keyboard stuff
1"""Serve QMK documentation locally
2"""
3import shutil
4from qmk.docs import prepare_docs_build_area, run_docs_command
5
6from milc import cli
7
8
9@cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.')
10@cli.argument('-b', '--browser', action='store_true', help='Open the docs in the default browser.')
11@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
12def docs(cli):
13 """Spin up a local HTTP server for the QMK docs.
14 """
15
16 if not shutil.which('doxygen'):
17 cli.log.error('doxygen is not installed. Please install it and try again.')
18 return
19
20 if not shutil.which('yarn'):
21 cli.log.error('yarn is not installed. Please install it and try again.')
22 return
23
24 if not prepare_docs_build_area(is_production=False):
25 return False
26
27 cmd = ['docs:dev', '--port', f'{cli.args.port}']
28 if cli.args.browser:
29 cmd.append('--open')
30 run_docs_command('run', cmd)