2020-11-10 15:00:40 +00:00
|
|
|
"""Build QMK documentation locally
|
|
|
|
"""
|
|
|
|
import shutil
|
|
|
|
from pathlib import Path
|
2021-05-19 22:24:46 +00:00
|
|
|
from subprocess import DEVNULL
|
2020-11-10 15:00:40 +00:00
|
|
|
|
|
|
|
from milc import cli
|
|
|
|
|
|
|
|
DOCS_PATH = Path('docs/')
|
2022-02-21 15:47:44 +00:00
|
|
|
BUILD_PATH = Path('.build/')
|
|
|
|
BUILD_DOCS_PATH = BUILD_PATH / 'docs'
|
|
|
|
DOXYGEN_PATH = BUILD_PATH / 'doxygen'
|
2020-11-10 15:00:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@cli.subcommand('Build QMK documentation.', hidden=False if cli.config.user.developer else True)
|
|
|
|
def generate_docs(cli):
|
|
|
|
"""Invoke the docs generation process
|
|
|
|
|
|
|
|
TODO(unclaimed):
|
|
|
|
* [ ] Add a real build step... something static docs
|
|
|
|
"""
|
|
|
|
|
2022-02-21 15:47:44 +00:00
|
|
|
if BUILD_DOCS_PATH.exists():
|
|
|
|
shutil.rmtree(BUILD_DOCS_PATH)
|
|
|
|
if DOXYGEN_PATH.exists():
|
|
|
|
shutil.rmtree(DOXYGEN_PATH)
|
2020-11-10 15:00:40 +00:00
|
|
|
|
2022-02-21 15:47:44 +00:00
|
|
|
shutil.copytree(DOCS_PATH, BUILD_DOCS_PATH)
|
2020-11-10 15:00:40 +00:00
|
|
|
|
|
|
|
# When not verbose we want to hide all output
|
2021-05-19 22:24:46 +00:00
|
|
|
args = {
|
|
|
|
'capture_output': False if cli.config.general.verbose else True,
|
|
|
|
'check': True,
|
|
|
|
'stdin': DEVNULL,
|
|
|
|
}
|
2020-11-10 15:00:40 +00:00
|
|
|
|
|
|
|
cli.log.info('Generating internal docs...')
|
|
|
|
|
|
|
|
# Generate internal docs
|
2021-05-19 22:24:46 +00:00
|
|
|
cli.run(['doxygen', 'Doxyfile'], **args)
|
2022-02-21 15:47:44 +00:00
|
|
|
cli.run(['moxygen', '-q', '-g', '-o', BUILD_DOCS_PATH / 'internals_%s.md', DOXYGEN_PATH / 'xml'], **args)
|
2020-11-10 15:00:40 +00:00
|
|
|
|
2022-02-21 15:47:44 +00:00
|
|
|
cli.log.info('Successfully generated internal docs to %s.', BUILD_DOCS_PATH)
|