Skip to content

Commit

Permalink
Introduce Doxygen support inside documentation
Browse files Browse the repository at this point in the history
With Doxygen support inside documentation, we are able to generate
a full API documentation from LTP headers. The idea is that we don't
need to keep track of both source code and API documentation files,
but we will auto-generate any API documentation via Doxygen + Sphinx.
  • Loading branch information
acerv committed Mar 20, 2024
1 parent 15dc0f3 commit 8fd74b4
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build:
os: "ubuntu-22.04"
tools:
python: "3.6"
jobs:
pre_build:
- cd doc_new && doxygen Doxygen.in

# Build from the docs/ directory with Sphinx
sphinx:
Expand Down
1 change: 1 addition & 0 deletions doc_new/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
xml/
html/
7 changes: 7 additions & 0 deletions doc_new/Doxygen.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
GENERATE_XML = YES
GENERATE_LATEX = NO
GENERATE_HTML = NO
HIDE_IN_BODY_DOCS = YES
EXTRACT_ALL = YES
INPUT = ../include
OUTPUT_DIRECTORY = .
2 changes: 1 addition & 1 deletion doc_new/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ all:
sphinx-build -b html . html

clean:
rm -rf html/
rm -rf xml/ html/
18 changes: 16 additions & 2 deletions doc_new/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import subprocess

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

Expand All @@ -14,14 +17,25 @@
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []

# Doxygen support
extensions = ['breathe']
breathe_default_project = "ltp"
breathe_projects = {'ltp': 'xml'}

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

def generate_doxygen_xml(app):
"""
Generate API documentation via Doxygen if we are not
inside a readthedocs server.
"""
if not os.environ.get('READTHEDOCS', None):
subprocess.call('doxygen Doxygen.in', shell=True)

def setup(app):
app.add_css_file('custom.css')
app.connect("builder-inited", generate_doxygen_xml)
3 changes: 3 additions & 0 deletions doc_new/developers/api_c_tests.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
.. Include them in this file with:
.. .. doxygenfile:: tst_uid.h
Developing using C API
======================
3 changes: 3 additions & 0 deletions doc_new/developers/api_kvm_tests.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
.. Include them in this file with:
.. .. doxygenfile:: tst_uid.h
Developing using KVM API
========================
3 changes: 3 additions & 0 deletions doc_new/developers/api_network_tests.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0-or-later
.. Include them in this file with:
.. .. doxygenfile:: tst_uid.h
Developing using network API
============================
1 change: 1 addition & 0 deletions doc_new/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sphinx-rtd-theme==2.0.0
breathe==4.35.0

0 comments on commit 8fd74b4

Please sign in to comment.