mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
Back-port some config/readme from develop
This commit is contained in:
parent
cd88660c00
commit
2a79f623c4
2 changed files with 456 additions and 168 deletions
|
|
@ -6,11 +6,149 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from os.path import sep
|
||||
import sphinx_theme
|
||||
from recommonmark.transform import AutoStructify
|
||||
from sphinx.util.osutil import cd
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
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 = "0.9.1"
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
extensions = [
|
||||
"recommonmark",
|
||||
"sphinx_multiversion",
|
||||
"sphinx.ext.napoleon",
|
||||
"sphinx.ext.autosectionlabel",
|
||||
"sphinx.ext.viewcode",
|
||||
# "sphinxcontrib.lunrsearch",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.githubpages",
|
||||
]
|
||||
|
||||
source_suffix = ['.md', '.rst']
|
||||
master_doc = 'index'
|
||||
|
||||
# make sure sectionlabel references can be used as path/to/file:heading
|
||||
autosectionlabel_prefix_document = True
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ["_templates"]
|
||||
# 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"]
|
||||
|
||||
|
||||
# -- 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 -------------------------------------------------
|
||||
|
||||
# html_theme = "alabaster"
|
||||
html_theme = "stanford_theme"
|
||||
html_theme_path = [sphinx_theme.get_html_theme_path("stanford_theme")]
|
||||
|
||||
# Custom extras for sidebar
|
||||
html_sidebars = {
|
||||
"**": [
|
||||
"searchbox.html",
|
||||
"localtoc.html",
|
||||
# "globaltoc.html",
|
||||
"relations.html",
|
||||
"sourcelink.html",
|
||||
"versioning.html",
|
||||
]
|
||||
}
|
||||
html_favicon = "_static/favicon.ico"
|
||||
|
||||
# HTML syntax highlighting style
|
||||
pygments_style = "sphinx"
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
# experimental, not working well atm
|
||||
|
||||
latex_engine = 'xelatex'
|
||||
latex_show_urls = 'footnote'
|
||||
latex_elements = {
|
||||
'papersize': 'a4paper',
|
||||
'fncychap': r'\usepackage[Bjarne]{fncychap}',
|
||||
'fontpkg': r'\usepackage{times,amsmath,amsfonts,amssymb,amsthm}',
|
||||
'preamble': r'''
|
||||
\usepackage[utf8]{fontenc}
|
||||
\usepackage{amsmath,amsfonts,amssymb,amsthm}
|
||||
\usepackage[math-style=literal]{unicode-math}
|
||||
\usepackage{newunicodechar}
|
||||
\usepackage{graphicx}
|
||||
'''
|
||||
}
|
||||
latex_documents = [
|
||||
(master_doc, 'main.tex', 'Sphinx format', 'Evennia', 'report'),
|
||||
("toc", 'toc.tex', 'TOC', 'Evennia', 'report')
|
||||
]
|
||||
|
||||
|
||||
# -- Recommonmark ------------------------------------------------------------
|
||||
# allows for writing Markdown and convert to rst dynamically
|
||||
|
||||
# reroute to github links or to the api
|
||||
|
||||
_github_code_root = "https://github.com/evennia/evennia/blob/"
|
||||
_github_doc_root = "https://github.com/evennia/tree/master/docs/sources/"
|
||||
_github_issue_choose = "https://github.com/evennia/evennia/issues/new/choose"
|
||||
|
||||
|
||||
def url_resolver(url):
|
||||
githubstart = "github:"
|
||||
apistart = "api:"
|
||||
choose_issue = ("feature-request", "report-bug", "issue", "bug-report")
|
||||
|
||||
if url.lower().strip() in choose_issue:
|
||||
return _github_issue_choose
|
||||
|
||||
elif url.startswith(githubstart):
|
||||
urlpath = url[len(githubstart):]
|
||||
if not (urlpath.startswith("develop/") or urlpath.startswith("master")):
|
||||
urlpath = "master/" + urlpath
|
||||
return _github_code_root + urlpath
|
||||
elif url.startswith(apistart):
|
||||
return "api/" + url[len(apistart) :] + ".html"
|
||||
return url
|
||||
# else:
|
||||
# return _github_doc_root + url
|
||||
|
||||
|
||||
# auto-create TOCs if a list of links is under these headers
|
||||
auto_toc_sections = ["Contents", "Toc", "Index"]
|
||||
|
||||
recommonmark_config = {
|
||||
"enable_auto_toc_tree": True,
|
||||
"url_resolver": url_resolver,
|
||||
"auto_toc_tree_section": ["Contents", "Toc", "Index"],
|
||||
"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")
|
||||
|
||||
if not _no_autodoc:
|
||||
|
|
@ -20,9 +158,11 @@ if not _no_autodoc:
|
|||
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.")
|
||||
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))
|
||||
|
|
@ -35,60 +175,36 @@ if not _no_autodoc:
|
|||
os.environ["DJANGO_SETTINGS_MODULE"] = "server.conf.settings"
|
||||
|
||||
import django # noqa
|
||||
|
||||
django.setup()
|
||||
|
||||
import evennia # noqa
|
||||
|
||||
evennia._init()
|
||||
|
||||
if _no_autodoc:
|
||||
exclude_patterns = ["api/*"]
|
||||
else:
|
||||
exclude_patterns = ["api/*migrations.rst"]
|
||||
|
||||
# -- 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.1'
|
||||
|
||||
# -- 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",
|
||||
"sphinx_multiversion",
|
||||
"sphinx.ext.napoleon",
|
||||
"sphinx.ext.autosectionlabel",
|
||||
"sphinx.ext.viewcode",
|
||||
# "sphinxcontrib.lunrsearch",
|
||||
]
|
||||
|
||||
# make sure sectionlabel references can be used as path/to/file:heading
|
||||
autosectionlabel_prefix_document = True
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
# 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",
|
||||
]
|
||||
autodoc_default_options = {
|
||||
"members": True,
|
||||
"undoc-members": True,
|
||||
"show-inheritance": True,
|
||||
"special-members": "__init__",
|
||||
"enable_eval_rst": True,
|
||||
}
|
||||
html_favicon = "_static/favicon.ico"
|
||||
|
||||
|
||||
# napoleon Google-style docstring parser
|
||||
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
|
||||
|
||||
|
||||
# Napoleon Google-style docstring parser for autodocs
|
||||
|
||||
napoleon_google_docstring = True
|
||||
napoleon_numpy_docstring = False
|
||||
|
|
@ -104,85 +220,8 @@ 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,
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
# -- 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
|
||||
|
||||
smv_tag_whitelist = r"^$"
|
||||
# which branches to include in multi-version docs
|
||||
# - master, develop and vX.X branches
|
||||
smv_branch_whitelist = r"^master$|^develop$|^v[0-9\.]+?$"
|
||||
smv_outputdir_format = "{config.release}"
|
||||
|
||||
|
||||
# recommonmark
|
||||
|
||||
# reroute to github links or to the api
|
||||
|
||||
_github_code_root = "https://github.com/evennia/evennia/blob/master/"
|
||||
_github_doc_root = "https://github.com/evennia/tree/master/docs/sources/"
|
||||
_github_issue_choose = "https://github.com/evennia/evennia/issues/new/choose"
|
||||
|
||||
|
||||
def url_resolver(url):
|
||||
urlstart = "github:"
|
||||
apistart = "api:"
|
||||
choose_issue = ("feature-request", "report-bug", "issue")
|
||||
|
||||
if url.lower().strip() in choose_issue:
|
||||
return _github_issue_choose
|
||||
elif url.startswith(urlstart):
|
||||
return _github_code_root + url[len(urlstart):]
|
||||
elif url.startswith(apistart):
|
||||
print("api: -> api ref")
|
||||
return "api/" + url[len(apistart):] + ".html"
|
||||
return url
|
||||
# else:
|
||||
# return _github_doc_root + url
|
||||
|
||||
|
||||
# auto-create TOCs if a list of links is under these headers
|
||||
auto_toc_sections = ["Contents", "Toc", "Index"]
|
||||
|
||||
recommonmark_config = {
|
||||
"enable_auto_toc_tree": True,
|
||||
"url_resolver": url_resolver,
|
||||
"auto_toc_tree_section": ["Contents", "Toc", "Index"],
|
||||
"code_highlight_options": {"force": True,
|
||||
"linenos": True}
|
||||
}
|
||||
# -- Main config setup ------------------------------------------
|
||||
# last setup steps for some plugins
|
||||
|
||||
|
||||
def setup(app):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue