evennia/docs/source/conf.py

184 lines
4.9 KiB
Python
Raw Normal View History

2020-04-05 00:02:02 +02:00
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import sys
from os.path import sep
2020-04-05 00:02:02 +02:00
from recommonmark.transform import AutoStructify
from sphinx.util.osutil import cd
_no_autodoc = os.environ.get("NOAUTODOC")
if not _no_autodoc:
# we must set up Evennia and its paths for autodocs to work
2020-04-05 00:02:02 +02:00
EV_ROOT = os.environ.get("EVDIR")
GAME_DIR = os.environ.get("EVGAMEDIR")
2020-04-05 00:02:02 +02:00
if not (EV_ROOT and GAME_DIR):
print("The EVDIR and EVGAMEDIR environment variables must be set to "
"the absolute paths to the evennia/ repo and an initialized "
"evennia gamedir respectively.")
raise RuntimeError()
2020-04-05 00:02:02 +02:00
print("Evennia root: {}, Game dir: {}".format(EV_ROOT, GAME_DIR))
2020-04-05 00:02:02 +02:00
sys.path.insert(1, EV_ROOT)
sys.path.insert(1, GAME_DIR)
2020-04-05 00:02:02 +02:00
with cd(GAME_DIR):
# set up Evennia so its sources can be parsed
os.environ["DJANGO_SETTINGS_MODULE"] = "server.conf.settings"
2020-04-05 00:02:02 +02:00
import django # noqa
django.setup()
import evennia # noqa
evennia._init()
2020-04-05 00:02:02 +02:00
# -- Project information -----------------------------------------------------
project = 'Evennia'
copyright = '2020, The Evennia developer community'
author = 'The Evennia developer community'
# The full version, including alpha/beta/rc tags
release = '0.9'
2020-04-05 00:02:02 +02:00
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"recommonmark",
2020-04-05 15:02:38 +02:00
"sphinx_multiversion",
2020-04-05 16:50:52 +02:00
"sphinx.ext.napoleon",
2020-04-07 23:13:24 +02:00
"sphinx.ext.autosectionlabel",
2020-04-10 17:38:26 +02:00
"sphinx.ext.viewcode",
# "sphinxcontrib.lunrsearch",
2020-04-05 00:02:02 +02:00
]
2020-04-05 15:02:38 +02:00
# make sure sectionlabel references can be used as path/to/file:heading
autosectionlabel_prefix_document = True
2020-04-05 00:02:02 +02:00
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
2020-04-09 08:39:55 +02:00
# 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".
html_static_path = ['_static']
# Custom extras for sidebar
html_sidebars = {
'**': [
"searchbox.html",
"localtoc.html",
# "globaltoc.html",
"relations.html",
"sourcelink.html",
"versioning.html",
]
}
2020-04-05 00:02:02 +02:00
2020-04-07 23:13:24 +02:00
# napoleon Google-style docstring parser
2020-04-05 00:02:02 +02:00
2020-04-07 23:13:24 +02:00
napoleon_google_docstring = True
napoleon_numpy_docstring = False
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = False
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_keyword = True
napoleon_use_rtype = True
# settings for sphinxcontrib.apidoc to auto-run sphinx-apidocs
if _no_autodoc:
exclude_patterns = ["api/*"]
else:
exclude_patterns = ["api/*migrations.rst"]
# for inline autodoc
autodoc_default_options = {
"members": True,
"undoc-members": True,
"show-inheritance": True,
"special-members": "__init__",
"enable_eval_rst": True,
2020-04-07 23:13:24 +02:00
}
def autodoc_skip_member(app, what, name, obj, skip, options):
if _no_autodoc:
return True
if name.startswith("__") and name != "__init__":
return True
return False
2020-04-05 16:50:52 +02:00
2020-04-05 00:02:02 +02:00
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# sphinx-multiversion config
2020-04-05 12:34:14 +02:00
smv_tag_whitelist = r"^$"
2020-05-22 00:38:29 +02:00
smv_branch_whitelist = r"^static-file-docs$|^static-file-dev$"
2020-04-05 00:02:02 +02:00
smv_outputdir_format = "versions" + sep + "{config.release}"
2020-04-07 23:13:24 +02:00
# reroute to github links or to the api
2020-04-05 12:32:52 +02:00
_github_code_root = "https://github.com/evennia/evennia/blob/master/"
2020-04-07 23:13:24 +02:00
_github_doc_root = "https://github.com/evennia/tree/master/docs/sources/"
2020-04-05 16:50:52 +02:00
# recommonmark
2020-04-05 21:23:33 +02:00
2020-04-05 16:50:52 +02:00
def url_resolver(url):
urlstart = "code:"
apistart = "api:"
if url.startswith(urlstart):
return _github_code_root + url[len(urlstart):]
elif url.startswith(apistart):
return "api/" + url[len(apistart):] + ".html"
2020-04-05 16:50:52 +02:00
else:
2020-04-07 23:13:24 +02:00
return _github_doc_root + url
2020-04-05 16:50:52 +02:00
2020-04-09 08:39:55 +02:00
auto_toc_sections = ["Contents", "Toc", "Index"]
recommonmark_config = {
"enable_auto_toc_tree": True,
"url_resolver": url_resolver,
"auto_toc_tree_section": ["Contents", "Toc", "Index"],
}
2020-04-05 12:32:52 +02:00
2020-04-05 00:02:02 +02:00
def setup(app):
2020-04-05 16:50:52 +02:00
app.connect("autodoc-skip-member", autodoc_skip_member)
2020-04-05 00:02:02 +02:00
app.add_transform(AutoStructify)
# custom lunr-based search
# from docs import search
# custom search
# search.setup(app)