How to document a new chapter / area of AOCL-DA functionality
Create a new ReStructuredText file in the
docdirectory (whereindex.rstis).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 in can be displayed in a collapsed form (html only), for this add the following
.. collapse:: AOCL-DA Sphinx Configuration.
.. literalinclude:: ../conf.py
:language: Python
:linenos:
1# Copyright (C) 2023-2025 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
32project = 'AOCL-DA'
33copyright = '2025, Advanced Micro Devices, Inc'
34author = 'Advanced Micro Devices, Inc'
35version = ''
36release = '5.1.1'
37
38# -- Get doc working for Python ----------------------------------------------
39# Add to PYTHONPATH
40sys.path.insert(0, os.path.relpath('../python_interface/'))
41autodoc_mock_imports = ['aoclda._aoclda', 'numpy']
42
43# -- General configuration ---------------------------------------------------
44extensions = ['sphinxcontrib.bibtex', 'breathe', 'sphinx.ext.napoleon',
45 'sphinx.ext.autodoc', 'sphinx_collapse', 'sphinx_design']
46bibtex_bibfiles = ['refs.bib']
47bibtex_reference_style = 'author_year'
48
49# -- Option for generating output conditional on cmake INTERNAL_DOC variable -
50exclude_patterns = ['**/doc/trees_forests/df_intro.rst']
51
52# -- Add any paths that contain templates here, relative to this directory. --
53templates_path = ['_template']
54
55# -- MathJax config ----------------------------------------------------------
56mathjax3_config = {
57 'chtml': {
58 'mtextInheritFont': 'true',
59 }
60}
61
62
63# -- Options for HTML output -------------------------------------------------
64
65html_theme = 'rocm_docs_theme'
66html_theme_options = {
67 "link_main_doc": False,
68 "flavor": "local",
69 "repository_provider": None,
70 "navigation_with_keys": False,
71 "navigation_depth": 1,
72}
73
74latex_elements = {
75 "preamble": '''
76\\setcounter{tocdepth}{2}
77'''
78}
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