Doxygen
Doxygen is a free, open-source documentation generator designed to automatically produce documentation from specially formatted comments embedded in source code.[1] Developed by Dimitri van Heesch, it was first publicly released in 1997 as a cross-platform tool written primarily in C++, enabling software developers to create comprehensive, navigable documentation that enhances code maintainability and collaboration.[2] The tool supports a wide array of programming languages, including C, C++, Python, Java, PHP, C#, Objective-C, Fortran, VHDL, Splice, IDL, and Lex, making it versatile for diverse software projects.[1]
Key features of Doxygen include the generation of multiple output formats such as HTML, PDF, LaTeX, RTF, Word, and XML, which allow for web-based browsing, printable documents, and integration with other tools.[3] It incorporates advanced capabilities like cross-referencing, hyperlinks between code elements, automatic diagram generation for class hierarchies and collaborations, and support for Markdown syntax within comments to facilitate richer documentation.[4] Configuration is handled through a customizable Doxyfile, which permits fine-tuning of output styles, inclusion of external files, and generation of inheritance graphs or call graphs to visualize code structure.[5]
Since its inception, Doxygen has evolved through community contributions and regular updates, with its source code repository migrating from Subversion to GitHub in May 2013 to foster collaborative development.[3] As of October 22, 2025, the latest stable release continues to emphasize compatibility with modern development practices, including integration with version control systems and IDEs like Visual Studio Code.[1] Widely adopted in open-source and proprietary projects, Doxygen serves as the de facto standard for extracting and organizing inline documentation, particularly in C++ ecosystems, by parsing comments marked with special commands (e.g., /** for blocks) to build indexed, searchable resources.[3]
Introduction
Overview
Doxygen is an open-source documentation generator that parses source code and extracts structured documentation from specially formatted comments embedded within it.[4] This tool automates the production of technical documentation, such as API references and user manuals, by interpreting markup in code comments to create organized, searchable outputs.[1]
The primary purpose of Doxygen is to facilitate the maintenance and readability of software projects, particularly in collaborative environments where clear documentation reduces errors and eases onboarding for developers.[6] By linking comments directly to code elements, it ensures that documentation remains synchronized with the codebase, minimizing outdated information that plagues manual documentation efforts.[3]
Widely regarded as the de facto standard for C++ projects, Doxygen also extends its applicability to numerous other programming languages, making it a versatile choice across diverse software ecosystems.[3] Key benefits include robust cross-referencing between code components, automatic indexing for quick navigation, and seamless integration of documentation with the source code itself to produce highly navigable resources.[4] It supports multiple output formats, with HTML being particularly favored for its interactivity and web accessibility.[4]
Licensing and Availability
Doxygen is released under the terms of the GNU General Public License (GPL) version 2, a copyleft license that grants users the freedom to use, study, modify, and distribute the software, provided that derivative works are also licensed under the same terms.[7] This licensing model ensures that Doxygen remains open-source and accessible for integration into various software development workflows without proprietary restrictions.[7]
The copyright for Doxygen is held by Dimitri van Heesch, its primary author, dating back to its initial release in 1997.[7] No warranties are provided with the software, which is distributed on an "as is" basis.[7]
Doxygen is freely available for download from its official website at doxygen.nl, where the latest stable release (version 1.15.0 as of October 2025) can be obtained in multiple formats.[8] Pre-built binaries are provided for major operating systems, including Windows (x64 installer and ZIP archive for Windows 10 and 11), Linux (tarball for Ubuntu 20.04 and compatible distributions), and macOS (disk image for macOS 10.15 and later).[8] For users preferring to build from source, the complete source code is hosted on the official GitHub repository at github.com/doxygen/doxygen, supporting compilation on these platforms and others via standard tools.[3]
The project encourages community involvement, with contributions accepted through the GitHub repository's issue tracker for reporting bugs or feature requests and pull requests for code submissions, fostering ongoing development and maintenance.[3]
History
Origins and Early Development
Doxygen was created by Dimitri van Heesch in 1997 as a cross-platform documentation generator written in C++, initially developed to address documentation needs for C++ projects, particularly those involving the Qt framework.[4][9] The tool emerged from van Heesch's work on a Qt-based GUI widget toolkit, where the challenges of manually maintaining documentation proved to be a significant burden, often described as a "nightmare."[9] Existing solutions, such as Qt's internal (unreleased) documentation tool and Doc++, fell short for Qt-specific requirements, including inadequate handling of features like signals and slots, as well as insufficient customization for Qt's visual style.[9] These limitations motivated the creation of a more flexible system capable of extracting and formatting information directly from annotated source code comments to produce structured documentation with cross-references.[9][4]
The inaugural version of Doxygen drew inspiration and borrowed some code from an early iteration of Doc++, a C++ documentation tool authored by Roland Wunderling and Malte Zöckler at the Zuse Institute Berlin.[4] Despite this foundation, van Heesch quickly rewrote nearly all of the codebase to better align with his vision, emphasizing portability across platforms and integration with C++ source annotations.[4] Early releases prioritized generating basic HTML output from specially formatted comments in source files, enabling simple navigation and linking between documented elements without requiring separate documentation files.[4] This approach allowed developers to embed descriptions, parameters, and relationships directly in the code, streamlining the documentation process for large C++ codebases.[9]
Doxygen's first public release occurred in 1997, establishing it as an open-source tool under the GNU General Public License and making it accessible for C++ developers seeking automated documentation generation.[4] In the early 2000s, van Heesch performed a comprehensive rewrite to enhance the tool's scalability for larger projects and to broaden its language support beyond initial C++ focus, laying the groundwork for its evolution into a multi-language documentation system.[4]
Major Releases and Evolution
Doxygen's evolution from the mid-2000s onward reflects a steady progression toward broader language support, enhanced parsing accuracy, and integration with contemporary development tools, building on its initial creation in 1997 by Dimitri van Heesch.[1] A key milestone in collaborative development occurred in May 2013, when the project transitioned from Subversion to Git hosted on GitHub, enabling easier community contributions and version control.[3]
Version 1.8.0, released on February 25, 2012, introduced native support for Markdown within documentation comments, simplifying the creation of formatted text and tables without requiring complex HTML or LaTeX syntax.[10] This release also added features like table-of-contents generation and improved output customization, marking a shift toward more user-friendly documentation authoring. Subsequent versions built on this foundation, with version 1.9.0 on December 27, 2020, delivering extensive bug fixes for comment parsing and output generation, alongside documentation updates that improved usability for multi-language projects.[11]
Further advancements in language handling appeared in version 1.9.6, released December 27, 2022, which added support for Python's PEP 526 variable annotations and enhanced enum documentation warnings via the new WARN_IF_UNDOC_ENUM_VAL option, addressing gaps in dynamic language parsing.[11] Version 1.10.0, issued on December 25, 2023, enhanced diagram generation through better inheritance graph rendering and flexible graph attributes, leveraging integrations with tools like Graphviz for more precise visual representations of code structures in large codebases.[11] These updates emphasized performance optimizations, such as reduced processing times for expansive projects, and expanded compatibility with modern standards like C++20 modules introduced in version 1.9.7.[11]
In 2025, version 1.14.0 on May 24 incorporated minor compatibility adjustments, bug fixes for Markdown link processing and SVG diagram padding, along with refactoring for improved stability and user feedback mechanisms.[11] The subsequent 1.15.0 release on October 22 refined Markdown strict mode by default, fixed Python module separator issues, and bolstered LaTeX table handling, continuing the trend of refining output quality and integration with visual tools like PlantUML for diagram creation.[11] Overall, Doxygen's trajectory has prioritized incremental expansions in language coverage—such as VHDL 2017 updates and Objective-C implementation parsing—while focusing on scalability for enterprise-scale codebases through ongoing performance tweaks and community-driven enhancements.[11]
The project remains primarily maintained by Dimitri van Heesch, with active community involvement through GitHub issues, pull requests, and contributions that ensure timely responses to evolving software documentation needs.[3]
Core Features
Supported Languages
Doxygen provides primary support for C, C++, and Objective-C, offering deep integration with language-specific constructs such as classes, namespaces, templates, and inheritance relationships to enable comprehensive parsing and cross-referencing in generated documentation.[5] This level of support allows for advanced features like detailed class hierarchies and template specialization documentation, making it particularly robust for object-oriented C++ projects.[6]
In addition to these core languages, Doxygen supports a range of others including Java, Python, JavaScript, PHP, C#, Fortran, IDL (for CORBA and Microsoft interfaces), Tcl, VHDL, D, Lex, and hardware description formats, with parsing capabilities tailored to each but varying in depth.[12] For instance, Python receives full docstring parsing and module recognition, while Java and C# benefit from strong support for interfaces and generics; however, scripting languages like Python, JavaScript, and PHP have more limited feature sets compared to compiled languages.[5] VHDL support focuses on entity and architecture parsing for hardware designs, and Fortran handles fixed- and free-form source code.[12]
Certain languages exhibit partial support, particularly in areas like full inheritance graphs, which are not comprehensively generated for scripting languages due to their dynamic nature and lack of static typing enforcement.[13] For example, while class diagrams can be produced for Python, they may not fully capture runtime inheritance behaviors, leading to incomplete visualizations in some cases.[14] Similarly, PHP and JavaScript parsing prioritizes function and variable extraction but omits advanced relational graphs available in C++.[6]
Doxygen's extensibility allows users to add custom language support through configuration options like EXTENSION_MAPPING, which maps file extensions to specific parsers, enabling processing of non-standard or proprietary formats without core modifications.[12] This feature, combined with filter extensions for languages like assembly or Visual Basic via external tools, enhances adaptability for diverse codebases.[15]
Doxygen produces documentation in multiple output formats, enabling users to generate materials suitable for various distribution and viewing needs. The primary and default format is HTML, which includes features such as frames for navigation, integrated search functionality, and support for interactive elements like collapsible sections.[16] Other directly supported formats include LaTeX for compiling into PDF, PostScript, or DVI files; RTF optimized for Microsoft Word; Unix-style man pages; XML for structured data exchange or further processing; and DocBook for additional typesetting options.[12] Indirect formats, such as compressed HTML help files (e.g., CHM for Windows or QCH for Qt), can be derived from the HTML output using external tools, while EPUB may be created by converting HTML results with third-party utilities, though not natively generated by Doxygen.[16]
The generation process begins with Doxygen scanning the specified source files across supported languages, parsing the code to extract specially formatted comments (known as docblocks) that document entities like functions, classes, and variables.[5] It then builds an internal database of cross-references, linking related elements such as function calls, class inheritances, and variable usages to create a navigable structure. Finally, Doxygen compiles this information into the selected output formats, incorporating diagrams where applicable by invoking external tools like Graphviz's dot utility to render call graphs, inheritance diagrams, and collaboration visuals in formats such as PNG or SVG.[17] This pipeline ensures that documentation reflects the current state of the codebase without manual intervention.
Customization of the outputs allows for tailored content inclusion, such as embedding full source code listings via the SOURCE_BROWSER option, generating call graphs with CALL_GRAPH enabled, or producing inheritance diagrams through CLASS_GRAPH settings, all of which enhance the depth of the generated documentation.[12] Users can further adjust elements like graph image formats (e.g., PNG for raster or SVG for vector scalability) and enable features such as inline source code snippets for functions.[18]
Key advantages of Doxygen's output generation include hyperlinked navigation, which facilitates quick traversal between code elements in HTML and PDF formats (when PDF_HYPERLINKS is enabled during LaTeX processing), and the ability to automatically regenerate documentation upon code changes, maintaining synchronization between source and docs.[16] These features promote efficient developer workflows and accessible, up-to-date project overviews.[1]
Design and Implementation
Parsing Mechanism
Doxygen's parsing mechanism relies on a lexer-based approach to process source code without performing a full compilation, enabling the extraction of documentation and structural information efficiently. The core lexer, generated using Flex and implemented in the scanner.l file, functions as a finite state machine that tokenizes input files by recognizing patterns such as comments, code blocks, identifiers, and symbols. This tokenization occurs independently for different programming languages through language-specific parsers, but the underlying mechanism treats the source as a stream of tokens to identify relevant elements like function definitions and class declarations. The process begins with scanning the input to build a hierarchical tree of Entry objects, where each Entry encapsulates a segment of parsed data, including fields like section to denote the type of information (e.g., class or member).[19]
Following tokenization, Doxygen constructs an internal symbol database to represent and interconnect parsed elements. This database organizes symbols—such as classes, functions, namespaces, and variables—into specialized dictionaries maintained in global data structures defined in doxygen.h. Symbols are stored as instances of classes derived from the abstract Definition base class, including ClassDef for classes and MemberDef for members, which capture attributes like visibility, relationships, and documentation attachments. This representation facilitates cross-referencing, where symbols are linked to their declarations, definitions, and usages across files, allowing Doxygen to resolve dependencies and generate navigational structures. The database is populated incrementally during parsing, ensuring that relationships like inheritance or function calls are accurately modeled for later use in documentation generation.[19]
Prior to lexer-based parsing, Doxygen applies a built-in preprocessor to handle compiler-like directives and prepare the input stream. This preprocessor, akin to a C frontend, evaluates conditional compilation (#if, #ifdef), expands macros (optionally, based on configuration), and processes #include directives by noting dependencies without recursively including content to avoid redundancy and infinite loops. Macro definitions are parsed and stored, but expansion is partial by default—conditionals are resolved using a Yacc-generated parser in constexp.y, while full expansion requires enabling MACRO_EXPANSION. This step mimics compiler preprocessing to resolve aliases and guards, ensuring the lexer receives a normalized input that accurately reflects the effective code structure.[20][19]
Error handling in Doxygen's parsing emphasizes warnings over fatal stops, reflecting its role as a documentation tool rather than a validator. As a lexical scanner, it does not detect semantic errors like type mismatches but issues warnings for malformed comments (e.g., unbalanced blocks or invalid markup) and unsupported constructs via options like WARN_IF_DOC_ERROR, which flags issues such as duplicate parameters in documentation. Preprocessing errors, like unresolved macros, are reported similarly, with output directed to standard error unless logged to a file via WARN_LOGFILE. Configuration allows treating warnings as errors through WARN_AS_ERROR, halting processing on detection, and the system provides debugging aids like Flex's debug mode for lexer rules. These mechanisms ensure robust processing while alerting users to documentation inconsistencies without interrupting the overall flow.[12][21]
Special Commands and Syntax
Doxygen employs a specialized markup language embedded within source code comments to generate structured documentation. This syntax allows developers to annotate code elements such as functions, classes, and variables directly, enabling the extraction of detailed, interconnected documentation. Comments must be placed in specific block formats recognized by Doxygen's parser, primarily using delimiters that distinguish them from regular code comments. For instance, in C-like languages including C, C++, Objective-C, Java, and PHP, multi-line documentation blocks are typically enclosed in /** ... */ or /*! ... */, while single-line comments use /// ... or //! .... These formats ensure that the content is identified as documentation rather than executable code, with the asterisks or exclamation marks signaling Doxygen to process the enclosed text.[6]
The core of Doxygen's syntax revolves around special commands, which begin with either @ or \ and are used to tag and describe code elements. Parameter documentation is handled by the @param command, which specifies a function's input or output parameter along with its description, optionally including direction indicators like [in] or [out] (e.g., @param [in] a an [integer](/page/Integer) value). Similarly, @return documents the function's output value, providing a concise explanation of what it represents. Cross-references to related entities are facilitated by @see, which links to other documented items, URLs, or files, enhancing navigability in the generated output. For conditional inclusion of documentation sections, the \if command defines blocks that are included or excluded based on configuration settings, such as language-specific content (e.g., \if english ... \endif). These commands must appear within recognized comment blocks and follow a structure where arguments are delimited by braces {} for descriptions, parentheses () for phrases, or angle brackets <> for identifiers, ensuring precise parsing.[22][6]
Structural tags provide higher-level organization for documentation. The @class command initiates documentation for a class, optionally specifying its header file and name (e.g., /** \class MyClass myheader.h "My Class [Documentation](/page/Documentation)" */), allowing for standalone class descriptions independent of code location. Namespaces are documented using @namespace, which groups related classes and functions under a scope (e.g., @namespace std::utils). File-level documentation is managed by @file, which describes source or header files, with an optional custom name for the entry (e.g., /** \file utils.[cpp](/page/CPP) "Utility Functions" */). These tags enable the creation of hierarchical documentation structures that mirror the codebase's organization, supporting inheritance graphs and module overviews in the output.[22]
Doxygen extends its syntax to incorporate modern formatting options within comments. Markdown is natively supported, allowing the use of elements like headers (#), lists (-), bold (**), italics (*), and tables directly in documentation blocks for improved readability without additional commands. HTML tags are permitted for finer control, such as <b> for bold or <pre> for code snippets, though Doxygen processes only a safe subset to maintain output consistency. For mathematical expressions and advanced typesetting, LaTeX syntax is integrated, enabling inline formulas via \f$ (e.g., \f$ E = mc^2 \f$) or displayed equations in block form, which are rendered in PDF or HTML outputs using external tools like LaTeX. These extensions blend seamlessly with special commands, permitting rich, multimedia-enhanced documentation while adhering to the core block comment structure.[23][24]
Usage and Configuration
Basic Command-Line Usage
Doxygen is invoked from the command line using the primary executable named doxygen, which processes source code and generates documentation based on a configuration file.[25] The core command takes the form doxygen [config_file], where config_file is the path to a Doxyfile; if omitted, Doxygen searches for a file named Doxyfile in the current directory and uses it if found, otherwise applying default settings.[25]
Essential command-line options facilitate initial setup and basic operations. The -g <config_file> option generates a new configuration file with default values, allowing users to customize it before running documentation generation, as in doxygen -g myproject.[25] For version information, the --version flag displays the current Doxygen release, helping verify installation details.[25] Additionally, --help provides a concise overview of all available options and usage syntax.[25]
Input sources are specified within the configuration file rather than directly on the command line. The INPUT directive lists directories or individual files containing the source code to process; if left empty, Doxygen defaults to the current directory.[12] The PROJECT_NAME setting defines the project's title, defaulting to "My Project" if unspecified, which appears in the generated documentation.[12]
By default, Doxygen produces output in the current working directory, creating subdirectories such as html/ for HTML-based documentation (enabled via GENERATE_HTML = YES) and latex/ for LaTeX sources (enabled via GENERATE_LATEX = YES).[12] These defaults enable quick starts without extensive configuration, though advanced tweaks like output paths are handled in the Doxyfile.[12]
Doxyfile Configuration
The Doxyfile serves as the primary configuration file for Doxygen, allowing users to customize the documentation generation process through a free-form ASCII text format resembling a Makefile.[12] This file, typically named Doxyfile by default, is case-sensitive and consists of key-value pairs in the form TAG_NAME = value, where values can be booleans (YES/NO), strings, numbers, or lists appended with +=.[12] Comments are denoted by #, with double ## preserved in output, and special characters like spaces in values require quotes, while line continuations use backslashes.[12] Each project should have its own Doxyfile to encapsulate settings, enabling reproducible builds across environments.[12]
The Doxyfile is organized into logical sections without explicit delimiters, grouping related options for clarity. The PROJECT section defines metadata such as PROJECT_NAME (default: "My Project"), PROJECT_NUMBER, PROJECT_BRIEF_DESCRIPTION, and PROJECT_LOGO for branding the generated documentation.[12] The BUILD section controls extraction and output behaviors, including EXTRACT_ALL = YES to include undocumented members in the documentation or NO to limit to documented ones only (default: NO).[12] The INPUT section specifies source files and directories via INPUT (a list of paths), FILE_PATTERNS for filtering (e.g., "*.cpp *.h"), and RECURSIVE = YES to traverse subdirectories (default: NO).[12] The OUTPUT section manages generation locations, with OUTPUT_DIRECTORY setting the base path and CREATE_SUBDIRS = YES organizing outputs into subfolders (default: NO).[12]
Essential options in the Doxyfile enable core customizations for documentation scope and formats. For instance, GENERATE_HTML = YES (default: YES) produces HTML output, while setting it to NO disables it to focus on other formats like LaTeX or PDF.[12] The HAVE_DOT = YES option detects and enables the Graphviz dot tool for generating diagrams, call graphs, and inheritance visuals, requiring Graphviz installation for functionality.[12] These settings allow users to tailor Doxygen's behavior to project needs, such as enabling comprehensive extraction with EXTRACT_ALL for initial API overviews.[12]
Advanced settings provide finer control over verbosity, warnings, and language-specific features. QUIET = YES suppresses non-essential output messages during processing (default: NO), useful in automated build pipelines.[12] WARN_FORMAT customizes warning message appearance, defaulting to "$file:$line: $text" but modifiable for integration with tools like continuous integration systems.[12] Language-specific options include, for example, JAVADOC_AUTOBRIEF = YES to interpret the first line of Javadoc-style comments as the brief description (default: NO), as well as options like PYTHON_DOCSTRING for Python docstring handling and OPTIMIZE_FOR_FORTRAN for Fortran-optimized output.[12]
Best practices for managing the Doxyfile emphasize maintainability and portability. It should be committed to version control to ensure consistent documentation across team members and builds, using relative paths in INPUT and environment variables like $(SRCDIR) to avoid hardcoding absolute paths.[12] The @INCLUDE directive allows modular inclusion of partial configs for shared settings, while ## comments document customizations for future reference.[12] Running doxygen -u updates the file with new defaults from Doxygen releases, preserving user changes.[12] Command-line options can override Doxyfile settings for one-off runs, but persistent configurations remain in the file.[12]
Examples
Simple Annotation Example
A simple annotation example in Doxygen involves embedding documentation comments directly in the source code using block comments delimited by /** and */, which allows the tool to extract and format the information into structured output.[6] For a basic C++ function, consider the following code snippet from a file named example.cpp:
cpp
/**
* @brief Adds two integers.
* This function computes the sum of the provided inputs.
* @param x First input value.
* @param y Second input value.
* @return The sum of x and y.
*/
int add(int x, int y) {
return x + y;
}
/**
* @brief Adds two integers.
* This function computes the sum of the provided inputs.
* @param x First input value.
* @param y Second input value.
* @return The sum of x and y.
*/
int add(int x, int y) {
return x + y;
}
Here, the @brief command provides a concise summary that appears in overviews, while the subsequent lines offer a detailed description; @param tags document each parameter, and @return specifies the output.[6]
To generate documentation from this code, a minimal Doxyfile configuration is required, specifying the input source and enabling HTML output. An example Doxyfile includes:
PROJECT_NAME = "Simple Example"
INPUT = example.cpp
OUTPUT_DIRECTORY = html
GENERATE_HTML = YES
PROJECT_NAME = "Simple Example"
INPUT = example.cpp
OUTPUT_DIRECTORY = html
GENERATE_HTML = YES
Running doxygen Doxyfile processes the input and produces HTML files in the html directory.[12][6]
The resulting HTML output features a main index page listing the documented function under a class or namespace hierarchy if applicable, linking to a dedicated page for add(). On this page, the brief description "Adds two integers." is displayed prominently in a summary section, followed by the detailed description in an expanded details area. The parameters are rendered in a definition list (<dl class="params">) with terms like <dt>x</dt><dd>First input value.</dd> and similarly for y, while the return value appears in a dedicated <div class="return"> block stating "The sum of x and y." This structure ensures easy navigation and readability for users.[6]
Advanced Graph and Diagram Example
To illustrate advanced documentation features in Doxygen, consider a C++ class hierarchy where a base class Animal is inherited by a derived class Dog, which in turn contains a member of type Cat from another inheritance branch. This example demonstrates automatic generation of inheritance diagrams, call graphs, and custom diagrams using special commands, enabling visual representation of relationships.[13]
The following code snippet defines the hierarchy with Doxygen comments. The base class is documented using the \class command to provide a brief description, while a custom graph is embedded via the \dot command to explicitly illustrate the inheritance and composition relationships using Graphviz DOT syntax.
cpp
/**
* @class [Animal](/page/A.N.I.M.A.L.)
* @brief Base class representing a generic animal.
*
* This class provides common attributes for all animals.
*/
class [Animal](/page/The_Animal) {
public:
virtual void makeSound() = 0;
};
/**
* @class Cat
* @brief A specific animal type that inherits from Animal.
*/
class Cat : public Animal {
public:
void makeSound() override { /* Implementation */ }
};
/**
* @class Dog
* @brief A derived animal that inherits from Animal and contains a Cat member.
*
* \dot
* digraph inheritance_example {
* node [shape=record, style=filled, fillcolor=lightblue];
* Animal [label="{Animal|makeSound(): void}"];
* Cat [label="{Cat|+makeSound(): void}", fillcolor=lightgreen];
* Dog [label="{Dog|+makeSound(): void\n|-cat: Cat}", fillcolor=lightyellow];
* Animal -> Cat [arrowhead="onormal", color=blue];
* Animal -> Dog [arrowhead="onormal", color=blue];
* Dog -> Cat [arrowhead="diamond", color=green, style=dashed];
* }
* \enddot
*/
class Dog : public Animal {
private:
Cat cat;
public:
void makeSound() override { /* Implementation */ }
};
/**
* @class [Animal](/page/A.N.I.M.A.L.)
* @brief Base class representing a generic animal.
*
* This class provides common attributes for all animals.
*/
class [Animal](/page/The_Animal) {
public:
virtual void makeSound() = 0;
};
/**
* @class Cat
* @brief A specific animal type that inherits from Animal.
*/
class Cat : public Animal {
public:
void makeSound() override { /* Implementation */ }
};
/**
* @class Dog
* @brief A derived animal that inherits from Animal and contains a Cat member.
*
* \dot
* digraph inheritance_example {
* node [shape=record, style=filled, fillcolor=lightblue];
* Animal [label="{Animal|makeSound(): void}"];
* Cat [label="{Cat|+makeSound(): void}", fillcolor=lightgreen];
* Dog [label="{Dog|+makeSound(): void\n|-cat: Cat}", fillcolor=lightyellow];
* Animal -> Cat [arrowhead="onormal", color=blue];
* Animal -> Dog [arrowhead="onormal", color=blue];
* Dog -> Cat [arrowhead="diamond", color=green, style=dashed];
* }
* \enddot
*/
class Dog : public Animal {
private:
Cat cat;
public:
void makeSound() override { /* Implementation */ }
};
This setup leverages Doxygen's parsing to automatically detect the inheritance from Animal to Cat and Dog, as well as the composition via the Cat member in Dog. The \class command ensures structured documentation for each class, while the \dot block inserts a tailored UML-style diagram showing public inheritance (solid arrows) and composition (dashed diamond arrow).[22][13]
To generate these visuals, the Doxyfile must be configured appropriately. Set HAVE_DOT = YES to enable integration with the Graphviz dot tool, which must be installed and accessible in the system PATH. Additionally, enable CALL_GRAPH = YES to produce call graphs for methods like makeSound(), revealing caller-callee relationships across the hierarchy. Other options, such as CLASS_DIAGRAMS = YES (default), ensure inheritance diagrams are created for documented classes. Without HAVE_DOT, diagrams fall back to textual representations.[17][26]
Upon running Doxygen (e.g., via doxygen Doxyfile), the output in HTML format includes auto-generated UML diagrams rendered by Graphviz, featuring colored nodes (e.g., yellow for classes, blue arrows for public inheritance) and integrated into class reference pages. For instance, the Dog class page displays the custom \dot graph alongside an automatic inheritance diagram showing Animal as the superclass, with hyperlinks to Cat and Animal pages. Call graphs appear as separate sections, visualizing invocations like Dog::makeSound() potentially calling related methods.[13]
The resulting documentation supports interactive navigation: users can click diagram elements to jump between linked class pages, facilitating exploration of the hierarchy and dependencies. This enhances maintainability in large codebases by providing a visual map of object-oriented structures.[13]