mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-01 20:33:46 +08:00
work on docs generation
This commit is contained in:
parent
c0edb1cf70
commit
9403067a04
9
.idea/dictionaries/ericf.xml
generated
9
.idea/dictionaries/ericf.xml
generated
@ -297,6 +297,7 @@
|
||||
<w>cpplint</w>
|
||||
<w>cpplintcode</w>
|
||||
<w>cpplintcodefull</w>
|
||||
<w>cpplintfull</w>
|
||||
<w>cpuinfo</w>
|
||||
<w>cpus</w>
|
||||
<w>cpython</w>
|
||||
@ -375,6 +376,7 @@
|
||||
<w>dnode</w>
|
||||
<w>doclines</w>
|
||||
<w>docprefix</w>
|
||||
<w>docshash</w>
|
||||
<w>docslines</w>
|
||||
<w>docstr</w>
|
||||
<w>doctype</w>
|
||||
@ -674,6 +676,7 @@
|
||||
<w>hacky</w>
|
||||
<w>halign</w>
|
||||
<w>handlemessage</w>
|
||||
<w>hashlines</w>
|
||||
<w>hashopenssl</w>
|
||||
<w>hashpath</w>
|
||||
<w>hashstr</w>
|
||||
@ -990,8 +993,10 @@
|
||||
<w>myobj</w>
|
||||
<w>myprojname</w>
|
||||
<w>mypy</w>
|
||||
<w>mypyfull</w>
|
||||
<w>mypyscripts</w>
|
||||
<w>mypyscriptsfull</w>
|
||||
<w>mysound</w>
|
||||
<w>mytextnode</w>
|
||||
<w>myweakcall</w>
|
||||
<w>mywidget</w>
|
||||
@ -1230,6 +1235,7 @@
|
||||
<w>pybuild</w>
|
||||
<w>pycache</w>
|
||||
<w>pycharmbin</w>
|
||||
<w>pycharmfull</w>
|
||||
<w>pycharmroot</w>
|
||||
<w>pycharmscripts</w>
|
||||
<w>pycharmscriptsfull</w>
|
||||
@ -1247,6 +1253,8 @@
|
||||
<w>pylib</w>
|
||||
<w>pylibs</w>
|
||||
<w>pylint</w>
|
||||
<w>pylintfast</w>
|
||||
<w>pylintfull</w>
|
||||
<w>pylintplugins</w>
|
||||
<w>pylintrc</w>
|
||||
<w>pylintscripts</w>
|
||||
@ -1457,6 +1465,7 @@
|
||||
<w>steelseries</w>
|
||||
<w>stickman</w>
|
||||
<w>storable</w>
|
||||
<w>storedhash</w>
|
||||
<w>storeitemui</w>
|
||||
<w>stringprep</w>
|
||||
<w>stringptr</w>
|
||||
|
||||
20
Makefile
20
Makefile
@ -270,7 +270,7 @@ check: updatecheck
|
||||
@echo ALL CHECKS PASSED!
|
||||
# Same as 'check' plus optional/slow extra checks.
|
||||
check2: updatecheck
|
||||
@$(MAKE) -j4 cpplint pylint mypy pycharmscripts
|
||||
@$(MAKE) -j4 cpplint pylint mypy pycharm
|
||||
@echo ALL CHECKS PASSED!
|
||||
|
||||
# Run faster checks which may occasionally miss things.
|
||||
@ -279,7 +279,7 @@ checkfast: updatecheck
|
||||
@echo ALL CHECKS PASSED!
|
||||
# Same as 'checkfast' plus optional/slow extra checks.
|
||||
checkfast2: updatecheck
|
||||
@$(MAKE) -j4 cpplint pylintfast mypy pycharmscripts
|
||||
@$(MAKE) -j4 cpplint pylintfast mypy pycharm
|
||||
@echo ALL CHECKS PASSED!
|
||||
|
||||
# Run checks with no caching (all files are checked).
|
||||
@ -288,7 +288,7 @@ checkfull: updatecheck
|
||||
@echo ALL CHECKS PASSED!
|
||||
# Same as 'checkfull' plus optional/slow extra checks.
|
||||
checkfull2: updatecheck
|
||||
@$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmscriptsfull
|
||||
@$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmfull
|
||||
@echo ALL CHECKS PASSED!
|
||||
|
||||
# Run Cpplint checks on all C/C++ code.
|
||||
@ -323,18 +323,18 @@ mypyfull: prereqs
|
||||
@tools/snippets mypy -full
|
||||
|
||||
# Run PyCharm checks on all Python code.
|
||||
pycharmscripts: prereqs
|
||||
@tools/snippets pycharmscripts
|
||||
pycharm: prereqs
|
||||
@tools/snippets pycharm
|
||||
|
||||
# Run PyCharm checks without caching (all files are checked).
|
||||
pycharmscriptsfull: prereqs
|
||||
@tools/snippets pycharmscripts -full
|
||||
pycharmfull: prereqs
|
||||
@tools/snippets pycharm -full
|
||||
|
||||
# Tell make which of these targets don't represent files.
|
||||
.PHONY: format formatfull formatcode formatcodefull formatscripts \
|
||||
formatscriptsfull check check2 checkfast checkfast2 checkfull checkfull2 \
|
||||
cpplint cpplintfull pylint pylintfull mypy \
|
||||
mypyfull pycharmscripts pycharmscriptsfull
|
||||
mypyfull pycharm pycharmfull
|
||||
|
||||
|
||||
################################################################################
|
||||
@ -358,7 +358,7 @@ updatethencheck: update
|
||||
@echo ALL CHECKS PASSED!
|
||||
# Same as 'updatethencheck' plus optional/slow extra checks.
|
||||
updatethencheck2: update
|
||||
@$(MAKE) -j4 cpplint pylint mypy pycharmscripts
|
||||
@$(MAKE) -j4 cpplint pylint mypy pycharm
|
||||
@echo ALL CHECKS PASSED!
|
||||
|
||||
# 'updatethencheck' without caching (checks all files).
|
||||
@ -367,7 +367,7 @@ updatethencheckfull: update
|
||||
@echo ALL CHECKS PASSED!
|
||||
# 'updatethencheckfull' plus optional/slow extra checks.
|
||||
updatethencheckfull2: update
|
||||
@$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmscriptsfull
|
||||
@$(MAKE) -j4 cpplintfull pylintfull mypyfull pycharmfull
|
||||
@echo ALL CHECKS PASSED!
|
||||
|
||||
# Format, update, and check the project; do this before git commits.
|
||||
|
||||
@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand.
|
||||
"""
|
||||
|
||||
# (hash we can use to see if this file is out of date)
|
||||
# SOURCES_HASH=120456495529909322688635129785556212748
|
||||
# SOURCES_HASH=221041082183416610193123748095056578345
|
||||
|
||||
# I'm sorry Pylint. I know this file saddens you. Be strong.
|
||||
# pylint: disable=useless-suppression
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<h4><em>last updated on 2019-11-11 for BallisticaCore version 1.5.0 build 20001</em></h4>
|
||||
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
|
||||
<!--DOCSHASH=2c7e7e6ababaa4f13a69ea88d880155c-->
|
||||
<h4><em>last updated on 2019-11-12 for Ballistica version 1.5.0 build 20001</em></h4>
|
||||
<p>This page documents the Python classes and functions in the 'ba' module,
|
||||
which are the ones most relevant to modding BallisticaCore. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
|
||||
<hr>
|
||||
<h2>Table of Contents</h2>
|
||||
<h4><a class="offsanchor" name="class_category_Gameplay_Classes">Gameplay Classes</a></h4>
|
||||
|
||||
@ -684,12 +684,12 @@ def _run_idea_inspections_cached(cachepath: Path,
|
||||
flush=True)
|
||||
|
||||
|
||||
def pycharmscripts(projroot: Path, full: bool, verbose: bool) -> None:
|
||||
def pycharm(projroot: Path, full: bool, verbose: bool) -> None:
|
||||
"""Run pycharm inspections on all our scripts."""
|
||||
|
||||
import time
|
||||
|
||||
cachepath = Path('config/.cache-pycharmscripts')
|
||||
cachepath = Path('config/.cache-pycharm')
|
||||
filenames = get_script_filenames(projroot)
|
||||
pycharmroot = Path('/Applications/PyCharm CE.app')
|
||||
pycharmbin = Path(pycharmroot, 'Contents/MacOS/pycharm')
|
||||
|
||||
@ -155,12 +155,12 @@ def _spelling(words: List[str]) -> None:
|
||||
|
||||
|
||||
def spelling_all() -> None:
|
||||
"""Add all misspellings from a pycharmscripts run."""
|
||||
"""Add all misspellings from a pycharm run."""
|
||||
|
||||
print('Running "make pycharmscriptsfull"...')
|
||||
print('Running "make pycharmfull"...')
|
||||
lines = [
|
||||
line for line in subprocess.run(
|
||||
['make', 'pycharmscriptsfull'], check=False,
|
||||
['make', 'pycharmfull'], check=False,
|
||||
capture_output=True).stdout.decode().splitlines()
|
||||
if 'Typo: In word' in line
|
||||
]
|
||||
@ -262,12 +262,12 @@ def mypy() -> None:
|
||||
code.mypy(PROJROOT, full)
|
||||
|
||||
|
||||
def pycharmscripts() -> None:
|
||||
def pycharm() -> None:
|
||||
"""Run PyCharm checks on our scripts."""
|
||||
from efrotools import code
|
||||
full = '-full' in sys.argv
|
||||
verbose = '-v' in sys.argv
|
||||
code.pycharmscripts(PROJROOT, full, verbose)
|
||||
code.pycharm(PROJROOT, full, verbose)
|
||||
|
||||
|
||||
def clioncode() -> None:
|
||||
|
||||
@ -44,8 +44,8 @@ import efrotools
|
||||
from efrotools.snippets import ( # pylint: disable=unused-import
|
||||
PROJROOT, CleanError, snippets_main, formatcode, formatscripts,
|
||||
formatmakefile, cpplint, pylint, mypy, tool_config_install, sync, sync_all,
|
||||
scriptfiles, pycharmscripts, clioncode, androidstudiocode,
|
||||
makefile_target_list, spelling, spelling_all, compile_python_files)
|
||||
scriptfiles, pycharm, clioncode, androidstudiocode, makefile_target_list,
|
||||
spelling, spelling_all, compile_python_files)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Optional, List, Sequence
|
||||
@ -643,6 +643,53 @@ def _vstr(nums: Sequence[int]) -> str:
|
||||
return '.'.join(str(i) for i in nums)
|
||||
|
||||
|
||||
def update_docs_md() -> None:
|
||||
"""Updates docs markdown files if necessary."""
|
||||
# pylint: disable=too-many-locals
|
||||
from efrotools import get_files_hash, run
|
||||
from efrotools.code import get_script_filenames
|
||||
|
||||
check = ('--check' in sys.argv)
|
||||
|
||||
docs_path = 'docs/ba_module.md'
|
||||
|
||||
# Generate a hash from all c/c++ sources under the python subdir
|
||||
# as well as all python scripts.
|
||||
pysources = []
|
||||
exts = ['.cc', '.c', '.h']
|
||||
for root, _dirs, files in os.walk('src/ballistica/python'):
|
||||
for fname in files:
|
||||
if any(fname.endswith(ext) for ext in exts):
|
||||
pysources.append(os.path.join(root, fname))
|
||||
pysources += get_script_filenames(Path('.'))
|
||||
curhash = get_files_hash(pysources)
|
||||
print('final2', curhash)
|
||||
|
||||
# Extract the current embedded hash.
|
||||
with open(docs_path) as infile:
|
||||
lines = infile.readlines()
|
||||
hashlines = [l for l in lines if '<!--DOCSHASH=' in l]
|
||||
assert len(hashlines) == 1
|
||||
storedhash = hashlines[0][13:-4]
|
||||
|
||||
if curhash != storedhash:
|
||||
if check:
|
||||
raise CleanError('Docs markdown is out of date.')
|
||||
|
||||
print(f'Updating {docs_path}...', flush=True)
|
||||
run('make docs')
|
||||
|
||||
# Our docs markdown is just the docs html with a few added
|
||||
# bits at the top.
|
||||
with open('build/docs.html') as infile:
|
||||
docs = infile.read()
|
||||
docs = ('<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->\n'
|
||||
f'<!--DOCSHASH={curhash}-->\n') + docs
|
||||
with open(docs_path, 'w') as outfile:
|
||||
outfile.write(docs)
|
||||
print(f'{docs_path} is up to date.')
|
||||
|
||||
|
||||
def checkenv() -> None:
|
||||
"""Check for tools necessary to build and run the app."""
|
||||
print('Checking environment...', flush=True)
|
||||
|
||||
@ -112,7 +112,19 @@ class App:
|
||||
self._apply_line_changes()
|
||||
self._apply_file_changes()
|
||||
self._update_compile_commands_file()
|
||||
self._update_dummy_module()
|
||||
|
||||
# We only check/update these in core; not spinoff projects.
|
||||
# That is because they create hashes based on source files
|
||||
# that get filtered for spinoff projects so always trip
|
||||
# dirty-checks there. If we want to generate these uniquely per
|
||||
# spinoff project we would need to start running updates
|
||||
# independently for those projects as opposed to just using
|
||||
# things as spinoff creates them.
|
||||
|
||||
# (this will get filtered and be unequal in spinoff projects)
|
||||
if 'ballistica' + 'core' == 'ballisticacore':
|
||||
self._update_dummy_module()
|
||||
self._update_docs_md()
|
||||
|
||||
if self._check:
|
||||
print('Check-Builds: Everything up to date.')
|
||||
@ -120,8 +132,8 @@ class App:
|
||||
print('Update-Builds: SUCCESS!')
|
||||
|
||||
def _update_dummy_module(self) -> None:
|
||||
# Lastly update our dummy _ba module.
|
||||
# We need to do this very last because it may run the cmake build
|
||||
# Update our dummy _ba module.
|
||||
# We need to do this near the end because it may run the cmake build
|
||||
# so its success may depend on the cmake build files having already
|
||||
# been updated.
|
||||
if os.path.exists('tools/gendummymodule.py'):
|
||||
@ -129,6 +141,19 @@ class App:
|
||||
print(CLRRED + 'Error checking/updating dummy module' + CLREND)
|
||||
sys.exit(255)
|
||||
|
||||
def _update_docs_md(self) -> None:
|
||||
# Update our docs/*.md files.
|
||||
# We need to do this near the end because it may run the cmake build
|
||||
# so its success may depend on the cmake build files having already
|
||||
# been updated.
|
||||
# (only do this if gendocs is available)
|
||||
if os.path.exists('tools/gendocs.py'):
|
||||
if os.system('tools/snippets update_docs_md' +
|
||||
self._checkarg) != 0:
|
||||
print(CLRRED + 'Error checking/updating docs markdown.' +
|
||||
CLREND)
|
||||
sys.exit(255)
|
||||
|
||||
def _update_compile_commands_file(self) -> None:
|
||||
# Update our local compile-commands file based on any changes to
|
||||
# our cmake stuff. Do this at end so cmake changes already happened.
|
||||
@ -160,7 +185,8 @@ class App:
|
||||
with open(fname, 'w') as outfile:
|
||||
outfile.write(fcode)
|
||||
if unchanged_project_count > 0:
|
||||
print(f'All {unchanged_project_count} project files up to date.')
|
||||
print(
|
||||
f'All {unchanged_project_count} project files are up to date.')
|
||||
|
||||
def _apply_line_changes(self) -> None:
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user