Skip to content

CXX-3069 document directories, namespaces, and generated headers #1173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

eramongodb
Copy link
Contributor

@eramongodb eramongodb commented Jul 22, 2024

Summary

Partially resolves CXX-3069. Followup to #1170.

Adds Doxygen documentation for directories, namespaces, and generated headers. Docs for files and root namespace redeclarations are deferred to a followup PR.

This PR proposes organizing Doxygen documentation at the bottom of header files in the following order:

// License notice.

#pragma once

#include <headers> // Include directives and etc.

namespace bsoncxx { ... } // Declarations and definitions.

///
/// @file
/// Documentation for this file.
///

///
/// @dir path/to/dir
/// Documentation for relevant subdirectories.
///

///
/// @namespace ns::qualifier
/// Documentation for relevant namespaces.
///

This is to avoid their interference with general development workflows, as these particular sets of documentation is not expected to be changed often.

Directories

This PR adds documentation of directories, which partially enables navigation via intermediate directories and the "File List" page.

image

More importantly, it triggers population of directory pages with subdirectory and file information (file docs are deferred to a followup PR).

image

Directories defer documentation to namespaces whenever able to avoid redundancy by referencing the namespace in its brief, since the directory structure mirrors the namespace structure.

To avoid ambiguity regarding which header within subdirectory to place directory documentation, all directory docs are collectively placed in the ABI directory's fwd.hpp file (with the exception of the library root directory itself).

Note: sometimes paths must be fully qualified relative to the project root directory or the library root directory for proper disambiguation by Doxygen, but this usually isn't necessary.

Namespaces

This PR adds documentation of namespaces (including root namespaces; redeclaration docs are deferred to a followup PR), which enables navigation via intermediate namespaces.

image

This triggers population of namespace pages with nested namespaces.

image

Similar to namespaces, all namespace docs are collectively placed in the ABI directory's fwd.hpp file to avoid placement ambiguity.

Currently, due to having a 1-to-1 relationship, v_noabi namespace docs reuse root namespace docs via @copydoc. This may no longer be possible if namespace restructuring occurs in the future, but this is expected to be a far-future concern.

Config Headers

This PR also adds documentation for generated headers under config/ (i.e. config.hpp) in the form of Doxygen modules (aka "named groups"). This PR also documents headers already visible under the config/ directory (i.e. prelude.hpp) for completeness.

image

image

This means macros such as BSONCXX_POLY_USE_* and BSONCXX_VERSION_* are finally documented proper by the API doc pages! 🎉

Headers which are not intended for use by consumers of the library are labeled with a @warning For internal use only!. Docs for such files are intentionally kept brief and sparse in detail to avoid encouraging users to use the provided entities despite the warning.

Due to generated headers "not existing" according to Doxygen due to docs being generated from files under include/ only, their docs are defined in the ABI directory's fwd.hpp file alongside directory and namespace docs within a #if defined(BSONCXX_PRIVATE_DOXYGEN_PREPROCESSOR) block defining stubs for entities (primarily macros) provided by the relevant header files.

This has the effect of listing the generated header docs both in the fwd.hpp file page (where it is document) as well as the dedicated Module page (corresponding to the generated header). Some care and emphasis was required to make clear what file actually provides the documented entities.

Transitive Includes

The prelude.hpp and fwd.hpp headers demonstrates how supported transitive includes are intended to be explicitly documented following SHOW_INCLUDE_FILES = NO in #1166.

image

image

This is implemented using a @par command with a paragraph title and a @li list. The @parblock is not strictly necessary but is included regardless to clearly denote the expected scope of the page element (e.g. such that it does not unintentionally apply to subsequent paragraphs).

image

This pattern is expected to be used sparingly and only for header files where the transitive includes are clearly expected and deliberately supported (e.g. view_or_value.hpp transitively includes the corresponding view.hpp and value.hpp headers).

@eramongodb eramongodb requested a review from kevinAlbs July 22, 2024 17:51
@eramongodb eramongodb self-assigned this Jul 22, 2024
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question.

/// recommended, but may be necessary depending on how the mongocxx library is being imported or
/// packaged.
///
#define BSONCXX_STATIC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove BSONCXX_STATIC? The rendered documentation notes "These macros are provided by export.hpp". But BSONCXX_STATIC is applied on the CMake target, rather than defined in export.hpp.

Similar question applies to MONGOCXX_STATIC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Removed as suggested.

@eramongodb eramongodb merged commit 1baf35c into mongodb:master Jul 23, 2024
1 check was pending
@eramongodb eramongodb deleted the cxx-3069 branch July 23, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants