Debian Codegraph @

docs/source/conf.py

raw
1 # Configuration file for the Sphinx documentation builder.
2 #
3 # This file only contains a selection of the most common options. For a full
4 # list see the documentation:
5 # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
7 # -- Path setup --------------------------------------------------------------
8
9 # If extensions (or modules to document with autodoc) are in another directory,
10 # add these directories to sys.path here. If the directory is relative to the
11 # documentation root, use os.path.abspath to make it absolute, like shown here.
12 #
13 # import os
14 # import sys
15 # sys.path.insert(0, os.path.abspath('.'))
16
17 import os
18 import subprocess
19 import pathlib
20
21
22 # -- Project information -----------------------------------------------------
23
24 project = 'pydoctor'
25 copyright = '2020, Michael Hudson-Doyle and various contributors (see Git history)'
26 author = 'Michael Hudson-Doyle and various contributors (see Git history)'
27
28 from pydoctor import __version__ as version
29
30 # -- General configuration ---------------------------------------------------
31
32 # Add any Sphinx extension module names here, as strings. They can be
33 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34 # ones.
35 extensions = [
36 "sphinx_rtd_theme",
37 "sphinx.ext.intersphinx",
38 "pydoctor.sphinx_ext.build_apidocs",
39 "sphinxcontrib.spelling",
40 "sphinxarg.ext",
41 ]
42
43 # Add any paths that contain templates here, relative to this directory.
44 templates_path = ['_templates']
45
46 # List of patterns, relative to source directory, that match files and
47 # directories to ignore when looking for source files.
48 # This pattern also affects html_static_path and html_extra_path.
49 exclude_patterns = []
50
51 # Definitions that will be made available to every document.
52 rst_epilog = """
53 .. include:: <isonum.txt>
54 """
55
56 # Configure spell checker.
57 spelling_word_list_filename = 'spelling_wordlist.txt'
58
59 # Configure intersphinx magic
60 intersphinx_mapping = {
61 # FIXME: use the official Twisted's docs when they update
62 'twisted': ('https://tristanlatr.github.io/apidocs/twisted/', None),
63 'configargparse': ('https://bw2.github.io/ConfigArgParse/', None),
64 'std': ('https://docs.python.org/3/', None),
65 }
66
67 # -- Options for HTML output -------------------------------------------------
68
69 # The theme to use for HTML and HTML Help pages. See the documentation for
70 # a list of builtin themes.
71 #
72 html_theme = "sphinx_rtd_theme"
73
74 # Add any paths that contain custom static files (such as style sheets) here,
75 # relative to this directory. They are copied after the builtin static files,
76 # so a file named "default.css" will overwrite the builtin "default.css".
77 html_static_path = []
78
79 # Try to find URL fragment for the GitHub source page based on current
80 # branch or tag.
81 _git_reference = subprocess.getoutput('git rev-parse --abbrev-ref HEAD')
82 if _git_reference == 'HEAD':
83 # It looks like the branch has no name.
84 # Fallback to commit ID.
85 _git_reference = subprocess.getoutput('git rev-parse HEAD')
86
87 if os.environ.get('READTHEDOCS', '') == 'True':
88 rtd_version = os.environ.get('READTHEDOCS_VERSION', '')
89 if '.' in rtd_version:
90 # It looks like we have a tag build.
91 _git_reference = rtd_version
92
93 _pydoctor_root = pathlib.Path(__file__).parent.parent.parent
94 _common_args = [
95 f'--html-viewsource-base=https://github.com/twisted/pydoctor/tree/{_git_reference}',
96 f'--project-base-dir={_pydoctor_root}',
97 f'--config={_pydoctor_root}/setup.cfg',
98 ]
99 pydoctor_args = {
100 'main': [
101 '--html-output={outdir}/api/', # Make sure to have a trailing delimiter for better usage coverage.
102 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/api',
103 '--project-name=pydoctor',
104 f'--project-version={version}',
105 '--docformat=epytext',
106 '--privacy=HIDDEN:pydoctor.test',
107 '--project-url=../index.html',
108 f'{_pydoctor_root}/pydoctor',
109 ] + _common_args,
110 'custom_template_demo': [
111 '--html-output={outdir}/custom_template_demo/',
112 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/custom_template_demo',
113 f'--project-version={version}',
114 f'--template-dir={_pydoctor_root}/docs/sample_template',
115 f'{_pydoctor_root}/pydoctor',
116 ] + _common_args +
117 [f'--config={_pydoctor_root}/docs/source/custom_template_demo/pyproject.toml',
118 '-qqq' ], # we don't want to hear any warnings from this custom template demo.
119 'epydoc_demo': [
120 '--html-output={outdir}/docformat/epytext_demo',
121 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/docformat/epytext_demo',
122 '--project-name=pydoctor-epytext-demo',
123 '--project-version=1.3.0',
124 '--docformat=epytext',
125 '--sidebar-toc-depth=3',
126 '--project-url=../epytext.html',
127 '--theme=readthedocs',
128 f'{_pydoctor_root}/docs/epytext_demo',
129 ] + _common_args,
130 'restructuredtext_demo': [
131 '--html-output={outdir}/docformat/restructuredtext_demo',
132 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/docformat/restructuredtext_demo',
133 '--project-name=pydoctor-restructuredtext-demo',
134 '--project-version=1.0.0',
135 '--docformat=restructuredtext',
136 '--sidebar-toc-depth=3',
137 '--project-url=../restructuredtext.html',
138 '--process-types',
139 f'{_pydoctor_root}/docs/restructuredtext_demo',
140 ] + _common_args,
141 'numpy_demo': [ # no need to pass --docformat here, we use __docformat__
142 '--html-output={outdir}/docformat/numpy_demo',
143 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/docformat/numpy_demo',
144 '--project-name=pydoctor-numpy-style-demo',
145 '--project-version=1.0.0',
146 '--project-url=../google-numpy.html',
147 '--theme=readthedocs',
148 f'{_pydoctor_root}/docs/numpy_demo',
149 f'{_pydoctor_root}/pydoctor/napoleon'
150 ] + _common_args,
151 'google_demo': [
152 '--html-output={outdir}/docformat/google_demo',
153 '--html-base-url=https://pydoctor.readthedocs.io/en/latest/docformat/google_demo',
154 '--project-name=pydoctor-google-style-demo',
155 '--project-version=1.0.0',
156 '--docformat=google',
157 '--project-url=../google-numpy.html',
158 '--theme=readthedocs',
159 f'{_pydoctor_root}/docs/google_demo',
160 ] + _common_args,
161 }
162
163 pydoctor_url_path = {
164 'main': '/en/{rtd_version}/api',
165 'epydoc_demo': '/en/{rtd_version}/docformat/epytext/',
166 'restructuredtext_demo': '/en/{rtd_version}/docformat/restructuredtext/',
167 'numpy_demo': '/en/{rtd_version}/docformat/numpy/',
168 'google_demo': '/en/{rtd_version}/docformat/google/',
169 }