From 831750b40b67ed07b7473d17531f70fb23b4e9b5 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 14 Jun 2021 16:55:21 -0500 Subject: [PATCH] docs: Begin documenting ISL This commit mostly just adds the framework required to scrape documentation out of the ISL sources and headers. The method chosen here is a combination of doxygen and breathe (a sphinx extension for doxygen integration). I'll freely admit that doxygen is pretty terrible but it seems like the best option we have available to us today. Acked-by: Emma Anholt Acked-by: Daniel Stone Acked-by: Erik Faye-Lund . Part-of: --- .gitlab-ci.yml | 5 ++- docs/conf.py | 10 ++++- docs/doxygen-wrapper.py | 92 +++++++++++++++++++++++++++++++++++++++++ docs/index.rst | 1 + docs/isl/index.rst | 12 ++++++ 5 files changed, 117 insertions(+), 3 deletions(-) create mode 100755 docs/doxygen-wrapper.py create mode 100644 docs/isl/index.rst diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb4b85ab051..20d028be71a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -97,8 +97,9 @@ stages: - .fdo.ci-fairy - .ci-run-policy script: - - apk --no-cache add graphviz - - pip3 install "sphinx<4.0" sphinx_rtd_theme + - apk --no-cache add graphviz doxygen + - pip3 install "sphinx<4.0" breathe mako sphinx_rtd_theme + - docs/doxygen-wrapper.py --out-dir=docs/doxygen_xml - sphinx-build -W -b html docs public pages: diff --git a/docs/conf.py b/docs/conf.py index 3938638092d..079016cdd35 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ sys.path.append(os.path.abspath('_exts')) # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.graphviz', 'formatting', 'redirects'] +extensions = ['sphinx.ext.graphviz', 'breathe', 'formatting', 'redirects'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -212,3 +212,11 @@ texinfo_documents = [ # -- Options for Graphviz ------------------------------------------------- graphviz_output_format = 'svg' + +# -- Options for breathe -------------------------------------------------- +breathe_projects = { + 'mesa' : 'doxygen_xml', +} +breathe_default_project = 'mesa' +breathe_show_define_initializer = True +breathe_show_enumvalue_initializer = True diff --git a/docs/doxygen-wrapper.py b/docs/doxygen-wrapper.py new file mode 100755 index 00000000000..49735b3504c --- /dev/null +++ b/docs/doxygen-wrapper.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +# +# Copyright © 2021 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import argparse +from mako.template import Template +import os +import subprocess +import tempfile + +INPUT_PATHS = [ + 'src/intel/isl', +] + +TEMPLATE_DOXYFILE = Template(""" +# Doxyfile 1.9.1 +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "Mesa" + +INPUT = ${' '.join(input_files)} +XML_OUTPUT = ${output_xml} + +# Only generate XML +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES + +# Add aliases for easily writing reStructuredText in comments +ALIASES = "rst=\\verbatim embed:rst:leading-asterisk" +ALIASES += "endrst=\endverbatim" + +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES + +# Defines required to keep doxygen from tripping on our attribute macros +PREDEFINED = PACKED= +PREDEFINED += ATTRIBUTE_CONST= +""") + +def run_doxygen(output_path, input_paths=[]): + doxyfile = tempfile.NamedTemporaryFile(mode='w', delete=False) + try: + doxyfile.write(TEMPLATE_DOXYFILE.render( + input_files=[ os.path.abspath(i) for i in input_paths ], + output_xml=os.path.abspath(output_path), + )) + doxyfile.close() + + subprocess.run(['doxygen', doxyfile.name]) + + finally: + doxyfile.close() + os.unlink(doxyfile.name) + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('--out-dir', + help='Output XML directory.', + required=True) + args = parser.parse_args() + + this_dir = os.path.dirname(os.path.abspath(__file__)) + mesa_dir = os.path.join(this_dir, '..') + def fixpath(p): + if os.path.isabs(p): + return p + return os.path.join(mesa_dir, p) + + input_paths = [ fixpath(p) for p in INPUT_PATHS ] + + run_doxygen(args.out_dir, input_paths) diff --git a/docs/index.rst b/docs/index.rst index c735b994e1d..cbb5d6f8879 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -111,6 +111,7 @@ Linux, FreeBSD, and other operating systems. release-calendar dispatch gallium/index + isl/index android macos Linux Kernel Drivers diff --git a/docs/isl/index.rst b/docs/isl/index.rst new file mode 100644 index 00000000000..a8d2a517b6c --- /dev/null +++ b/docs/isl/index.rst @@ -0,0 +1,12 @@ +Intel Surface Layout (ISL) +========================== + +The Intel Surface Layout library (**ISL**) is a subproject in Mesa for doing +surface layout calculations for Intel graphics drivers. It was originally +written by Chad Versace and is now maintained by Jason Ekstrand and Nanley +Chery. + +The core representation of a surface in ISL is :cpp:struct:`isl_surf`. + +.. doxygenstruct:: isl_surf + :members: