/* * Stellarium * Copyright (C) 2008 Fabien Chereau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /*! @page codingStyle Coding Style Conventions in Stellarium The increasing number of contributors require that we clearly define coding rules and guidelines. Although for historical reasons the current code of Stellarium does not always comply to these rules, they should now be respected for any addition or modification of the code. @section stylistic_conventions_sec Stylistic Conventions @section file_names_sec File Names The extensions are .hpp/.cpp for C++ headers/code, .h/.c for C headers/code. C++ files should have the same name and case than the class they contain. For example class StelFontMgr should be declared in file StelFontMgr.hpp and implemented in StelFontMgr.cpp. @section comments_sec Doxygen Comments Stellarium source code should be documented with Doxygen. From Doxygen webpage: "Doxygen is a documentation system for C++, C, Java, [...] It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual (in LaTeX) from a set of documented source files. [...] The documentation is extracted directly from the sources, which makes it much easier to keep the documentation consistent with the source code. [...] You can also visualize the relations between the various elements by means of include dependency graphs, inheritance diagrams, and collaboration diagrams, which are all generated automatically. All public and protected classes and methods from Stellarium should be fully documented in the headers (.hpp). There are different ways to comment C++ code with Doxygen, in Stellarium use the following for headers files: @verbatim //! Find and return the list of at most maxNbItem objects auto-completing the passed object I18n name. //! @param objPrefix the case insensitive first letters of the searched object. //! @param maxNbItem the maximum number of returned object names. //! @return a vector of matching object name by order of relevance, or an empty vector if nothing match. QList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5) const; @endverbatim Brief descriptions are single line only, and stop at the first full stop (period). Any subsequent sentences which occur before \@param or a similar tag are considered to be part of a detailed description. For methods definitions in .cpp files, a simpler comment for each method is sufficient: @code // Find and return the list of at most maxNbItem objects auto-completing the // passed object I18n name. QList listMatchingObjectsI18n(const QString& objPrefix, unsigned int maxNbItem=5) const { etc.. @endcode @section cpp_code C/C++ Code Use C++ replacement for C functions and Qt replacements for C++ function/STL wherever possible. @section translation_sec Translatable Strings and Console Output Translatable strings are translated using the Translator class, which is a C++ wrapper around gettext. The strings should be marked using the q_() macro: it takes a QString in English and returns the translation as a QString using the current global language.