4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-24 12:37:04 +08:00
Chen Wang 761bb89f27 doxygen: add documentation for doxygen
Documentation is provided to clarify how to write
doxygen documentation for RT-Thread. This document
is also integrated as part of RT-Thread doxygen
documentation.

An example is also provided.

The original README.md is removed and integrated into
this document.

Updated github actions for doxygen too.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
2025-02-11 17:09:44 +08:00

4.6 KiB
Raw Blame History

@page howto_doxygen How to write doxygen documentation for RT-Thread

RT-Thread Online Documentation is created based on doxygen and is available at: https://rt-thread.github.io/rt-thread/. It is consisted of two parts.

One part is the detailed introduction of Kernel, which is written in markdown format and converted into HTML page by doxygen. It is displayed under "RT-Thread User Guide" in Treeview on the left side of the browser. Each sub-chapter is organized into a hierarchical structure by using doxygen's subpage mechanism. There are no special requirements for writing this part, so I will not go into details in this article.

The other part is the description of API. RT-Thread uses doxygen to automate the generation of documentation from source code comments, parsing information about classes, functions, and variables to produce output in format of HTML. It is displayed under "Modules" in Treeview on the left side of the browser. Each sub-chapter is organized into a hierarchical structure by using doxygen's topics mechanism. The main content of this article is to describe how to write API with doxygen.

General Rules on writing API documentation

@note The code comments and HTML content generated by doxygen in this guide, for the structures, constants(macro definition), enumeration values, union values, global functions, global variables and other objects involved are all within the scope of the RT-Thread kernel API. The code of internal functions, variables (such as static functions etc.) are not belong to the API scope, how to write comment for these elements are not considered in this guide.

By default, API documentation is written in header files, but there are exceptions, such as for functions.

There are several ways to mark a comment block as a detailed description. We prefer JavaDoc-style (C-style) comment block with some additional markings to document the code, like this:

/**
 * ... text ...
 */

When you want to put documentation after members, we prefer a Qt style, like this:

int var; /**< Detailed description after the member */

When writing comments based on doxygen, several commands defined by doxygen are used. See https://www.doxygen.nl/manual/commands.html for more details about doxygen commands.

More details refer to Doxygen Docs: Documenting the code

Detailed Rules on writing API documentation

This article provide an example.

Click @ref group_doxygen_example for the corresponding HTML documentation that is generated by Doxygen.

The contents of Example are described in the following chapters:

  • @subpage page_howto_groups

  • @subpage page_howto_macro

  • @subpage page_howto_struct

  • @subpage page_howto_union

  • @subpage page_howto_enum

  • @subpage page_howto_typedef

  • @subpage page_howto_function

Build & Run

How to build & run doxygen html on Ubuntu

The following steps are verified on Ubuntu 22.04

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.5 LTS
Release:	22.04
Codename:	jammy

The following packages (and dependents) need to be installed:

$ sudo apt update
$ sudo apt install doxygen
$ sudo apt install graphviz

Assume that the path of RT-Thead code tree is $RTT, execute the following command to build html.

$ cd $RTT/documentation
$ rm -rf html
$ doxygen

A new html directory will be created and all the html files will be placed in this directory.

If you want to quickly browse HTML locally (in Ubuntu environment), you can enter the html directory and start a local HTML server through Python.

$ cd html
$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

A bash script run.sh is provided to automatic upon operations.

$ cd $RTT/documentation
$ ./run.sh

Then open the browser and enter http://<IP>:8000/index.html to access the created html web pages. If it is a local access, then <IP> should be replaced by localhost. If it is a remote access, then <IP> should be replaced by the actual accessible IP address of the machine where HTML is located.

How to build & run doxygen html with Doxywizard

  1. download from https://doxygen.nl/index.html
  2. open Doxywizard
  3. File -> Open
  4. Open the file ./Doxyfile
  5. To tab Run , Click Run doxygen