|
| 1 | +#A part of NonVisual Desktop Access (NVDA) |
| 2 | +#Copyright (C) 2019 NV Access Limited, Leonard de RUijter |
| 3 | +#This file is covered by the GNU General Public License. |
| 4 | +#See the file COPYING for more details. |
| 5 | + |
| 6 | +# Configuration file for the Sphinx documentation builder. |
| 7 | + |
| 8 | +# -- Path setup -------------------------------------------------------------- |
| 9 | + |
| 10 | +import os |
| 11 | +import sys |
| 12 | +sys.path.insert(0, os.path.abspath('../source')) |
| 13 | +import sourceEnv |
| 14 | + |
| 15 | +# Initialize languageHandler so that sphinx is able to deal with translatable strings. |
| 16 | +import languageHandler |
| 17 | +languageHandler.setLanguage("en") |
| 18 | + |
| 19 | +# Initialize globalvars.appArgs to something sensible. |
| 20 | +import globalVars |
| 21 | +class AppArgs: |
| 22 | + # Set an empty comnfig path |
| 23 | + # This is never used as we don't initialize config, but some modules expect this to be set. |
| 24 | + configPath = "" |
| 25 | + secure = False |
| 26 | + disableAddons = True |
| 27 | + launcher = False |
| 28 | +globalVars.appArgs = AppArgs() |
| 29 | + |
| 30 | +# Import NVDA's versionInfo module. |
| 31 | +import versionInfo |
| 32 | +# Set a suitable updateVersionType for the updateCheck module to be imported |
| 33 | +versionInfo.updateVersionType = "stable" |
| 34 | + |
| 35 | +# -- Project information ----------------------------------------------------- |
| 36 | + |
| 37 | +project = versionInfo.name |
| 38 | +copyright = versionInfo.copyright |
| 39 | +author = versionInfo.publisher |
| 40 | + |
| 41 | +# The major project version |
| 42 | +version = versionInfo.formatVersionForGUI(versionInfo.version_year, versionInfo.version_major, versionInfo.version_minor) |
| 43 | + |
| 44 | +# The full version, including alpha/beta/rc tags |
| 45 | +release = versionInfo.version |
| 46 | + |
| 47 | +# -- General configuration --------------------------------------------------- |
| 48 | + |
| 49 | +default_role = 'py:obj' |
| 50 | + |
| 51 | +# Add any Sphinx extension module names here, as strings. They can be |
| 52 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
| 53 | +# ones. |
| 54 | +extensions = [ |
| 55 | + 'sphinx.ext.autodoc', |
| 56 | +] |
| 57 | + |
| 58 | +# Add any paths that contain templates here, relative to this directory. |
| 59 | +templates_path = ['_templates'] |
| 60 | + |
| 61 | +# List of patterns, relative to source directory, that match files and |
| 62 | +# directories to ignore when looking for source files. |
| 63 | +# This pattern also affects html_static_path and html_extra_path. |
| 64 | +exclude_patterns = [ |
| 65 | + "_build" |
| 66 | +] |
| 67 | + |
| 68 | + |
| 69 | +# -- Options for HTML output ------------------------------------------------- |
| 70 | + |
| 71 | +# The theme to use for HTML and HTML Help pages. |
| 72 | + |
| 73 | +html_theme = 'alabaster' |
| 74 | + |
| 75 | +# Add any paths that contain custom static files (such as style sheets) here, |
| 76 | +# relative to this directory. They are copied after the builtin static files, |
| 77 | +# so a file named "default.css" will overwrite the builtin "default.css". |
| 78 | +html_static_path = ['_static'] |
| 79 | + |
| 80 | +# -- Extension configuration ------------------------------------------------- |
| 81 | + |
| 82 | +# sphinx.ext.autodoc configuration |
| 83 | + |
| 84 | +autoclass_content = "both" # Both the class’ and the __init__ method’s docstring are concatenated and inserted. |
| 85 | +autodoc_member_order = 'bysource' |
| 86 | +autodoc_mock_imports = [ |
| 87 | + "config", |
| 88 | + "louis", |
| 89 | +] |
| 90 | + |
| 91 | +# SUpport for auto generation of API docs |
| 92 | +# Based on code published in https://github.com/readthedocs/readthedocs.org/issues/1139#issuecomment-398083449 |
| 93 | + |
| 94 | +def run_apidoc(_): |
| 95 | + ignore_paths = [ |
| 96 | + '_buildVersion.py', |
| 97 | + 'comInterfaces', |
| 98 | + 'images', |
| 99 | + 'lib', |
| 100 | + 'lib64', |
| 101 | + 'libArm64', |
| 102 | + 'locale', |
| 103 | + 'louis', # Not our project |
| 104 | + 'typelibs', |
| 105 | + 'waves', |
| 106 | + "mathType.py", # Fails when not installed |
| 107 | + 'oleTypes.py', # Not our code |
| 108 | + 'setup.py', # Py2exe |
| 109 | + 'sourceEnv.py', # Only available when running from source |
| 110 | + ] |
| 111 | + argv = [ |
| 112 | + "--force", # overwrite existing files |
| 113 | + "-P", # Include private modules |
| 114 | + "--module-first", # put module documentation before submodule documentation |
| 115 | + "--output-dir", ".", |
| 116 | + sys.path[0] # Module sources |
| 117 | + ] + [os.path.join(sys.path[0], path) for path in ignore_paths] |
| 118 | + |
| 119 | + from sphinx.ext import apidoc |
| 120 | + apidoc.main(argv) |
| 121 | + |
| 122 | +def setup(app): |
| 123 | + app.connect('builder-inited', run_apidoc) |
0 commit comments