mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Run black reformatter on code
This commit is contained in:
parent
4582eb4085
commit
bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions
|
|
@ -7,6 +7,7 @@
|
|||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
# from recommonmark.transform import AutoStructify
|
||||
from sphinx.util.osutil import cd
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ extensions = [
|
|||
"sphinx.ext.viewcode",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.githubpages",
|
||||
"myst_parser"
|
||||
"myst_parser",
|
||||
]
|
||||
|
||||
source_suffix = [".md", ".rst"]
|
||||
|
|
@ -145,9 +146,11 @@ _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"
|
||||
_ref_regex = re.compile( # normal reference-links [txt](url)
|
||||
r"\[(?P<txt>[\w -\[\]\`\n]+?)\]\((?P<url>.+?)\)", re.I + re.S + re.U + re.M)
|
||||
r"\[(?P<txt>[\w -\[\]\`\n]+?)\]\((?P<url>.+?)\)", re.I + re.S + re.U + re.M
|
||||
)
|
||||
_ref_doc_regex = re.compile( # in-document bottom references [txt]: url
|
||||
r"\[(?P<txt>[\w -\`]+?)\\n]:\s+?(?P<url>.+?)(?=$|\n)", re.I + re.S + re.U + re.M)
|
||||
r"\[(?P<txt>[\w -\`]+?)\\n]:\s+?(?P<url>.+?)(?=$|\n)", re.I + re.S + re.U + re.M
|
||||
)
|
||||
|
||||
|
||||
def url_resolver(app, docname, source):
|
||||
|
|
@ -165,10 +168,11 @@ def url_resolver(app, docname, source):
|
|||
|
||||
|
||||
"""
|
||||
|
||||
def _url_remap(url):
|
||||
|
||||
# determine depth in tree of current document
|
||||
docdepth = docname.count('/') + 1
|
||||
docdepth = docname.count("/") + 1
|
||||
relative_path = "../".join("" for _ in range(docdepth))
|
||||
|
||||
if url.endswith(_choose_issue):
|
||||
|
|
@ -176,14 +180,14 @@ def url_resolver(app, docname, source):
|
|||
return _github_issue_choose
|
||||
elif _githubstart in url:
|
||||
# github:develop/... shortcut
|
||||
urlpath = url[url.index(_githubstart) + len(_githubstart):]
|
||||
urlpath = url[url.index(_githubstart) + len(_githubstart) :]
|
||||
if not (urlpath.startswith("develop/") or urlpath.startswith("master")):
|
||||
urlpath = "master/" + urlpath
|
||||
return _github_code_root + urlpath
|
||||
elif _sourcestart in url:
|
||||
ind = url.index(_sourcestart)
|
||||
|
||||
modpath, *inmodule = url[ind + len(_sourcestart):].rsplit("#", 1)
|
||||
modpath, *inmodule = url[ind + len(_sourcestart) :].rsplit("#", 1)
|
||||
modpath = "/".join(modpath.split("."))
|
||||
inmodule = "#" + inmodule[0] if inmodule else ""
|
||||
modpath = modpath + ".html" + inmodule
|
||||
|
|
@ -194,13 +198,13 @@ def url_resolver(app, docname, source):
|
|||
return url
|
||||
|
||||
def _re_ref_sub(match):
|
||||
txt = match.group('txt')
|
||||
url = _url_remap(match.group('url'))
|
||||
txt = match.group("txt")
|
||||
url = _url_remap(match.group("url"))
|
||||
return f"[{txt}]({url})"
|
||||
|
||||
def _re_docref_sub(match):
|
||||
txt = match.group('txt')
|
||||
url = _url_remap(match.group('url'))
|
||||
txt = match.group("txt")
|
||||
url = _url_remap(match.group("url"))
|
||||
return f"[{txt}]: {url}"
|
||||
|
||||
src = source[0]
|
||||
|
|
@ -248,7 +252,7 @@ autodoc_default_options = {
|
|||
"show-inheritance": True,
|
||||
"special-members": "__init__",
|
||||
"enable_eval_rst": True,
|
||||
"inherited_members": True
|
||||
"inherited_members": True,
|
||||
}
|
||||
|
||||
autodoc_member_order = "bysource"
|
||||
|
|
@ -345,8 +349,12 @@ def setup(app):
|
|||
|
||||
# build toctree file
|
||||
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
|
||||
from docs.pylib import (auto_link_remapper, update_default_cmd_index,
|
||||
contrib_readmes2docs, update_dynamic_pages)
|
||||
from docs.pylib import (
|
||||
auto_link_remapper,
|
||||
update_default_cmd_index,
|
||||
contrib_readmes2docs,
|
||||
update_dynamic_pages,
|
||||
)
|
||||
|
||||
_no_autodoc = os.environ.get("NOAUTODOC")
|
||||
update_default_cmd_index.run_update(no_autodoc=_no_autodoc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue