libjxl

FORK: libjxl patches used on blog
git clone https://git.neptards.moe/blog/libjxl.git
Log | Files | Refs | Submodules | README | LICENSE

conf.py (3219B)


      1 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
      2 #
      3 # Use of this source code is governed by a BSD-style
      4 # license that can be found in the LICENSE file.
      5 
      6 # Configuration file for the Sphinx documentation builder.
      7 #
      8 # See https://www.sphinx-doc.org/en/master/usage/configuration.html
      9 
     10 import os
     11 import re
     12 import subprocess
     13 
     14 def GetVersion():
     15     """Function to get the version of the current code."""
     16     with open(os.path.join(
     17             os.path.dirname(__file__), '../../lib/CMakeLists.txt'), 'r') as f:
     18         cmakevars = {}
     19         for line in f:
     20             m = re.match(r'set\(JPEGXL_([A-Z]+)_VERSION ([^\)]+)\)', line)
     21             if m:
     22                 cmakevars[m.group(1)] = m.group(2)
     23     return '%s.%s.%s' % (cmakevars['MAJOR'], cmakevars['MINOR'], cmakevars['PATCH'])
     24 
     25 def ConfigProject(app, config):
     26     # Configure the doxygen xml directory as the "xml" directory next to the
     27     # sphinx output directory. Doxygen generates by default the xml files in a
     28     # "xml" sub-directory of the OUTPUT_DIRECTORY.
     29     build_dir = os.path.dirname(app.outdir)
     30     xml_dir = os.path.join(build_dir, 'xml')
     31     config.breathe_projects['libjxl'] = xml_dir
     32 
     33     # Read the docs build environment doesn't run our cmake script so instead we
     34     # need to run doxygen manually here.
     35     if os.environ.get('READTHEDOCS', None) != 'True':
     36         return
     37     root_dir = os.path.realpath(os.path.join(app.srcdir, '../../'))
     38     doxyfile = os.path.join(build_dir, 'Doxyfile-rtd.doc')
     39     with open(doxyfile, 'w') as f:
     40         f.write(f"""
     41 FILE_PATTERNS          = *.c *.h
     42 GENERATE_HTML          = NO
     43 GENERATE_LATEX         = NO
     44 GENERATE_XML           = YES
     45 INPUT                  = lib/include doc/api.txt
     46 OUTPUT_DIRECTORY       = {build_dir}
     47 PROJECT_NAME           = LIBJXL
     48 QUIET                  = YES
     49 RECURSIVE              = YES
     50 STRIP_FROM_PATH        = lib/include
     51 WARN_AS_ERROR          = YES
     52 """)
     53     subprocess.check_call(['doxygen', doxyfile], cwd=root_dir)
     54 
     55 def setup(app):
     56     # Generate doxygen XML on init when running from Read the docs.
     57     app.connect("config-inited", ConfigProject)
     58 
     59 ### Project information
     60 
     61 project = 'libjxl'
     62 project_copyright = 'JPEG XL Project Authors'
     63 author = 'JPEG XL Project Authors'
     64 version = GetVersion()
     65 
     66 ### General configuration
     67 
     68 extensions = [
     69     # For integration with doxygen documentation.
     70     'breathe',
     71     # sphinx readthedocs theme.
     72     'sphinx_rtd_theme',
     73     # Do we use it?
     74     'sphinx.ext.graphviz',
     75 ]
     76 
     77 breathe_default_project = 'libjxl'
     78 breathe_projects = {}
     79 
     80 
     81 # All the API is in C, except those files that end with cxx.h.
     82 breathe_domain_by_extension = {'h': 'cpp'}
     83 breathe_domain_by_file_pattern = {
     84     '*cxx.h': 'cpp',
     85 }
     86 breathe_implementation_filename_extensions = ['.cc']
     87 
     88 # These are defined at build time by cmake.
     89 c_id_attributes = [
     90     'JXL_EXPORT',
     91     'JXL_DEPRECATED',
     92     'JXL_THREADS_EXPORT',
     93 ]
     94 cpp_id_attributes = c_id_attributes
     95 
     96 
     97 breathe_projects_source = {
     98     'libjxl' : ('../../', [
     99         'doc/api.txt',
    100         'lib/include/jxl',
    101     ])
    102 }
    103 
    104 # Recognized suffixes.
    105 source_suffix = ['.rst', '.md']
    106 
    107 ### Options for HTML output
    108 
    109 # Use the readthedocs.io theme when generating the HTML output.
    110 html_theme = 'sphinx_rtd_theme'