mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-06 23:59:18 +08:00
Formatting
This commit is contained in:
parent
461a4c016a
commit
823739b508
@ -9,25 +9,26 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
ballistica_root = os.getenv('BALLISTICA_ROOT') + '/'
|
ballistica_root = os.getenv('BALLISTICA_ROOT') + '/'
|
||||||
assets_dirs : dict = {'ba_data':'src/assets/ba_data/python/',
|
assets_dirs: dict = {
|
||||||
'dummy_modules':'build/dummymodules/',
|
'ba_data': 'src/assets/ba_data/python/',
|
||||||
'efro_tools':'tools/', # for efro and bacommon package
|
'dummy_modules': 'build/dummymodules/',
|
||||||
}
|
'efro_tools': 'tools/', # for efro and bacommon package
|
||||||
|
}
|
||||||
sys.path.append(os.path.abspath(ballistica_root+assets_dirs['ba_data']))
|
|
||||||
sys.path.append(os.path.abspath(ballistica_root+assets_dirs['dummy_modules']))
|
sys.path.append(os.path.abspath(ballistica_root + assets_dirs['ba_data']))
|
||||||
sys.path.append(os.path.abspath(ballistica_root+assets_dirs['efro_tools']))
|
sys.path.append(os.path.abspath(ballistica_root + assets_dirs['dummy_modules']))
|
||||||
|
sys.path.append(os.path.abspath(ballistica_root + assets_dirs['efro_tools']))
|
||||||
|
|
||||||
# -- Options for HTML output -------------------------------------------------
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
# for more themes visit https://sphinx-themes.org/
|
# for more themes visit https://sphinx-themes.org/
|
||||||
html_theme = 'furo' # python_docs_theme, groundwork, furo
|
html_theme = 'furo' # python_docs_theme, groundwork, furo
|
||||||
# html_logo = ballistica_root + 'build/assets/ba_data/textures/logo_preview.png' # need a smaller img
|
# html_logo = ballistica_root + 'build/assets/ba_data/textures/logo_preview.png' # need a smaller img
|
||||||
|
|
||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
keep_warnings = True # Supressing warnings
|
keep_warnings = True # Supressing warnings
|
||||||
project = 'ballistica-bombsquad'
|
project = 'ballistica-bombsquad'
|
||||||
|
|
||||||
copyright = '2024, Efroemling'
|
copyright = '2024, Efroemling'
|
||||||
@ -44,8 +45,9 @@ release = '43241'
|
|||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
# ones.
|
# ones.
|
||||||
autosummary_generate = True
|
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
|
extensions = [
|
||||||
"sphinx.ext.autodoc",
|
'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.
|
# 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']
|
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# 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,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
|||||||
@ -52,9 +52,7 @@ def parse_docs_attrs(attrs: list[AttributeInfo], docs: str) -> str:
|
|||||||
# A line with a single alphanumeric word preceding a colon
|
# A line with a single alphanumeric word preceding a colon
|
||||||
# is a new attr.
|
# is a new attr.
|
||||||
splits = line.split(' ', maxsplit=1)
|
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:
|
if cur_attr is not None:
|
||||||
attrs.append(cur_attr)
|
attrs.append(cur_attr)
|
||||||
cur_attr = AttributeInfo(name=splits[0])
|
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.
|
# whatnot here so let's make sure we only do this once.
|
||||||
global _g_genned_pdoc_with_dummy_modules # pylint: disable=global-statement
|
global _g_genned_pdoc_with_dummy_modules # pylint: disable=global-statement
|
||||||
if _g_genned_pdoc_with_dummy_modules:
|
if _g_genned_pdoc_with_dummy_modules:
|
||||||
raise RuntimeError(
|
raise RuntimeError('Can only run this once; it mucks with the environment.')
|
||||||
'Can only run this once; it mucks with the environment.'
|
|
||||||
)
|
|
||||||
_g_genned_pdoc_with_dummy_modules = True
|
_g_genned_pdoc_with_dummy_modules = True
|
||||||
|
|
||||||
# Make sure dummy-modules are up to date and make them discoverable
|
# Make sure dummy-modules are up to date and make them discoverable
|
||||||
@ -213,51 +209,60 @@ def _run_pdoc() -> None:
|
|||||||
duration = time.monotonic() - starttime
|
duration = time.monotonic() - starttime
|
||||||
print(f'{Clr.GRN}Generated pdoc documentation in {duration:.1f}s.{Clr.RST}')
|
print(f'{Clr.GRN}Generated pdoc documentation in {duration:.1f}s.{Clr.RST}')
|
||||||
|
|
||||||
|
|
||||||
def generate_sphinxdoc() -> None:
|
def generate_sphinxdoc() -> None:
|
||||||
_run_sphinx()
|
_run_sphinx()
|
||||||
|
|
||||||
|
|
||||||
def _run_sphinx() -> None:
|
def _run_sphinx() -> None:
|
||||||
"""Do the actual docs generation with sphinx."""
|
"""Do the actual docs generation with sphinx."""
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from batools.version import get_current_version
|
from batools.version import get_current_version
|
||||||
|
|
||||||
version, buildnum = get_current_version()
|
version, buildnum = get_current_version()
|
||||||
|
|
||||||
assets_dirs : dict = {'ba_data':'src/assets/ba_data/python/',
|
assets_dirs: dict = {
|
||||||
'dummy_modules':'build/dummymodules/',
|
'ba_data': 'src/assets/ba_data/python/',
|
||||||
'efro_tools':'tools/', # for efro and bacommon package
|
'dummy_modules': 'build/dummymodules/',
|
||||||
}
|
'efro_tools': 'tools/', # for efro and bacommon package
|
||||||
|
}
|
||||||
|
|
||||||
sphinx_src = 'src/assets/sphinx/'
|
sphinx_src = 'src/assets/sphinx/'
|
||||||
template_dir = Path(sphinx_src+'template/')
|
template_dir = Path(sphinx_src + 'template/')
|
||||||
assert template_dir.is_dir()
|
assert template_dir.is_dir()
|
||||||
build_dir = 'build/sphinx/'
|
build_dir = 'build/sphinx/'
|
||||||
os.makedirs(build_dir, exist_ok=True)
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
sphinx_apidoc_out = '.cache/sphinx/' # might want to use .cache dir
|
sphinx_apidoc_out = '.cache/sphinx/' # might want to use .cache dir
|
||||||
os.makedirs(sphinx_apidoc_out, exist_ok=True)
|
os.makedirs(sphinx_apidoc_out, exist_ok=True)
|
||||||
|
|
||||||
|
os.environ['BALLISTICA_ROOT'] = os.getcwd() # used in sphinx conf.py
|
||||||
os.environ['BALLISTICA_ROOT'] = os.getcwd() # used in sphinx conf.py
|
|
||||||
os.environ['BA_RUNNING_WITH_DUMMY_MODULES'] = '1'
|
os.environ['BA_RUNNING_WITH_DUMMY_MODULES'] = '1'
|
||||||
|
|
||||||
shutil.copytree(template_dir, sphinx_apidoc_out, dirs_exist_ok= True)
|
shutil.copytree(template_dir, sphinx_apidoc_out, dirs_exist_ok=True)
|
||||||
|
|
||||||
starttime = time.monotonic()
|
starttime = time.monotonic()
|
||||||
apidoc_cmd = ['sphinx-apidoc',
|
apidoc_cmd = [
|
||||||
'-f', # Force overwriting of any existing generated files.
|
'sphinx-apidoc',
|
||||||
'-H', 'Bombsquad', # project
|
'-f', # Force overwriting of any existing generated files.
|
||||||
'-A','Efroemling', # author
|
'-H',
|
||||||
'-V', str(version), # version
|
'Bombsquad', # project
|
||||||
'-R', str(buildnum), # release
|
'-A',
|
||||||
# '--templatedir', template_dir,
|
'Efroemling', # author
|
||||||
'-o', sphinx_apidoc_out,
|
'-V',
|
||||||
]
|
str(version), # version
|
||||||
subprocess.run(apidoc_cmd + [assets_dirs['ba_data']] , check=True)
|
'-R',
|
||||||
|
str(buildnum), # release
|
||||||
|
# '--templatedir', template_dir,
|
||||||
|
'-o',
|
||||||
|
sphinx_apidoc_out,
|
||||||
|
]
|
||||||
|
subprocess.run(apidoc_cmd + [assets_dirs['ba_data']], check=True)
|
||||||
subprocess.run(apidoc_cmd + [assets_dirs['dummy_modules']], check=True)
|
subprocess.run(apidoc_cmd + [assets_dirs['dummy_modules']], check=True)
|
||||||
subprocess.run(apidoc_cmd + [assets_dirs['efro_tools']], check=True)
|
subprocess.run(apidoc_cmd + [assets_dirs['efro_tools']], check=True)
|
||||||
|
|
||||||
subprocess.run( ['make', 'html'], check = True, cwd= sphinx_apidoc_out)
|
subprocess.run(['make', 'html'], check=True, cwd=sphinx_apidoc_out)
|
||||||
shutil.copytree(sphinx_apidoc_out + '_build/html/', build_dir, dirs_exist_ok=True)
|
shutil.copytree(sphinx_apidoc_out + '_build/html/', build_dir, dirs_exist_ok=True)
|
||||||
# shutil.rmtree(temp_modules_dir)
|
# shutil.rmtree(temp_modules_dir)
|
||||||
duration = time.monotonic() - starttime
|
duration = time.monotonic() - starttime
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user