docs: prepare for hawkmoth

Hawkmoth is a Sphinx-extension that uses Clang to directly parse C code
for automatic documentation of C/C++ code, similar to what Doxygen does.

However, Doxygen is rather clunky to integrate into the build process,
so let's start switching over to Hawkmoth instead.

As Sphinx does not have syntax for describing parameter direction, add
an rst_prolog with rst replacements for them.

Reviewed-by: Jani Nikula <jani@nikula.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24507>
This commit is contained in:
Erik Faye-Lund
2023-05-20 12:50:03 +02:00
committed by Marge Bot
parent 0ed5b8af01
commit 67485efd65
2 changed files with 24 additions and 2 deletions

View File

@@ -21,6 +21,8 @@
import os
import sys
from hawkmoth.util import compiler
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -40,6 +42,7 @@ extensions = [
'bootstrap',
'breathe',
'formatting',
'hawkmoth',
'nir',
'redirects',
'sphinx.ext.graphviz',
@@ -214,6 +217,25 @@ texinfo_documents = [
graphviz_output_format = 'svg'
# -- Options for hawkmoth -------------------------------------------------
hawkmoth_root = os.path.abspath('..')
hawkmoth_clang = [
'-Iinclude/',
'-Isrc/',
'-DHAVE_STRUCT_TIMESPEC',
'-DHAVE_PTHREAD',
'-DHAVE_ENDIAN_H',
]
hawkmoth_clang.extend(compiler.get_include_args())
# helpers for definining parameter direction
rst_prolog = '''
.. |in| replace:: **[in]**
.. |out| replace:: **[out]**
.. |inout| replace:: **[inout]**
'''
# -- Options for breathe --------------------------------------------------
breathe_projects = {
'mesa' : 'doxygen_xml',