2020-11-10 15:00:40 +00:00
|
|
|
"""Build QMK documentation locally
|
|
|
|
"""
|
|
|
|
import shutil
|
2024-05-30 02:00:41 +00:00
|
|
|
from qmk.docs import prepare_docs_build_area, run_docs_command, BUILD_DOCS_PATH
|
2020-11-10 15:00:40 +00:00
|
|
|
|
|
|
|
from milc import cli
|
|
|
|
|
|
|
|
|
2024-05-30 02:00:41 +00:00
|
|
|
@cli.argument('-s', '--serve', arg_only=True, action='store_true', help="Serves the generated docs once built.")
|
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
|
|
|
|
"""
|
|
|
|
|
2024-05-30 02:00:41 +00:00
|
|
|
if not shutil.which('doxygen'):
|
|
|
|
cli.log.error('doxygen is not installed. Please install it and try again.')
|
|
|
|
return
|
2020-11-10 15:00:40 +00:00
|
|
|
|
2024-05-30 02:00:41 +00:00
|
|
|
if not shutil.which('yarn'):
|
|
|
|
cli.log.error('yarn is not installed. Please install it and try again.')
|
|
|
|
return
|
2020-11-10 15:00:40 +00:00
|
|
|
|
2024-05-30 02:00:41 +00:00
|
|
|
if not prepare_docs_build_area(is_production=True):
|
|
|
|
return False
|
2020-11-10 15:00:40 +00:00
|
|
|
|
2024-05-30 02:00:41 +00:00
|
|
|
cli.log.info('Building vitepress docs')
|
|
|
|
run_docs_command('run', 'docs:build')
|
2022-03-07 11:22:22 +00:00
|
|
|
cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH)
|
2024-05-30 02:00:41 +00:00
|
|
|
|
|
|
|
if cli.args.serve:
|
|
|
|
if not cli.config.general.verbose:
|
|
|
|
cli.log.info('Serving docs at http://localhost:4173/ (Ctrl+C to stop)')
|
|
|
|
run_docs_command('run', 'docs:preview')
|