Formatting

This commit is contained in:
Loup-Garou911XD 2024-03-13 01:47:17 +05:30
parent 461a4c016a
commit 823739b508
2 changed files with 45 additions and 39 deletions

View File

@ -9,7 +9,8 @@ import os
import sys
ballistica_root = os.getenv('BALLISTICA_ROOT') + '/'
assets_dirs : dict = {'ba_data':'src/assets/ba_data/python/',
assets_dirs: dict = {
'ba_data': 'src/assets/ba_data/python/',
'dummy_modules': 'build/dummymodules/',
'efro_tools': 'tools/', # for efro and bacommon package
}
@ -44,8 +45,9 @@ release = '43241'
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
autosummary_generate = True
extensions = ["sphinx.ext.napoleon", # https://stackoverflow.com/questions/45880348/how-to-remove-the-cause-of-an-unexpected-indentation-warning-when-generating-cod
"sphinx.ext.autodoc",
extensions = [
'sphinx.ext.napoleon', # https://stackoverflow.com/questions/45880348/how-to-remove-the-cause-of-an-unexpected-indentation-warning-when-generating-cod
'sphinx.ext.autodoc',
]
# Add any paths that contain templates here, relative to this directory.
@ -57,7 +59,6 @@ templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# 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".

View File

@ -52,9 +52,7 @@ def parse_docs_attrs(attrs: list[AttributeInfo], docs: str) -> str:
# A line with a single alphanumeric word preceding a colon
# is a new attr.
splits = line.split(' ', maxsplit=1)
if splits[0].replace('_', '').isalnum() and splits[-1].endswith(
':'
):
if splits[0].replace('_', '').isalnum() and splits[-1].endswith(':'):
if cur_attr is not None:
attrs.append(cur_attr)
cur_attr = AttributeInfo(name=splits[0])
@ -144,9 +142,7 @@ def _run_pdoc_with_dummy_modules() -> None:
# whatnot here so let's make sure we only do this once.
global _g_genned_pdoc_with_dummy_modules # pylint: disable=global-statement
if _g_genned_pdoc_with_dummy_modules:
raise RuntimeError(
'Can only run this once; it mucks with the environment.'
)
raise RuntimeError('Can only run this once; it mucks with the environment.')
_g_genned_pdoc_with_dummy_modules = True
# Make sure dummy-modules are up to date and make them discoverable
@ -213,18 +209,22 @@ def _run_pdoc() -> None:
duration = time.monotonic() - starttime
print(f'{Clr.GRN}Generated pdoc documentation in {duration:.1f}s.{Clr.RST}')
def generate_sphinxdoc() -> None:
_run_sphinx()
def _run_sphinx() -> None:
"""Do the actual docs generation with sphinx."""
import time
import shutil
from batools.version import get_current_version
version, buildnum = get_current_version()
assets_dirs : dict = {'ba_data':'src/assets/ba_data/python/',
assets_dirs: dict = {
'ba_data': 'src/assets/ba_data/python/',
'dummy_modules': 'build/dummymodules/',
'efro_tools': 'tools/', # for efro and bacommon package
}
@ -237,21 +237,26 @@ def _run_sphinx() -> None:
sphinx_apidoc_out = '.cache/sphinx/' # might want to use .cache dir
os.makedirs(sphinx_apidoc_out, exist_ok=True)
os.environ['BALLISTICA_ROOT'] = os.getcwd() # used in sphinx conf.py
os.environ['BA_RUNNING_WITH_DUMMY_MODULES'] = '1'
shutil.copytree(template_dir, sphinx_apidoc_out, dirs_exist_ok=True)
starttime = time.monotonic()
apidoc_cmd = ['sphinx-apidoc',
apidoc_cmd = [
'sphinx-apidoc',
'-f', # Force overwriting of any existing generated files.
'-H', 'Bombsquad', # project
'-A','Efroemling', # author
'-V', str(version), # version
'-R', str(buildnum), # release
'-H',
'Bombsquad', # project
'-A',
'Efroemling', # author
'-V',
str(version), # version
'-R',
str(buildnum), # release
# '--templatedir', template_dir,
'-o', sphinx_apidoc_out,
'-o',
sphinx_apidoc_out,
]
subprocess.run(apidoc_cmd + [assets_dirs['ba_data']], check=True)
subprocess.run(apidoc_cmd + [assets_dirs['dummy_modules']], check=True)