Jump to content

Doxygen

From Wikipedia, the free encyclopedia
Developer(s)Dimitri van Heesch
Initial release26 October 1997; 27 years ago (1997-10-26)[1]
Stable release
1.13.1[2] Edit this on Wikidata / 2 January 2025; 4 days ago (2 January 2025)
Repository
Written inC++
Operating systemCross-platform
TypeDocumentation generator
LicenseGPLv2
Websitedoxygen.nl

Doxygen (/ˈdɒksiən/ DOK-see-jən)[3] is a documentation generator[4][5][6][7] that works with many programming languages. It extracts information from specially-formatted source code comments and saves the information in one of various supported formats.

Doxygen supports static analysis of a codebase. It uses the parse tree parsed from the codebase to generate diagrams and charts of the code structure. It provides cross-referencing that a reader can use to refer back to the source code from the generated documentation.

Doxygen can be used in many programming contexts. It supports many languages including C,[8] C++, C#, D, Fortran, IDL, Java, Objective-C,[9] Perl,[10] PHP,[11] Python,[12][13] and VHDL.[11] It can run on many computers, including Unix-like, macOS, and Windows systems. It is free software, released under the terms of the GNU General Public License version 2 (GPLv2).

History

[edit]

The first version of Doxygen borrowed code from an early version of DOC++, developed by Roland Wunderling and Malte Zöckler at Zuse Institute Berlin. Later, the Doxygen code was rewritten by Dimitri van Heesch.

Development

[edit]

The Doxygen source code is hosted at GitHub, where the main developer, Dimitri van Heesch, contributes under the name "doxygen".[14] Doxygen is written in C++, and consists of around 300,000 source lines of code. For lexical analysis, Lex (or its replacement Flex) is run via approximately 35,000 lines of lex script. The parsing tool Yacc (or its replacement Bison) is also used, but only for minor tasks. The bulk of parsing is done via native C++ code. The build system includes CMake and Python script.

Design

[edit]

Like other documentation generators such as Javadoc, Doxygen extracts information from both the comment and the symbolic (non-comment) code. A comment is associated with a programming symbol due to its proximity to the symbol in the code. Markup in the comments allows for controlling inclusion and formatting of the resulting documentation.

Doxygen supports output in many formats including: HTML, CHM, RTF, PDF, LaTeX, PostScript and man page.

Doxygen can generate inheritance diagrams for C++ classes. For more advanced diagrams and graphs, Doxygen can use the "dot" tool from Graphviz.[15]

Example

[edit]

All examples are given for languages with C-like comments where a multi-line comment starts with /* and a single line comment starts with //.

Doxygen ignores a comment unless it is marked specially. For a multi-line comment, the comment must start with /** or /*!. A markup tag is prefixed with a backslash (\) or an at-sign (@).[16] The following is a relatively simple function comment block with markup in bold:

/**
Function description
@param p1 Parameter description
@param p2 Parameter description
@return Return description
*/
void foo(int p1, int p2) {}

A block can be formatted various ways. A common way is to left-align asterisks on each line which Doxygen does not include in the output. For example:

/**
 * Function description
 * @param p1 Parameter description
 * @param p2 Parameter description
 * @return Return description
 */
void foo(int p1, int p2) {}

Alternatively, a block can consist of a series of single-line comments. Doxygen accepts comments with an additional slash (/) or exclamation (!).[17]

/// Function description
/// @param p1 Parameter description
/// @param p2 Parameter description
/// @return Return description
void foo(int p1, int p2) {}

To locate a documentation comment to the right of the code, an additional < marker is required.[18] This allows for an alternative approach for documenting parameters as shown below.

/**
 * Function description
 */
void foo(int p1 /**<Parameter description*/, int p2 /**<Parameter description*/) {}

A mathematic formula can be specified via LaTeX commands. For example:

/**
 * An inline equation @f$ e^{\pi i}+1 = 0 @f$
 * A displayed equation: @f[ e^{\pi i}+1 = 0 @f]
 */

A more complete example in C++:

/**
 * @file
 * @brief Time class header
 * @author John Doe <jdoe@example.com>
 * @version 1.0
 * @copyright CC BY-SA or GFDL
 * @sa <a href="https://en.wikipedia.org/wiki/Wikipedia:Copyrights">Wikipedia:Copyrights - Wikipedia</a>
 */

/**
 * Represents a moment of time
 * @author John Doe
 */
class Time {
public:
    /**
     * Construct with a duration since Jan 1, 1970
     * @param millis A number of milliseconds
     */
    explicit Time(long millis) : m_millis(millis) {
    }

    /**
     * Get a new instance with the current time
     * @return Instance
     */
    static Time now() {
        // ...
    }

private:
    long m_millis; ///< Milliseconds since Jan 1, 1970
};

See also

[edit]

References

[edit]
  1. ^ ANNOUNCE: doxygen 0.1 Archived October 4, 2011, at the Wayback Machine, Announcing: the first release of Doxygen, a C++ documentation system. , From: Dimitri van Heesch, Date: Sun, 26 Oct 1997, Qt-interest Archive
  2. ^ "Doxygen release 1.13.1". 2 January 2025. Retrieved 2 January 2025.
  3. ^ "Doxygen Manual: Frequently Asked Questions". www.doxygen.nl.
  4. ^ Perkel, Jeffrey M. (2015-11-22). "Get With the Program: DIY tips for adding coding to your analysis arsenal". The Scientist (Journal). The Scientist.
  5. ^ Sabin, Mihaela (2015-11-22). "Doxygen". OpenComputing (Wiki). University of New Hampshire. Archived from the original on 2015-11-23.
  6. ^ "Doxygen". Free Software Directory (Wiki). 2015-11-22.
  7. ^ "Documentation". Rosetta Code (Wiki). 2015-11-22.
  8. ^ "Documentation: C". Rosetta Code (Wiki). 2015-11-22.
  9. ^ "Documentation: Objective-C". Rosetta Code (Wiki). 2015-11-22.
  10. ^ "Doxygen::Filter::Perl - A perl code pre-filter for Doxygen - metacpan.org". metacpan.org.
  11. ^ a b "Doxygen Manual: Getting started". www.doxygen.nl.
  12. ^ "Automatic Python API documentation generation tools". python.org wiki (Wiki). 2015-11-22.
  13. ^ Brown, Eric W. "doxypypy: A Doxygen filter for Python" – via PyPI.
  14. ^ "doxygen/doxygen". June 9, 2021 – via GitHub.
  15. ^ "Doxygen Manual: Graphs and diagrams". www.doxygen.nl.
  16. ^ Doxygen: Special Commands
  17. ^ Doxygen: Documenting the code - §Comment blocks for C-like languages
  18. ^ Doxygen: Documenting the code - §Putting documentation after members
[edit]