conf.py 8.27 KB
Newer Older
1
# -*- coding: utf-8 -*-
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os, subprocess
import shlex
import recommonmark
import sphinx_gallery
from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
44 45
sys.path.insert(0, os.path.join(curr_path, '../python/'))
sys.path.insert(0, os.path.join(curr_path, '../topi/python'))
tqchen committed
46
sys.path.insert(0, os.path.join(curr_path, '../nnvm/python'))
47
sys.path.insert(0, os.path.join(curr_path, '../vta/python'))
48 49 50 51 52 53

# -- General configuration ------------------------------------------------

# General information about the project.
project = u'tvm'
author = u'%s developers' % project
54
copyright = u'2018, %s' % author
55 56 57 58 59 60 61 62
github_doc_root = 'https://github.com/tqchen/tvm/tree/master/docs/'

# add markdown parser
CommonMarkParser.github_doc_root = github_doc_root
source_parsers = {
    '.md': CommonMarkParser
}
os.environ['TVM_BUILD_DOC'] = '1'
tqchen committed
63
os.environ['NNVM_BUILD_DOC'] = '1'
64 65 66 67 68 69 70 71 72 73
# Version information.
import tvm
version = tvm.__version__
release = tvm.__version__

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
74
    'sphinx.ext.intersphinx',
75 76 77 78 79
    'sphinx.ext.napoleon',
    'sphinx.ext.mathjax',
    'sphinx_gallery.gen_gallery',
]

80 81 82
breathe_projects = {'tvm' : 'doxygen/xml/'}
breathe_default_project = 'tvm'

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst', '.md']

# The encoding of source files.
#source_encoding = 'utf-8-sig'

# generate autosummary even if no references
autosummary_generate = True

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

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

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']

# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

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

# The theme is set by the make target
html_theme = os.environ.get('TVM_THEME', 'rtd')

on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
# only import rtd theme and set it if want to build docs locally
if not on_rtd and html_theme == 'rtd':
    import sphinx_rtd_theme
    html_theme = 'sphinx_rtd_theme'
    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# 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".
159
html_static_path = ['_static']
160

161 162 163 164 165 166 167 168
html_theme_options = {
    'analytics_id': 'UA-75982049-2',
    'logo_only': True,
}

html_logo = "_static/img/tvm-logo-small.png"


169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'

# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
  (master_doc, '%s.tex' % project, project,
   author, 'manual'),
]

# hook for doxygen
def run_doxygen(folder):
    """Run the doxygen make command in the designated folder."""
    try:
188 189 190 191
        #retcode = subprocess.call("cd %s; make doc" % folder, shell=True)
        retcode = subprocess.call("rm -rf _build/html/doxygen", shell=True)
        retcode = subprocess.call("mkdir -p _build/html", shell=True)
        retcode = subprocess.call("cp -rf doxygen/html _build/html/doxygen", shell=True)
192 193 194 195 196
        if retcode < 0:
            sys.stderr.write("doxygen terminated by signal %s" % (-retcode))
    except OSError as e:
        sys.stderr.write("doxygen execution failed: %s" % e)

197 198 199 200 201 202 203
intersphinx_mapping = {
    'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None),
    'numpy': ('http://docs.scipy.org/doc/numpy/', None),
    'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
    'matplotlib': ('http://matplotlib.org/', None),
}

204 205
from sphinx_gallery.sorting import ExplicitOrder

206 207 208
examples_dirs = ["../tutorials/", "../vta/tutorials/"]
gallery_dirs = ["tutorials", "vta/tutorials"]

209
subsection_order = ExplicitOrder(
210 211
    ['../tutorials/frontend',
     '../tutorials/language',
212
     '../tutorials/optimize',
213
     '../tutorials/autotvm',
214
     '../tutorials/dev',
215
     '../tutorials/topi',
216
     '../tutorials/deployment'])
217 218 219

def generate_doxygen_xml(app):
    """Run the doxygen make commands if we're on the ReadTheDocs server"""
220
    run_doxygen('..')
221 222 223 224

def setup(app):
    # Add hook for building doxygen xml when needed
    # no c++ API for now
225 226
    app.connect("builder-inited", generate_doxygen_xml)
    app.add_stylesheet('css/tvm_theme.css')
227
    app.add_config_value('recommonmark_config', {
228 229
        'url_resolver': lambda url: github_doc_root + url,
        'auto_doc_ref': True
230 231 232
            }, True)
    app.add_transform(AutoStructify)

233

234 235
sphinx_gallery_conf = {
    'backreferences_dir': 'gen_modules/backreferences',
236 237 238 239 240
    'doc_module': ('tvm', 'numpy'),
'reference_url': {
    'tvm': None,
    'matplotlib': 'http://matplotlib.org',
    'numpy': 'http://docs.scipy.org/doc/numpy-1.9.1'},
241
    'examples_dirs': examples_dirs,
242
    'gallery_dirs': gallery_dirs,
243
    'subsection_order': subsection_order,
244
    'filename_pattern': os.environ.get("TVM_TUTORIAL_EXEC_PATTERN", ".py"),
245 246
    'find_mayavi_figures': False,
    'expected_failing_examples': []
247
}