Replace tpo git repository URL by gitlab
[stem.git] / docs / conf.py
blobfeaac0136af31324bb14f9491dd818b575443422
1 # -*- coding: utf-8 -*-
3 # Stem documentation build configuration file, created by
4 # sphinx-quickstart on Thu May 31 09:56:13 2012.
6 # This file is execfile()d with the current directory set to its containing dir.
8 # Note that not all possible configuration values are present in this
9 # autogenerated file.
11 # All configuration values have a default; values that are commented out
12 # serve to show the default.
14 import os
15 import sys
16 import warnings
18 from sphinx.domains.python import PythonDomain
20 TYPEHINTS_REQUIRED = """\
21 Building Stem's website requires...
23 https://github.com/agronholm/sphinx-autodoc-typehints
25 Please run...
27 % pip install sphinx-autodoc-typehints
28 """
30 try:
31 import sphinx_autodoc_typehints
32 except ImportError:
33 print(TYPEHINTS_REQUIRED, file = sys.stderr)
34 sys.exit(1)
36 # These warnings are due to: https://github.com/agronholm/sphinx-autodoc-typehints/issues/133
38 warnings.filterwarnings('ignore', message = 'sphinx.util.inspect.Signature\(\) is deprecated')
40 # Drop redundant return types because we state this in our :returns: clasuses.
41 # This is an argument for sphinx-autodoc-typehints.
43 typehints_document_rtype = False
45 # If extensions (or modules to document with autodoc) are in another directory,
46 # add these directories to sys.path here. If the directory is relative to the
47 # documentation root, use os.path.abspath to make it absolute, like shown here.
49 sys.path.insert(0, os.path.abspath('..'))
50 sys.path.append(os.path.abspath('.'))
51 # -- General configuration -----------------------------------------------------
53 # If your documentation needs a minimal Sphinx version, state it here.
54 needs_sphinx = '1.3' # required for the caption option
56 # Add any Sphinx extension module names here, as strings. They can be extensions
57 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
58 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx_autodoc_typehints', 'roles']
60 autodoc_default_options = {
61 'members': True,
62 'member-order': 'bysource',
63 'show-inheritance': True,
64 'undoc-members': True,
66 # Without this Sphinx emits several warnings of the form...
68 # WARNING: missing attribute mentioned in :members: or __all__: module stem, attribute directory
70 # This is because Sphinx expects modules from importlib.import_module() to
71 # have attributes for its submodules. These attributes might or might not be
72 # present depending on what other modules have been imported.
74 # Said another way...
76 # % print(importlib.import_module('stem').__dict__.keys())
77 # dict_keys(['__name__', '__doc__', '__package__', ...]) <= doesn't have submodules
79 # But if instead we call...
81 # % importlib.import_module('stem.connection')
82 # % print(importlib.import_module('stem').__dict__.keys())
83 # dict_keys(['__name__', '__doc__', '__package__', ..., 'descriptor', 'control', 'connection']) <= includes submodules refernced by stem.connection
85 # By telling it to ignore our '__all__' attributes Sphinx will import in a
86 # fashon that doesn't emit these warnings.
88 'ignore-module-all': True,
91 # Add any paths that contain templates here, relative to this directory.
92 templates_path = ['_templates']
94 # The suffix of source filenames.
95 source_suffix = '.rst'
97 # The encoding of source files.
98 #source_encoding = 'utf-8-sig'
100 # The master toctree document.
101 master_doc = 'index'
103 from stem import __version__, __author__, __contact__
105 # Ignore the '-dev' version suffix.
107 if __version__.endswith('-dev'):
108 __version__ = __version__[:-4]
110 # General information about the project.
111 project = 'Stem'
112 copyright = '2012, %s' % __author__
114 # The version info for the project you're documenting, acts as replacement for
115 # |version| and |release|, also used in various other places throughout the
116 # built documents.
118 # The short X.Y version.
119 version = __version__[:__version__.rfind(".")]
120 # The full version, including alpha/beta/rc tags.
121 release = __version__
123 # The language for content autogenerated by Sphinx. Refer to documentation
124 # for a list of supported languages.
125 #language = None
127 # There are two options for replacing |today|: either, you set today to some
128 # non-false value, then it is used:
129 #today = ''
130 # Else, today_fmt is used as the format for a strftime call.
131 #today_fmt = '%B %d, %Y'
133 # List of patterns, relative to source directory, that match files and
134 # directories to ignore when looking for source files.
135 exclude_patterns = ['_build']
137 # The reST default role (used for this markup: `text`) to use for all documents.
138 #default_role = None
140 # If true, '()' will be appended to :func: etc. cross-reference text.
141 #add_function_parentheses = True
143 # If true, the current module name will be prepended to all description
144 # unit titles (such as .. function::).
145 #add_module_names = True
147 # If true, sectionauthor and moduleauthor directives will be shown in the
148 # output. They are ignored by default.
149 #show_authors = False
151 # The name of the Pygments (syntax highlighting) style to use.
152 pygments_style = 'sphinx'
154 # A list of ignored prefixes for module index sorting.
155 #modindex_common_prefix = []
158 # -- Options for HTML output ---------------------------------------------------
160 # The theme to use for HTML and HTML Help pages. See the documentation for
161 # a list of builtin themes.
162 #html_theme = 'default'
163 html_theme = 'haiku'
165 # Theme options are theme-specific and customize the look and feel of a theme
166 # further. For a list of options available for each theme, see the
167 # documentation.
168 #html_theme_options = {}
170 # Add any paths that contain custom themes here, relative to this directory.
171 #html_theme_path = []
173 # The name for this set of Sphinx documents. If None, it defaults to
174 # "<project> v<release> documentation".
175 #html_title = None
177 # A shorter title for the navigation bar. Default is the same as html_title.
178 html_short_title = 'Stem Docs'
180 # The name of an image file (relative to this directory) to place at the top
181 # of the sidebar.
183 html_logo = '_static/logo.png'
185 # The name of an image file (within the static path) to use as favicon of the
186 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
187 # pixels large.
189 html_favicon = '_static/favicon.png'
191 # Add any paths that contain custom static files (such as style sheets) here,
192 # relative to this directory. They are copied after the builtin static files,
193 # so a file named "default.css" will overwrite the builtin "default.css".
194 html_static_path = ['_static']
196 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
197 # using the given strftime format.
198 #html_last_updated_fmt = '%b %d, %Y'
200 # If true, SmartyPants will be used to convert quotes and dashes to
201 # typographically correct entities.
202 smartquotes = False
204 # Custom sidebar templates, maps document names to template names.
205 #html_sidebars = {}
207 # Additional templates that should be rendered to pages, maps page names to
208 # template names.
209 #html_additional_pages = {}
211 # If false, no module index is generated.
212 #html_domain_indices = True
214 # If false, no index is generated.
215 #html_use_index = True
217 # If true, the index is split into individual pages for each letter.
218 #html_split_index = False
220 # If true, links to the reST sources are added to the pages.
221 html_show_sourcelink = False
223 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
224 html_show_sphinx = False
226 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
227 html_show_copyright = False
229 # If true, an OpenSearch description file will be output, and all pages will
230 # contain a <link> tag referring to it. The value of this option must be the
231 # base URL from which the finished HTML is served.
232 #html_use_opensearch = ''
234 # This is the file name suffix for HTML files (e.g. ".xhtml").
235 #html_file_suffix = None
237 # Output file base name for HTML help builder.
238 htmlhelp_basename = 'Stemdoc'
241 # -- Options for LaTeX output --------------------------------------------------
243 # The paper size ('letter' or 'a4').
244 #latex_paper_size = 'letter'
246 # The font size ('10pt', '11pt' or '12pt').
247 #latex_font_size = '10pt'
249 # Grouping the document tree into LaTeX files. List of tuples
250 # (source start file, target name, title, author, documentclass [howto/manual]).
251 latex_documents = [
252 ('index', 'Stem.tex', 'Stem Documentation',
253 'Damian Johnson', 'manual'),
256 # The name of an image file (relative to this directory) to place at the top of
257 # the title page.
258 #latex_logo = None
260 # For "manual" documents, if this is true, then toplevel headings are parts,
261 # not chapters.
262 #latex_use_parts = False
264 # If true, show page references after internal links.
265 #latex_show_pagerefs = False
267 # If true, show URL addresses after external links.
268 #latex_show_urls = False
270 # Additional stuff for the LaTeX preamble.
271 #latex_preamble = ''
273 # Documents to append as an appendix to all manuals.
274 #latex_appendices = []
276 # If false, no module index is generated.
277 #latex_domain_indices = True
280 # -- Options for manual page output --------------------------------------------
282 # One entry per manual page. List of tuples
283 # (source start file, name, description, authors, manual section).
284 man_pages = [
285 ('index', 'stem', 'Stem Documentation',
286 ['%s (%s)' % (__author__, __contact__)], 1)
290 def skip_members(app, what, name, obj, skip, options):
291 if name in ('ATTRIBUTES', 'PARSER_FOR_LINE'):
292 return True # skip the descriptor's parser constants
295 class PythonDomainNoXref(PythonDomain):
297 Sphinx attempts to create cross-reference links for variable names...
299 https://github.com/sphinx-doc/sphinx/issues/2549
300 https://github.com/sphinx-doc/sphinx/issues/3866
302 This causes alot of warnings such as...
304 stem/descriptor/networkstatus.py:docstring of
305 stem.descriptor.networkstatus.DocumentDigest:: WARNING: more than one
306 target found for cross-reference 'digest':
307 stem.descriptor.extrainfo_descriptor.ExtraInfoDescriptor.digest, ...
310 def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
311 if 'refspecific' in node:
312 del node['refspecific']
314 return super(PythonDomainNoXref, self).resolve_xref(
315 env, fromdocname, builder, typ, target, node, contnode)
318 def setup(app):
319 app.connect('autodoc-skip-member', skip_members)
320 app.add_domain(PythonDomainNoXref, override = True)