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
|
2020-06-14 11:45:10 +02:00
|
|
|
import sphinx_theme
|
2020-04-05 00:02:02 +02:00
|
|
|
from recommonmark.transform import AutoStructify
|
|
|
|
|
from sphinx.util.osutil import cd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Project information -----------------------------------------------------
|
|
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
project = "Evennia"
|
|
|
|
|
copyright = "2020, The Evennia developer community"
|
|
|
|
|
author = "The Evennia developer community"
|
|
|
|
|
|
|
|
|
|
# The full Evennia version covered by these docs, including alpha/beta/rc tags
|
|
|
|
|
# This will be used for multi-version selection options.
|
|
|
|
|
release = "1.0-dev"
|
2020-04-05 00:02:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- General configuration ---------------------------------------------------
|
|
|
|
|
|
|
|
|
|
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",
|
2020-05-23 14:59:12 +02:00
|
|
|
# "sphinxcontrib.lunrsearch",
|
2020-06-14 11:45:10 +02:00
|
|
|
"sphinx.ext.todo",
|
|
|
|
|
"sphinx.ext.githubpages",
|
2020-04-05 00:02:02 +02:00
|
|
|
]
|
|
|
|
|
|
2020-06-16 14:50:02 +02:00
|
|
|
source_suffix = [".md", ".rst"]
|
|
|
|
|
master_doc = "index"
|
2020-06-14 20:19:31 +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.
|
2020-06-14 11:45:10 +02:00
|
|
|
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".
|
2020-06-14 11:45:10 +02:00
|
|
|
html_static_path = ["_static"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Sphinx-multiversion config ----------------------------------------------
|
|
|
|
|
|
|
|
|
|
# which branches to include in multi-versioned docs
|
|
|
|
|
# - master, develop and vX.X branches
|
|
|
|
|
smv_branch_whitelist = r"^master$|^develop$|^v[0-9\.]+?$"
|
|
|
|
|
smv_outputdir_format = "{config.release}"
|
|
|
|
|
# don't make docs for tags
|
|
|
|
|
smv_tag_whitelist = r"^$"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Options for HTML output -------------------------------------------------
|
|
|
|
|
|
2020-06-16 14:50:02 +02:00
|
|
|
html_theme = "nature"
|
2020-04-09 08:39:55 +02:00
|
|
|
|
|
|
|
|
# Custom extras for sidebar
|
|
|
|
|
html_sidebars = {
|
2020-06-14 11:45:10 +02:00
|
|
|
"**": [
|
2020-04-09 08:39:55 +02:00
|
|
|
"searchbox.html",
|
|
|
|
|
"localtoc.html",
|
|
|
|
|
# "globaltoc.html",
|
|
|
|
|
"relations.html",
|
|
|
|
|
"sourcelink.html",
|
|
|
|
|
"versioning.html",
|
|
|
|
|
]
|
|
|
|
|
}
|
2020-06-15 21:30:49 +02:00
|
|
|
html_favicon = "_static/images/favicon.ico"
|
|
|
|
|
html_logo = "_static/images/evennia_logo.png"
|
2020-04-05 00:02:02 +02:00
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
# HTML syntax highlighting style
|
|
|
|
|
pygments_style = "sphinx"
|
2020-04-05 00:02:02 +02:00
|
|
|
|
|
|
|
|
|
2020-06-14 20:19:31 +02:00
|
|
|
# -- Options for LaTeX output ------------------------------------------------
|
|
|
|
|
# experimental, not working well atm
|
|
|
|
|
|
2020-06-16 14:50:02 +02:00
|
|
|
latex_engine = "xelatex"
|
|
|
|
|
latex_show_urls = "footnote"
|
2020-06-14 20:19:31 +02:00
|
|
|
latex_elements = {
|
2020-06-16 14:50:02 +02:00
|
|
|
"papersize": "a4paper",
|
|
|
|
|
"fncychap": r"\usepackage[Bjarne]{fncychap}",
|
|
|
|
|
"fontpkg": r"\usepackage{times,amsmath,amsfonts,amssymb,amsthm}",
|
|
|
|
|
"preamble": r"""
|
2020-06-14 20:19:31 +02:00
|
|
|
\usepackage[utf8]{fontenc}
|
|
|
|
|
\usepackage{amsmath,amsfonts,amssymb,amsthm}
|
|
|
|
|
\usepackage[math-style=literal]{unicode-math}
|
|
|
|
|
\usepackage{newunicodechar}
|
|
|
|
|
\usepackage{graphicx}
|
2020-06-16 14:50:02 +02:00
|
|
|
""",
|
2020-06-14 20:19:31 +02:00
|
|
|
}
|
|
|
|
|
latex_documents = [
|
2020-06-16 14:50:02 +02:00
|
|
|
(master_doc, "main.tex", "Sphinx format", "Evennia", "report"),
|
|
|
|
|
("toc", "toc.tex", "TOC", "Evennia", "report"),
|
2020-06-14 20:19:31 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
# -- Recommonmark ------------------------------------------------------------
|
|
|
|
|
# allows for writing Markdown and convert to rst dynamically
|
2020-06-07 02:35:06 +02:00
|
|
|
|
2020-04-07 23:13:24 +02:00
|
|
|
# reroute to github links or to the api
|
2020-04-05 12:32:52 +02:00
|
|
|
|
2020-06-14 20:19:31 +02:00
|
|
|
_github_code_root = "https://github.com/evennia/evennia/blob/"
|
2020-04-07 23:13:24 +02:00
|
|
|
_github_doc_root = "https://github.com/evennia/tree/master/docs/sources/"
|
2020-06-07 02:35:06 +02:00
|
|
|
_github_issue_choose = "https://github.com/evennia/evennia/issues/new/choose"
|
2020-04-05 16:50:52 +02:00
|
|
|
|
2020-06-06 19:38:34 +02:00
|
|
|
|
2020-04-05 16:50:52 +02:00
|
|
|
def url_resolver(url):
|
2020-06-14 20:19:31 +02:00
|
|
|
githubstart = "github:"
|
2020-06-06 19:38:34 +02:00
|
|
|
apistart = "api:"
|
2020-06-14 20:19:31 +02:00
|
|
|
choose_issue = ("feature-request", "report-bug", "issue", "bug-report")
|
2020-06-06 19:38:34 +02:00
|
|
|
|
2020-06-07 02:35:06 +02:00
|
|
|
if url.lower().strip() in choose_issue:
|
|
|
|
|
return _github_issue_choose
|
2020-06-14 20:19:31 +02:00
|
|
|
|
|
|
|
|
elif url.startswith(githubstart):
|
2020-06-19 12:03:14 +02:00
|
|
|
urlpath = url[len(githubstart):]
|
2020-06-14 20:19:31 +02:00
|
|
|
if not (urlpath.startswith("develop/") or urlpath.startswith("master")):
|
2020-06-14 21:45:37 +02:00
|
|
|
urlpath = "master/" + urlpath
|
2020-06-14 20:19:31 +02:00
|
|
|
return _github_code_root + urlpath
|
2020-06-06 19:38:34 +02:00
|
|
|
elif url.startswith(apistart):
|
2020-06-19 12:03:14 +02:00
|
|
|
return "api/" + url[len(apistart):] + ".html"
|
2020-06-12 20:33:11 +02:00
|
|
|
return url
|
2020-04-05 16:50:52 +02:00
|
|
|
|
2020-06-06 19:38:34 +02:00
|
|
|
|
2020-06-07 02:35:06 +02:00
|
|
|
# auto-create TOCs if a list of links is under these headers
|
2020-04-09 08:39:55 +02:00
|
|
|
auto_toc_sections = ["Contents", "Toc", "Index"]
|
|
|
|
|
|
2020-05-25 22:28:43 +02:00
|
|
|
recommonmark_config = {
|
|
|
|
|
"enable_auto_toc_tree": True,
|
|
|
|
|
"url_resolver": url_resolver,
|
2020-06-15 20:08:00 +02:00
|
|
|
"auto_toc_maxdepth": 1,
|
2020-05-25 22:28:43 +02:00
|
|
|
"auto_toc_tree_section": ["Contents", "Toc", "Index"],
|
2020-06-14 11:45:10 +02:00
|
|
|
"code_highlight_options": {"force": True, "linenos": True},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- API/Autodoc ---------------------------------------------------------------
|
|
|
|
|
# automatic creation of API documentation. This requires a valid Evennia setup
|
|
|
|
|
|
|
|
|
|
_no_autodoc = os.environ.get("NOAUTODOC")
|
|
|
|
|
|
2020-06-19 12:03:14 +02:00
|
|
|
ansi_clean = None
|
|
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
if not _no_autodoc:
|
|
|
|
|
# we must set up Evennia and its paths for autodocs to work
|
|
|
|
|
|
|
|
|
|
EV_ROOT = os.environ.get("EVDIR")
|
|
|
|
|
GAME_DIR = os.environ.get("EVGAMEDIR")
|
|
|
|
|
|
|
|
|
|
if not (EV_ROOT and GAME_DIR):
|
|
|
|
|
err = (
|
|
|
|
|
"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(err)
|
|
|
|
|
|
|
|
|
|
print("Evennia root: {}, Game dir: {}".format(EV_ROOT, GAME_DIR))
|
|
|
|
|
|
|
|
|
|
sys.path.insert(1, EV_ROOT)
|
|
|
|
|
sys.path.insert(1, GAME_DIR)
|
|
|
|
|
|
|
|
|
|
with cd(GAME_DIR):
|
|
|
|
|
# set up Evennia so its sources can be parsed
|
|
|
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "server.conf.settings"
|
|
|
|
|
|
|
|
|
|
import django # noqa
|
|
|
|
|
|
|
|
|
|
django.setup()
|
|
|
|
|
|
|
|
|
|
import evennia # noqa
|
|
|
|
|
|
|
|
|
|
evennia._init()
|
|
|
|
|
|
2020-06-19 12:03:14 +02:00
|
|
|
from evennia.utils.ansi import strip_raw_ansi as ansi_clean
|
|
|
|
|
|
2020-06-14 21:45:37 +02:00
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
if _no_autodoc:
|
|
|
|
|
exclude_patterns = ["api/*"]
|
|
|
|
|
else:
|
|
|
|
|
exclude_patterns = ["api/*migrations.rst"]
|
|
|
|
|
|
|
|
|
|
autodoc_default_options = {
|
|
|
|
|
"members": True,
|
2020-06-18 23:30:11 +02:00
|
|
|
"undoc-members": False,
|
2020-06-14 11:45:10 +02:00
|
|
|
"show-inheritance": True,
|
|
|
|
|
"special-members": "__init__",
|
|
|
|
|
"enable_eval_rst": True,
|
2020-05-25 22:28:43 +02:00
|
|
|
}
|
|
|
|
|
|
2020-06-18 23:30:11 +02:00
|
|
|
autodoc_member_order = "bysource"
|
|
|
|
|
autodoc_typehints = "description"
|
2020-04-05 12:32:52 +02:00
|
|
|
|
2020-06-19 12:03:14 +02:00
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
def autodoc_skip_member(app, what, name, obj, skip, options):
|
2020-06-18 23:30:11 +02:00
|
|
|
"""Which members the autodoc should ignore."""
|
2020-06-14 11:45:10 +02:00
|
|
|
if _no_autodoc:
|
|
|
|
|
return True
|
2020-06-18 23:30:11 +02:00
|
|
|
if name.startswith("_") and name != "__init__":
|
2020-06-14 11:45:10 +02:00
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
2020-06-18 23:30:11 +02:00
|
|
|
def autodoc_clean_docstring(app, what, name, obj, options, lines):
|
|
|
|
|
"""Clean docstring of ansi. Must modify lines list in-place"""
|
2020-06-19 12:03:14 +02:00
|
|
|
if ansi_clean:
|
|
|
|
|
for il, line in enumerate(lines):
|
|
|
|
|
lines[il] = ansi_clean(line)
|
2020-06-18 23:30:11 +02:00
|
|
|
|
|
|
|
|
|
2020-06-14 11:45:10 +02:00
|
|
|
# Napoleon Google-style docstring parser for autodocs
|
|
|
|
|
|
|
|
|
|
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
|
2020-06-18 23:30:11 +02:00
|
|
|
napoleon_use_admonition_for_examples = True
|
2020-06-14 11:45:10 +02:00
|
|
|
napoleon_use_admonition_for_notes = False
|
|
|
|
|
napoleon_use_admonition_for_references = False
|
|
|
|
|
napoleon_use_ivar = False
|
|
|
|
|
napoleon_use_param = True
|
|
|
|
|
napoleon_use_keyword = True
|
2020-06-18 23:30:11 +02:00
|
|
|
napoleon_use_rtype = False
|
2020-06-14 11:45:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# -- Main config setup ------------------------------------------
|
|
|
|
|
# last setup steps for some plugins
|
|
|
|
|
|
2020-06-16 14:50:02 +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-06-18 23:30:11 +02:00
|
|
|
app.connect("autodoc-process-docstring", autodoc_clean_docstring)
|
2020-04-05 00:02:02 +02:00
|
|
|
app.add_transform(AutoStructify)
|
2020-05-20 02:26:45 +02:00
|
|
|
|
2020-06-14 21:45:37 +02:00
|
|
|
# build toctree file
|
2020-06-16 14:50:02 +02:00
|
|
|
sys.path.insert(1, os.path.join(os.path.dirname(os.path.dirname(__file__)), "docs"))
|
2020-06-14 21:45:37 +02:00
|
|
|
from docs.pylib import create_toctree
|
2020-06-16 14:50:02 +02:00
|
|
|
|
2020-06-14 21:45:37 +02:00
|
|
|
create_toctree.create_toctree()
|
|
|
|
|
print("Updated source/toc.md file")
|
|
|
|
|
|
2020-05-23 16:19:06 +02:00
|
|
|
# custom lunr-based search
|
|
|
|
|
# from docs import search
|
2020-05-23 14:59:12 +02:00
|
|
|
# custom search
|
2020-05-23 16:19:06 +02:00
|
|
|
# search.setup(app)
|