4.5.1. Creating and Building New Doc - 4.5.1. Creating and Building New Doc - 5.3 English - 68552

AOCL API Guide (68552)

Document_ID
68552
Release_Date
2026-05-13
Version
5.3 English

How to document a new chapter / area of AOCL-DA functionality

  • Create a new ReStructuredText file in the doc directory (where index.rst is).

  • Write a general introduction to the chapter / area

  • Use the Breathe extension to Sphinx to document the API using Doxygen-formatted code comments

See linear-models.rst and aoclda_linmod.h for an example.

Installing the documentation dependencies

Create a virtual Python environment in which to install sphinx-build and the Sphinx extensions used by AOCL-DA. E.g.,

cd ~/DA-projects/aocl-da
python3 -m venv ~/DA-projects/doc-3
source ~/DA-projects/doc-3/bin/activate
pip install -r doc/requirements.txt

The presence of the requirements is checked in the build system.

It is also possible to add and pretty-print an entire file using

.. literalinclude:: <rel/abs/file.cpp>
    :language: C++
    :linenos:

Most extensions are understood: C, Python, etc.

If the file is too long or ancillary, then it can be displayed in a dropdown form (html only), for this add the following

.. dropdown:: AOCL-DA Sphinx Configuration.

    .. literalinclude:: ../conf.py
        :language: Python
        :linenos:
AOCL-DA Sphinx Configuration.
 1# Copyright (C) 2023-2026 Advanced Micro Devices, Inc. All rights reserved.
 2#
 3# Redistribution and use in source and binary forms, with or without modification,
 4# are permitted provided that the following conditions are met:
 5# 1. Redistributions of source code must retain the above copyright notice,
 6#    this list of conditions and the following disclaimer.
 7# 2. Redistributions in binary form must reproduce the above copyright notice,
 8#    this list of conditions and the following disclaimer in the documentation
 9#    and/or other materials provided with the distribution.
10# 3. Neither the name of the copyright holder nor the names of its contributors
11#    may be used to endorse or promote products derived from this software without
12#    specific prior written permission.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23# POSSIBILITY OF SUCH DAMAGE.
24#
25
26
27# Configuration file for the Sphinx documentation builder.
28
29# -- Project information -----------------------------------------------------
30import sys
31import os
32from docutils import nodes
33project = 'AOCL-DA'
34copyright = '2026, Advanced Micro Devices, Inc'
35author = 'Advanced Micro Devices, Inc'
36version = ''
37release = '5.2.2'
38
39# -- Get doc working for Python ----------------------------------------------
40# Add to PYTHONPATH
41sys.path.insert(0, os.path.relpath('../python_interface/'))
42autodoc_mock_imports = ['aoclda._aoclda', 'numpy']
43
44# Add a custom 'nref' role that renders plain text with no cross-reference ---
45def nref_role(name, rawtext, text, lineno, inliner, options=None, content=None):
46    """Role that renders text as-is with no cross-referencing."""
47    if options is None:
48        options = {}
49    if content is None:
50        content = []
51    node = nodes.inline(rawtext, text, classes=['nref'])
52    return [node], []
53
54def setup(app):
55    app.add_role('nref', nref_role)
56    return {
57        'version': release,
58        'parallel_read_safe': True,
59        'parallel_write_safe': True,
60    }
61
62# -- General configuration ---------------------------------------------------
63extensions = ['sphinxcontrib.bibtex', 'breathe', 'sphinx.ext.napoleon',
64              'sphinx.ext.autodoc', 'sphinx_design']
65bibtex_bibfiles = ['refs.bib']
66bibtex_reference_style = 'author_year'
67
68# -- Option for generating output conditional on cmake INTERNAL_DOC variable -
69exclude_patterns = ['**/doc/trees_forests/df_intro.rst']
70
71# -- Add any paths that contain templates here, relative to this directory. --
72templates_path = ['_template']
73
74# -- MathJax config ----------------------------------------------------------
75mathjax3_config = {
76    'chtml': {
77        'mtextInheritFont': 'true',
78    }
79}
80
81
82# -- Options for HTML output -------------------------------------------------
83
84html_theme = 'rocm_docs_theme'
85html_theme_options = {
86    "link_main_doc": False,
87    "flavor": "local",
88    "repository_provider": None,
89    "navigation_with_keys": False,
90    "navigation_depth": 1,
91}
92
93latex_elements = {
94    "preamble": '''
95\\setcounter{tocdepth}{2}
96'''
97}

How to build documentation via CMake

Build the doc target: it will build both the html and the pdf documentation

cmake -DBUILD_DOC=ON
cmake --build . --target doc

targets doc_html and doc_pdf are also available to build only one of the two.

cmake --build . --target doc_[html|pdf]

To build the release version of the doc (excluding internal documentation), set the variable INTERNAL_DOC at configure time:

cmake -DBUILD_DOC=ON -DINTERNAL_DOC=OFF
cmake --build . --target doc