Run black reformatter on code
This commit is contained in:
parent
4582eb4085
commit
bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions
|
|
@ -11,15 +11,15 @@ from os import rename
|
|||
|
||||
def _rst2md(filename_rst):
|
||||
|
||||
with open(filename_rst, 'r') as fil:
|
||||
with open(filename_rst, "r") as fil:
|
||||
# read rst file, reformat and save
|
||||
txt = fil.read()
|
||||
with open(filename_rst, 'w') as fil:
|
||||
with open(filename_rst, "w") as fil:
|
||||
txt = "```{eval-rst}\n" + txt + "\n```"
|
||||
fil.write(txt)
|
||||
|
||||
# rename .rst file to .md file
|
||||
filename, _ = filename_rst.rsplit('.', 1)
|
||||
filename, _ = filename_rst.rsplit(".", 1)
|
||||
filename_md = filename + ".md"
|
||||
rename(filename_rst, filename_md)
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ def auto_link_remapper(no_autodoc=False):
|
|||
|
||||
for strip_prefix in _STRIP_PREFIX:
|
||||
if url.startswith(strip_prefix):
|
||||
url = url[len(strip_prefix):]
|
||||
url = url[len(strip_prefix) :]
|
||||
|
||||
if any(url.startswith(noremap) for noremap in _NO_REMAP_STARTSWITH):
|
||||
# skip regular http/s urls etc
|
||||
|
|
@ -157,10 +157,10 @@ def auto_link_remapper(no_autodoc=False):
|
|||
|
||||
if url.startswith("evennia."):
|
||||
# api link - we want to remove legacy #reference and remove .md
|
||||
if '#' in url:
|
||||
_, url = url.rsplit('#', 1)
|
||||
if "#" in url:
|
||||
_, url = url.rsplit("#", 1)
|
||||
if url.endswith(".md"):
|
||||
url, _ = url.rsplit('.', 1)
|
||||
url, _ = url.rsplit(".", 1)
|
||||
return f"[{txt}]({url})"
|
||||
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
|
|
@ -174,7 +174,9 @@ def auto_link_remapper(no_autodoc=False):
|
|||
|
||||
if _CURRFILE in docref_map and fname in docref_map[_CURRFILE]:
|
||||
cfilename = _CURRFILE.rsplit("/", 1)[-1]
|
||||
urlout = docref_map[_CURRFILE][fname] + ".md" + ("#" + anchor[0].lower() if anchor else "")
|
||||
urlout = (
|
||||
docref_map[_CURRFILE][fname] + ".md" + ("#" + anchor[0].lower() if anchor else "")
|
||||
)
|
||||
if urlout != url:
|
||||
print(f" {cfilename}: [{txt}]({url}) -> [{txt}]({urlout})")
|
||||
else:
|
||||
|
|
@ -193,7 +195,7 @@ def auto_link_remapper(no_autodoc=False):
|
|||
|
||||
for strip_prefix in _STRIP_PREFIX:
|
||||
if url.startswith(strip_prefix):
|
||||
url = url[len(strip_prefix):]
|
||||
url = url[len(strip_prefix) :]
|
||||
|
||||
if any(url.startswith(noremap) for noremap in _NO_REMAP_STARTSWITH):
|
||||
return f"[{txt}]: {url}"
|
||||
|
|
@ -202,8 +204,8 @@ def auto_link_remapper(no_autodoc=False):
|
|||
urlout = url
|
||||
elif url.startswith("evennia."):
|
||||
# api link - we want to remove legacy #reference
|
||||
if '#' in url:
|
||||
_, urlout = url.rsplit('#', 1)
|
||||
if "#" in url:
|
||||
_, urlout = url.rsplit("#", 1)
|
||||
else:
|
||||
fname, *part = url.rsplit("/", 1)
|
||||
fname = part[0] if part else fname
|
||||
|
|
|
|||
|
|
@ -50,15 +50,11 @@ tutorials are found here. Also the home of the Tutorial World demo adventure.
|
|||
"utils": """
|
||||
Miscellaneous, optional tools for manipulating text, auditing connections
|
||||
and more.
|
||||
"""
|
||||
""",
|
||||
}
|
||||
|
||||
|
||||
_FILENAME_MAP = {
|
||||
"rpsystem": "RPSystem",
|
||||
"xyzgrid": "XYZGrid",
|
||||
"awsstorage": "AWSStorage"
|
||||
}
|
||||
_FILENAME_MAP = {"rpsystem": "RPSystem", "xyzgrid": "XYZGrid", "awsstorage": "AWSStorage"}
|
||||
|
||||
HEADER = """# Contribs
|
||||
|
||||
|
|
@ -145,10 +141,14 @@ def readmes2docs(directory=_SOURCE_DIR):
|
|||
|
||||
pypath = f"evennia.contrib.{category}.{name}"
|
||||
|
||||
filename = "Contrib-" + "-".join(
|
||||
_FILENAME_MAP.get(
|
||||
part, part.capitalize() if part[0].islower() else part)
|
||||
for part in name.split("_")) + ".md"
|
||||
filename = (
|
||||
"Contrib-"
|
||||
+ "-".join(
|
||||
_FILENAME_MAP.get(part, part.capitalize() if part[0].islower() else part)
|
||||
for part in name.split("_")
|
||||
)
|
||||
+ ".md"
|
||||
)
|
||||
outfile = pathjoin(_OUT_DIR, filename)
|
||||
|
||||
with open(file_path) as fil:
|
||||
|
|
@ -163,7 +163,7 @@ def readmes2docs(directory=_SOURCE_DIR):
|
|||
except IndexError:
|
||||
blurb = name
|
||||
|
||||
with open(outfile, 'w') as fil:
|
||||
with open(outfile, "w") as fil:
|
||||
fil.write(data)
|
||||
|
||||
categories[category].append((name, credits, blurb, filename, pypath))
|
||||
|
|
@ -179,11 +179,7 @@ def readmes2docs(directory=_SOURCE_DIR):
|
|||
for tup in sorted(contrib_tups, key=lambda tup: tup[0].lower()):
|
||||
catlines.append(
|
||||
BLURB.format(
|
||||
name=tup[0],
|
||||
credits=tup[1],
|
||||
blurb=tup[2],
|
||||
filename=tup[3],
|
||||
code_location=tup[4]
|
||||
name=tup[0], credits=tup[1], blurb=tup[2], filename=tup[3], code_location=tup[4]
|
||||
)
|
||||
)
|
||||
filenames.append(f"{tup[3]}")
|
||||
|
|
@ -193,17 +189,15 @@ def readmes2docs(directory=_SOURCE_DIR):
|
|||
category=category,
|
||||
category_desc=_CATEGORY_DESCS[category].strip(),
|
||||
blurbs="\n".join(catlines),
|
||||
toctree=toctree
|
||||
toctree=toctree,
|
||||
)
|
||||
)
|
||||
|
||||
text = _FILE_STRUCTURE.format(
|
||||
header=HEADER,
|
||||
categories="\n".join(category_sections),
|
||||
footer=INDEX_FOOTER
|
||||
header=HEADER, categories="\n".join(category_sections), footer=INDEX_FOOTER
|
||||
)
|
||||
|
||||
with open(_OUT_INDEX_FILE, 'w') as fil:
|
||||
with open(_OUT_INDEX_FILE, "w") as fil:
|
||||
fil.write(text)
|
||||
|
||||
print(f" -- Converted Contrib READMEs to {ncount} doc pages + index.")
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ if __name__ == "__main__":
|
|||
filepaths = glob.glob(args.files, recursive=True)
|
||||
width = args.width
|
||||
|
||||
wrapper = textwrap.TextWrapper(width=width, break_long_words=False, expand_tabs=True,)
|
||||
wrapper = textwrap.TextWrapper(
|
||||
width=width,
|
||||
break_long_words=False,
|
||||
expand_tabs=True,
|
||||
)
|
||||
|
||||
count = 0
|
||||
for filepath in filepaths:
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
#
|
||||
|
||||
from os.path import dirname, abspath, join as pathjoin
|
||||
from evennia.utils.utils import (
|
||||
mod_import, variable_from_module, callables_from_module
|
||||
)
|
||||
from evennia.utils.utils import mod_import, variable_from_module, callables_from_module
|
||||
|
||||
__all__ = ("run_update")
|
||||
__all__ = "run_update"
|
||||
|
||||
|
||||
PAGE = """
|
||||
|
|
@ -33,6 +31,7 @@ with [EvEditor](EvEditor), flipping pages in [EvMore](EvMore) or using the
|
|||
|
||||
"""
|
||||
|
||||
|
||||
def run_update(no_autodoc=False):
|
||||
|
||||
if no_autodoc:
|
||||
|
|
@ -71,7 +70,8 @@ def run_update(no_autodoc=False):
|
|||
for modname in cmd_modules:
|
||||
module = mod_import(modname)
|
||||
cmds_per_module[module] = [
|
||||
cmd for cmd in callables_from_module(module).values() if cmd.__name__.startswith("Cmd")]
|
||||
cmd for cmd in callables_from_module(module).values() if cmd.__name__.startswith("Cmd")
|
||||
]
|
||||
for cmd in cmds_per_module[module]:
|
||||
cmd_to_module_map[cmd] = module
|
||||
cmds_alphabetically.append(cmd)
|
||||
|
|
@ -79,8 +79,9 @@ def run_update(no_autodoc=False):
|
|||
|
||||
cmd_infos = []
|
||||
for cmd in cmds_alphabetically:
|
||||
aliases = [alias[1:] if alias and alias[0] == "@" else alias
|
||||
for alias in sorted(cmd.aliases)]
|
||||
aliases = [
|
||||
alias[1:] if alias and alias[0] == "@" else alias for alias in sorted(cmd.aliases)
|
||||
]
|
||||
aliases = f" [{', '.join(sorted(cmd.aliases))}]" if aliases else ""
|
||||
cmdlink = f"[**{cmd.key}**{aliases}]({cmd.__module__}.{cmd.__name__})"
|
||||
category = f"help-category: _{cmd.help_category.capitalize()}_"
|
||||
|
|
@ -98,12 +99,13 @@ def run_update(no_autodoc=False):
|
|||
txt = PAGE.format(
|
||||
ncommands=len(cmd_to_cmdset_map),
|
||||
nfiles=len(cmds_per_module),
|
||||
alphabetical="\n".join(f"- {info}" for info in cmd_infos))
|
||||
alphabetical="\n".join(f"- {info}" for info in cmd_infos),
|
||||
)
|
||||
|
||||
outdir = pathjoin(dirname(dirname(abspath(__file__))), "source", "Components")
|
||||
fname = pathjoin(outdir, "Default-Commands.md")
|
||||
|
||||
with open(fname, 'w') as fil:
|
||||
with open(fname, "w") as fil:
|
||||
fil.write(txt)
|
||||
|
||||
print(" -- Updated Default Command index.")
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ DOCDIR = pathjoin(ROOTDIR, "docs")
|
|||
DOCSRCDIR = pathjoin(DOCDIR, "source")
|
||||
EVENNIADIR = pathjoin(ROOTDIR, "evennia")
|
||||
|
||||
|
||||
def update_changelog():
|
||||
"""
|
||||
Plain CHANGELOG copy
|
||||
|
|
@ -22,7 +23,7 @@ def update_changelog():
|
|||
with open(sourcefile) as fil:
|
||||
txt = fil.read()
|
||||
|
||||
with open(targetfile, 'w') as fil:
|
||||
with open(targetfile, "w") as fil:
|
||||
fil.write(txt)
|
||||
|
||||
print(" -- Updated Changelog.md")
|
||||
|
|
@ -62,7 +63,7 @@ if settings.SERVERNAME == "Evennia":
|
|||
{txt}
|
||||
```
|
||||
"""
|
||||
with open(targetfile, 'w') as fil:
|
||||
with open(targetfile, "w") as fil:
|
||||
fil.write(txt)
|
||||
|
||||
print(" -- Updated Settings-Default.md")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue