Skip to content
Snippets Groups Projects
conf.py 8.63 KiB
Newer Older
André Anjos's avatar
André Anjos committed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
André Anjos's avatar
André Anjos committed

import os
Samuel GAIST's avatar
Samuel GAIST committed
import time

André Anjos's avatar
André Anjos committed
import pkg_resources

Samuel GAIST's avatar
Samuel GAIST committed
# For inter-documentation mapping:
from bob.extension.utils import link_documentation
from bob.extension.utils import load_requirements

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
import sphinx_rtd_theme

André Anjos's avatar
André Anjos committed
# -- General configuration -----------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Samuel GAIST's avatar
Samuel GAIST committed
needs_sphinx = "1.3"
André Anjos's avatar
André Anjos committed

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
Samuel GAIST's avatar
Samuel GAIST committed
    "sphinx.ext.todo",
    "sphinx.ext.coverage",
    "sphinx.ext.ifconfig",
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.doctest",
    "sphinx.ext.graphviz",
    "sphinx.ext.intersphinx",
    "sphinx.ext.napoleon",
    "sphinx.ext.viewcode",
    "sphinx.ext.mathjax",
]
André Anjos's avatar
André Anjos committed


# Ignores stuff we can't easily resolve on other project's sphinx manuals
nitpick_ignore = []

# Allows the user to override warnings from a separate file
Samuel GAIST's avatar
Samuel GAIST committed
if os.path.exists("nitpick-exceptions.txt"):
    for line in open("nitpick-exceptions.txt"):
        if line.strip() == "" or line.startswith("#"):
            continue
        dtype, target = line.split(None, 1)
        target = target.strip()
Samuel GAIST's avatar
Samuel GAIST committed
        try:  # python 2.x
            target = unicode(target)
        except NameError:
            pass
        nitpick_ignore.append((dtype, target))

André Anjos's avatar
André Anjos committed
# Always includes todos
todo_include_todos = True

# Generates auto-summary automatically
autosummary_generate = True

# Create numbers on figures with captions
numfig = True

André Anjos's avatar
André Anjos committed
# If we are on OSX, the 'dvipng' path maybe different
Samuel GAIST's avatar
Samuel GAIST committed
dvipng_osx = "/Library/TeX/texbin/dvipng"
if os.path.exists(dvipng_osx):
    pngmath_dvipng = dvipng_osx
André Anjos's avatar
André Anjos committed

# Add any paths that contain templates here, relative to this directory.
Samuel GAIST's avatar
Samuel GAIST committed
templates_path = ["_templates"]
André Anjos's avatar
André Anjos committed

# The suffix of source filenames.
Samuel GAIST's avatar
Samuel GAIST committed
source_suffix = ".rst"
André Anjos's avatar
André Anjos committed

# The encoding of source files.
Samuel GAIST's avatar
Samuel GAIST committed
# source_encoding = 'utf-8-sig'
André Anjos's avatar
André Anjos committed

# The master toctree document.
Samuel GAIST's avatar
Samuel GAIST committed
master_doc = "index"
André Anjos's avatar
André Anjos committed

# General information about the project.
Samuel GAIST's avatar
Samuel GAIST committed
project = u"beat.backend.python"
copyright = u"%s, Idiap Research Institute" % time.strftime("%Y")
André Anjos's avatar
André Anjos committed

# Grab the setup entry
distribution = pkg_resources.require(project)[0]

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = distribution.version
# The full version, including alpha/beta/rc tags.
release = distribution.version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Samuel GAIST's avatar
Samuel GAIST committed
# language = None
André Anjos's avatar
André Anjos committed

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Samuel GAIST's avatar
Samuel GAIST committed
# today = ''
André Anjos's avatar
André Anjos committed
# Else, today_fmt is used as the format for a strftime call.
Samuel GAIST's avatar
Samuel GAIST committed
# today_fmt = '%B %d, %Y'
André Anjos's avatar
André Anjos committed

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Samuel GAIST's avatar
Samuel GAIST committed
exclude_patterns = ["links.rst"]
André Anjos's avatar
André Anjos committed

# The reST default role (used for this markup: `text`) to use for all documents.
Samuel GAIST's avatar
Samuel GAIST committed
# default_role = None
André Anjos's avatar
André Anjos committed

# If true, '()' will be appended to :func: etc. cross-reference text.
Samuel GAIST's avatar
Samuel GAIST committed
# add_function_parentheses = True
André Anjos's avatar
André Anjos committed

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
Samuel GAIST's avatar
Samuel GAIST committed
# add_module_names = True
André Anjos's avatar
André Anjos committed

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
Samuel GAIST's avatar
Samuel GAIST committed
# show_authors = False
André Anjos's avatar
André Anjos committed

# The name of the Pygments (syntax highlighting) style to use.
Samuel GAIST's avatar
Samuel GAIST committed
pygments_style = "sphinx"
André Anjos's avatar
André Anjos committed

# A list of ignored prefixes for module index sorting.
Samuel GAIST's avatar
Samuel GAIST committed
# modindex_common_prefix = []
André Anjos's avatar
André Anjos committed

# Some variables which are useful for generated material
Samuel GAIST's avatar
Samuel GAIST committed
project_variable = project.replace(".", "_")
short_description = u"BEAT Platform (Python backend)"
owner = [u"Idiap Research Institute"]
André Anjos's avatar
André Anjos committed


# -- Options for HTML output ---------------------------------------------------

Samuel GAIST's avatar
Samuel GAIST committed
html_theme = "sphinx_rtd_theme"
André Anjos's avatar
André Anjos committed

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
Samuel GAIST's avatar
Samuel GAIST committed
# html_theme_options = {}
André Anjos's avatar
André Anjos committed

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# The name for this set of Sphinx documents.  If None, it defaults to
# "<project> v<release> documentation".
Samuel GAIST's avatar
Samuel GAIST committed
# html_title = None
André Anjos's avatar
André Anjos committed

# A shorter title for the navigation bar.  Default is the same as html_title.
Samuel GAIST's avatar
Samuel GAIST committed
# html_short_title = project_variable
André Anjos's avatar
André Anjos committed

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
Samuel GAIST's avatar
Samuel GAIST committed
html_logo = "img/logo.png"
André Anjos's avatar
André Anjos committed

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
Samuel GAIST's avatar
Samuel GAIST committed
html_favicon = "img/favicon.ico"
André Anjos's avatar
André Anjos committed

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Samuel GAIST's avatar
Samuel GAIST committed
# html_static_path = ['_static']
André Anjos's avatar
André Anjos committed

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Samuel GAIST's avatar
Samuel GAIST committed
# html_last_updated_fmt = '%b %d, %Y'
André Anjos's avatar
André Anjos committed

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
Samuel GAIST's avatar
Samuel GAIST committed
# html_use_smartypants = True
André Anjos's avatar
André Anjos committed

# Custom sidebar templates, maps document names to template names.
Samuel GAIST's avatar
Samuel GAIST committed
# html_sidebars = {}
André Anjos's avatar
André Anjos committed

# Additional templates that should be rendered to pages, maps page names to
# template names.
Samuel GAIST's avatar
Samuel GAIST committed
# html_additional_pages = {}
André Anjos's avatar
André Anjos committed

# If false, no module index is generated.
Samuel GAIST's avatar
Samuel GAIST committed
# html_domain_indices = True
André Anjos's avatar
André Anjos committed

# If false, no index is generated.
Samuel GAIST's avatar
Samuel GAIST committed
# html_use_index = True
André Anjos's avatar
André Anjos committed

# If true, the index is split into individual pages for each letter.
Samuel GAIST's avatar
Samuel GAIST committed
# html_split_index = False
André Anjos's avatar
André Anjos committed

# If true, links to the reST sources are added to the pages.
Samuel GAIST's avatar
Samuel GAIST committed
# html_show_sourcelink = True
André Anjos's avatar
André Anjos committed

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
Samuel GAIST's avatar
Samuel GAIST committed
# html_show_sphinx = True
André Anjos's avatar
André Anjos committed

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
Samuel GAIST's avatar
Samuel GAIST committed
# html_show_copyright = True
André Anjos's avatar
André Anjos committed

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
Samuel GAIST's avatar
Samuel GAIST committed
# html_use_opensearch = ''
André Anjos's avatar
André Anjos committed

# This is the file name suffix for HTML files (e.g. ".xhtml").
Samuel GAIST's avatar
Samuel GAIST committed
# html_file_suffix = None
André Anjos's avatar
André Anjos committed

# Output file base name for HTML help builder.
Samuel GAIST's avatar
Samuel GAIST committed
htmlhelp_basename = project_variable + u"_doc"
# -- Post configuration --------------------------------------------------------
André Anjos's avatar
André Anjos committed

# Included after all input documents
rst_epilog = """
.. |project| replace:: BEAT
André Anjos's avatar
André Anjos committed
.. |version| replace:: %s
.. |current-year| date:: %%Y
Samuel GAIST's avatar
Samuel GAIST committed
""" % (
    version,
)
André Anjos's avatar
André Anjos committed

# Default processing flags for sphinx
Samuel GAIST's avatar
Samuel GAIST committed
autoclass_content = "class"
autodoc_member_order = "bysource"
André Anjos's avatar
André Anjos committed
autodoc_default_flags = [
Samuel GAIST's avatar
Samuel GAIST committed
    "members",
    "undoc-members",
    "show-inheritance",
]

if "BOB_DOCUMENTATION_SERVER" not in os.environ:
    # notice we need to overwrite this for BEAT projects - defaults from Bob are
    # not OK
    os.environ[
        "BOB_DOCUMENTATION_SERVER"
    ] = "https://www.idiap.ch/software/beat/docs/beat/%(name)s/%(version)s/|https://www.idiap.ch/software/beat/docs/beat/%(name)s/master/"
André Anjos's avatar
André Anjos committed

sphinx_requirements = "extra-intersphinx.txt"
if os.path.exists(sphinx_requirements):
Samuel GAIST's avatar
Samuel GAIST committed
    intersphinx_mapping = link_documentation(
        additional_packages=["python", "numpy"] + load_requirements(sphinx_requirements)
    )
Samuel GAIST's avatar
Samuel GAIST committed
    intersphinx_mapping = link_documentation()
# Adds simplejson, pyzmq links
Samuel GAIST's avatar
Samuel GAIST committed
intersphinx_mapping["http://simplejson.readthedocs.io/en/stable/"] = None
intersphinx_mapping["http://pyzmq.readthedocs.io/en/stable/"] = None

# We want to remove all private (i.e. _. or __.__) members
# that are not in the list of accepted functions
Samuel GAIST's avatar
Samuel GAIST committed
accepted_private_functions = ["__array__"]


def member_function_test(app, what, name, obj, skip, options):
Samuel GAIST's avatar
Samuel GAIST committed
    # test if we have a private function
    if len(name) > 1 and name[0] == "_":
        # test if this private function should be allowed
        if name not in accepted_private_functions:
            # omit private functions that are not in the list of accepted private
            # functions
            return skip
        else:
            # test if the method is documented
            if not hasattr(obj, "__doc__") or not obj.__doc__:
                return skip
    return False

André Anjos's avatar
André Anjos committed

def setup(app):
Samuel GAIST's avatar
Samuel GAIST committed
    app.connect("autodoc-skip-member", member_function_test)