Skip to content
Myr

conf.py

This file

Path

docs/conf.py

175 lines · 5.0 KiB · Python

Last changed by

fix docs index sidebarDavid Lordbefore adoption8ceff65

History of this file

Take it

1# -*- coding: utf-8 -*-2from __future__ import print_function34import inspect5import re67from pallets_sphinx_themes import DocVersion, ProjectLink, get_version89# Project --------------------------------------------------------------1011project = 'Flask'12copyright = '2010 Pallets Team'13author = 'Pallets Team'14release, version = get_version('Flask')1516# General --------------------------------------------------------------1718master_doc = 'index'1920extensions = [21    'sphinx.ext.autodoc',22    'sphinx.ext.intersphinx',23    'sphinxcontrib.log_cabinet',24]2526intersphinx_mapping = {27    'python': ('https://docs.python.org/3/', None),28    'werkzeug': ('http://werkzeug.pocoo.org/docs/', None),29    'click': ('http://click.pocoo.org/', None),30    'jinja': ('http://jinja.pocoo.org/docs/', None),31    'itsdangerous': ('https://pythonhosted.org/itsdangerous', None),32    'sqlalchemy': ('https://docs.sqlalchemy.org/en/latest/', None),33    'wtforms': ('https://wtforms.readthedocs.io/en/latest/', None),34    'blinker': ('https://pythonhosted.org/blinker/', None),35}3637# HTML -----------------------------------------------------------------3839html_theme = 'flask'40html_context = {41    'project_links': [42        ProjectLink('Donate to Pallets', 'https://psfmember.org/civicrm/contribute/transact?reset=1&id=20'),43        ProjectLink('Flask Website', 'https://palletsprojects.com/p/flask/'),44        ProjectLink('PyPI releases', 'https://pypi.org/project/Flask/'),45        ProjectLink('Source Code', 'https://github.com/pallets/flask/'),46        ProjectLink(47            'Issue Tracker', 'https://github.com/pallets/flask/issues/'),48    ],49    'versions': [50        DocVersion('dev', 'Development', 'unstable'),51        DocVersion('1.0', 'Flask 1.0', 'stable'),52        DocVersion('0.12', 'Flask 0.12'),53    ],54    'canonical_url': 'http://flask.pocoo.org/docs/{}/'.format(version),55    'carbon_ads_args': 'zoneid=1673&serve=C6AILKT&placement=pocooorg',56}57html_sidebars = {58    'index': [59        'project.html',60        'versions.html',61        'carbon_ads.html',62        'searchbox.html',63    ],64    '**': [65        'localtoc.html',66        'relations.html',67        'versions.html',68        'carbon_ads.html',69        'searchbox.html',70    ]71}72html_static_path = ['_static']73html_favicon = '_static/flask-favicon.ico'74html_logo = '_static/flask.png'75html_additional_pages = {76    '404': '404.html',77}78html_show_sourcelink = False7980# LaTeX ----------------------------------------------------------------8182latex_documents = [83    (master_doc, 'Flask.tex', 'Flask Documentation', 'Pallets Team', 'manual'),84]85latex_use_modindex = False86latex_elements = {87    'papersize': 'a4paper',88    'pointsize': '12pt',89    'fontpkg': r'\usepackage{mathpazo}',90    'preamble': r'\usepackage{flaskstyle}',91}92latex_use_parts = True93latex_additional_files = ['flaskstyle.sty', 'logo.pdf']9495# linkcheck ------------------------------------------------------------9697linkcheck_anchors = False9899# Local Extensions -----------------------------------------------------100101def unwrap_decorators():102    import sphinx.util.inspect as inspect103    import functools104105    old_getargspec = inspect.getargspec106    def getargspec(x):107        return old_getargspec(getattr(x, '_original_function', x))108    inspect.getargspec = getargspec109110    old_update_wrapper = functools.update_wrapper111    def update_wrapper(wrapper, wrapped, *a, **kw):112        rv = old_update_wrapper(wrapper, wrapped, *a, **kw)113        rv._original_function = wrapped114        return rv115    functools.update_wrapper = update_wrapper116117118unwrap_decorators()119del unwrap_decorators120121122_internal_mark_re = re.compile(r'^\s*:internal:\s*$(?m)', re.M)123124125def skip_internal(app, what, name, obj, skip, options):126    docstring = inspect.getdoc(obj) or ''127128    if skip or _internal_mark_re.search(docstring) is not None:129        return True130131132def cut_module_meta(app, what, name, obj, options, lines):133    """Remove metadata from autodoc output."""134    if what != 'module':135        return136137    lines[:] = [138        line for line in lines139        if not line.startswith((':copyright:', ':license:'))140    ]141142143def github_link(144    name, rawtext, text, lineno, inliner, options=None, content=None145):146    app = inliner.document.settings.env.app147    release = app.config.release148    base_url = 'https://github.com/pallets/flask/tree/'149150    if text.endswith('>'):151        words, text = text[:-1].rsplit('<', 1)152        words = words.strip()153    else:154        words = None155156    if release.endswith('dev'):157        url = '{0}master/{1}'.format(base_url, text)158    else:159        url = '{0}{1}/{2}'.format(base_url, release, text)160161    if words is None:162        words = url163164    from docutils.nodes import reference165    from docutils.parsers.rst.roles import set_classes166    options = options or {}167    set_classes(options)168    node = reference(rawtext, words, refuri=url, **options)169    return [node], []170171172def setup(app):173    app.connect('autodoc-skip-member', skip_internal)174    app.connect('autodoc-process-docstring', cut_module_meta)175    app.add_role('gh', github_link)