1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-06-08 17:41:56 +00:00
oot/docs/Documenting.md
Dragorn421 7d2786b2ca
fix
2025-06-07 01:29:48 +02:00

3.8 KiB

Documentation Style Guide

This project uses Doxygen to generate documentation pages from comments found in the source files. This guide focuses on writing compatible comments and ensuring consistency across the codebase.

However to keep the documentation readable in text and favor consistency, the Doxygen commands that should be used are restricted to what this document mentions.

To generate a doxygen manual for the project, ensure you have doxygen installed and then cd into the project root directory and run doxygen Doxyfile.

The documentation can then be browsed by opening docs/doxygen/html/index.html in a web browser.

Documenting Functions

Any comments inside functions, except bugs (see below), should use //-style comments, even if spanning over multiple lines.

A simple example of documenting a function with just a description (note the leading /**):

/**
 * Update the crawl sound timer, and play the crawling sound when it reaches 0.
 */
void EnInsect_UpdateCrawlSfx(EnInsect* this) {

A more complete example:

/**
 * Request to either increase or consume magic.
 *
 * @param amount the positive-valued amount to either increase or decrease magic by
 * @param type how the magic is increased or consumed.
 *
 * @return false if the request failed
 */
s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type) {

Note:

  • Documentation for self-explanatory arguments (@param) and return values (@return) may be omitted.
  • @param commands should not have empty lines in between.
  • Different commands (main description, @param, @return, ...) should be separated by empty lines.

Other directives that may be used for documenting functions:

  • @see to reference something else (see below).
  • @note to bring attention to some of the function behavior.

Documenting Variables

In case the name of a variable isn't completely clear, documentation can provide a description.

If applicable, it may refer to a set of defines or enumerations that should be used with it (those should be linked with @see, see below).

/**
 * My description of this variable
 */
s32 foo;

Documenting Files

File documentation should be located at the top of the file, above #includes.

File documentation should only feature information that is general to the file or the system it implements.

/**
 * @file z_fcurve_data_skelanime.c
 * @brief Curve skeleton animation system
 *
 * A curve skeleton has a fixed number of limbs, ...
...
 */

Other

Documenting Bugs:

Bugs should be documented on the line above where the bug begins.

//! @bug Missing early return

Bug described on multiple lines should still use the //! syntax, over multiple lines. For example:

//! @bug this code was clearly meaning to print `abs(camera->camDataIdx)` as a
//! one-or-two-digit number, instead of `i`.

@see should be used to provide links to related information where appropriate, for example:

/**
 * Sets the next framebuffer to the framebuffer associated to `task`.
 * If there is no current buffer or it is time to swap, this buffer will be swapped to
 * immediately, otherwise it will be swapped to later in Sched_HandleRetrace.
 *
 * @see Sched_HandleRetrace
 */
void Sched_SetNextFramebufferFromTask(Scheduler* sc, OSScTask* task) {

In the case of functions, @see should come before the first @param.

@see may also be used for documenting files or variables.

HTML and LaTeX

It is possible to include HTML and LaTeX in documentation comments.

However it is prefered not to do so, so that the raw text stays readable when looked at as plain text, for example when browsing the source code.