|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# documentation build configuration file, created by |
| 4 | +# sphinx-quickstart on Thu Jul 23 19:40:08 2015. |
| 5 | +# |
| 6 | +# This file is execfile()d with the current directory set to its |
| 7 | +# containing dir. |
| 8 | +# |
| 9 | +# Note that not all possible configuration values are present in this |
| 10 | +# autogenerated file. |
| 11 | +# |
| 12 | +# All configuration values have a default; values that are commented out |
| 13 | +# serve to show the default. |
| 14 | +import sys |
| 15 | +import os, subprocess |
| 16 | +import shlex |
| 17 | +import recommonmark |
| 18 | +from recommonmark.parser import CommonMarkParser |
| 19 | +from recommonmark.transform import AutoStructify |
| 20 | + |
| 21 | +# If extensions (or modules to document with autodoc) are in another directory, |
| 22 | +# add these directories to sys.path here. If the directory is relative to the |
| 23 | +# documentation root, use os.path.abspath to make it absolute, like shown here. |
| 24 | +curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) |
| 25 | +sys.path.insert(0, os.path.join(curr_path, '../python/')) |
| 26 | + |
| 27 | +# -- General configuration ------------------------------------------------ |
| 28 | + |
| 29 | +# General information about the project. |
| 30 | +project = u'nnvm' |
| 31 | +author = u'%s developers' % project |
| 32 | +copyright = u'2017, %s' % author |
| 33 | +github_doc_root = 'https://github.com/dmlc/nnvm/tree/master/docs/' |
| 34 | + |
| 35 | +# add markdown parser |
| 36 | +CommonMarkParser.github_doc_root = github_doc_root |
| 37 | +source_parsers = { |
| 38 | + '.md': CommonMarkParser |
| 39 | +} |
| 40 | +os.environ['NNVM_BUILD_DOC'] = '1' |
| 41 | +# Version information. |
| 42 | +import nnvm |
| 43 | +version = nnvm.__version__ |
| 44 | +release = nnvm.__version__ |
| 45 | + |
| 46 | +# Add any Sphinx extension module names here, as strings. They can be |
| 47 | +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones |
| 48 | +extensions = [ |
| 49 | + 'sphinx.ext.autodoc', |
| 50 | + 'sphinx.ext.autosummary', |
| 51 | + 'sphinx.ext.intersphinx', |
| 52 | + 'sphinx.ext.napoleon', |
| 53 | + 'sphinx.ext.mathjax' |
| 54 | +] |
| 55 | + |
| 56 | +# Add any paths that contain templates here, relative to this directory. |
| 57 | +templates_path = ['_templates'] |
| 58 | + |
| 59 | +# The suffix(es) of source filenames. |
| 60 | +# You can specify multiple suffix as a list of string: |
| 61 | +# source_suffix = ['.rst', '.md'] |
| 62 | +source_suffix = ['.rst', '.md'] |
| 63 | + |
| 64 | +# The encoding of source files. |
| 65 | +#source_encoding = 'utf-8-sig' |
| 66 | + |
| 67 | +# generate autosummary even if no references |
| 68 | +autosummary_generate = True |
| 69 | + |
| 70 | +# The master toctree document. |
| 71 | +master_doc = 'index' |
| 72 | + |
| 73 | +# The language for content autogenerated by Sphinx. Refer to documentation |
| 74 | +# for a list of supported languages. |
| 75 | +# |
| 76 | +# This is also used if you do content translation via gettext catalogs. |
| 77 | +# Usually you set "language" from the command line for these cases. |
| 78 | +language = None |
| 79 | + |
| 80 | +# There are two options for replacing |today|: either, you set today to some |
| 81 | +# non-false value, then it is used: |
| 82 | +#today = '' |
| 83 | +# Else, today_fmt is used as the format for a strftime call. |
| 84 | +#today_fmt = '%B %d, %Y' |
| 85 | + |
| 86 | +# List of patterns, relative to source directory, that match files and |
| 87 | +# directories to ignore when looking for source files. |
| 88 | +exclude_patterns = ['_build'] |
| 89 | + |
| 90 | +# The reST default role (used for this markup: `text`) to use for all |
| 91 | +# documents. |
| 92 | +#default_role = None |
| 93 | + |
| 94 | +# If true, '()' will be appended to :func: etc. cross-reference text. |
| 95 | +#add_function_parentheses = True |
| 96 | + |
| 97 | +# If true, the current module name will be prepended to all description |
| 98 | +# unit titles (such as .. function::). |
| 99 | +#add_module_names = True |
| 100 | + |
| 101 | +# If true, sectionauthor and moduleauthor directives will be shown in the |
| 102 | +# output. They are ignored by default. |
| 103 | +#show_authors = False |
| 104 | + |
| 105 | +# The name of the Pygments (syntax highlighting) style to use. |
| 106 | +pygments_style = 'sphinx' |
| 107 | + |
| 108 | +# A list of ignored prefixes for module index sorting. |
| 109 | +#modindex_common_prefix = [] |
| 110 | + |
| 111 | +# If true, keep warnings as "system message" paragraphs in the built documents. |
| 112 | +#keep_warnings = False |
| 113 | + |
| 114 | +# If true, `todo` and `todoList` produce output, else they produce nothing. |
| 115 | +todo_include_todos = False |
| 116 | + |
| 117 | +# -- Options for HTML output ---------------------------------------------- |
| 118 | + |
| 119 | +# The theme is set by the make target |
| 120 | +html_theme = os.environ.get('NNVM_THEME', 'rtd') |
| 121 | + |
| 122 | +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' |
| 123 | +# only import rtd theme and set it if want to build docs locally |
| 124 | +if not on_rtd and html_theme == 'rtd': |
| 125 | + import sphinx_rtd_theme |
| 126 | + html_theme = 'sphinx_rtd_theme' |
| 127 | + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
| 128 | + |
| 129 | +# Add any paths that contain custom static files (such as style sheets) here, |
| 130 | +# relative to this directory. They are copied after the builtin static files, |
| 131 | +# so a file named "default.css" will overwrite the builtin "default.css". |
| 132 | +html_static_path = ['_static'] |
| 133 | + |
| 134 | +# Output file base name for HTML help builder. |
| 135 | +htmlhelp_basename = project + 'doc' |
| 136 | + |
| 137 | +# -- Options for LaTeX output --------------------------------------------- |
| 138 | +latex_elements = { |
| 139 | +} |
| 140 | + |
| 141 | +# Grouping the document tree into LaTeX files. List of tuples |
| 142 | +# (source start file, target name, title, |
| 143 | +# author, documentclass [howto, manual, or own class]). |
| 144 | +latex_documents = [ |
| 145 | + (master_doc, '%s.tex' % project, project, |
| 146 | + author, 'manual'), |
| 147 | +] |
| 148 | + |
| 149 | +# hook for doxygen |
| 150 | +def run_doxygen(folder): |
| 151 | + """Run the doxygen make command in the designated folder.""" |
| 152 | + try: |
| 153 | + #retcode = subprocess.call("cd %s; make doc" % folder, shell=True) |
| 154 | + retcode = subprocess.call("rm -rf _build/html/doxygen", shell=True) |
| 155 | + retcode = subprocess.call("mkdir -p _build/html", shell=True) |
| 156 | + retcode = subprocess.call("cp -rf doxygen/html _build/html/doxygen", shell=True) |
| 157 | + if retcode < 0: |
| 158 | + sys.stderr.write("doxygen terminated by signal %s" % (-retcode)) |
| 159 | + except OSError as e: |
| 160 | + sys.stderr.write("doxygen execution failed: %s" % e) |
| 161 | + |
| 162 | +intersphinx_mapping = { |
| 163 | + 'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None), |
| 164 | + 'numpy': ('http://docs.scipy.org/doc/numpy/', None), |
| 165 | + 'scipy': ('http://docs.scipy.org/doc/scipy/reference', None), |
| 166 | + 'matplotlib': ('http://matplotlib.org/', None), |
| 167 | +} |
| 168 | + |
| 169 | + |
| 170 | +def generate_doxygen_xml(app): |
| 171 | + """Run the doxygen make commands if we're on the ReadTheDocs server""" |
| 172 | + run_doxygen('..') |
| 173 | + |
| 174 | +def setup(app): |
| 175 | + # Add hook for building doxygen xml when needed |
| 176 | + # no c++ API for now |
| 177 | + app.connect("builder-inited", generate_doxygen_xml) |
| 178 | + app.add_config_value('recommonmark_config', { |
| 179 | + 'url_resolver': lambda url: github_doc_root + url, |
| 180 | + 'auto_doc_ref': True |
| 181 | + }, True) |
| 182 | + app.add_transform(AutoStructify) |
0 commit comments