summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/cli/generate/docs.py
blob: a59a24db5043876539ba4edeae1d84cb6ea98e49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Build QMK documentation locally
"""
import shutil
import subprocess
from pathlib import Path

from milc import cli

DOCS_PATH = Path('docs/')
BUILD_PATH = Path('.build/docs/')


@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
    """

    if BUILD_PATH.exists():
        shutil.rmtree(BUILD_PATH)

    shutil.copytree(DOCS_PATH, BUILD_PATH)

    # When not verbose we want to hide all output
    args = {'check': True}
    if not cli.args.verbose:
        args.update({'stdout': subprocess.DEVNULL, 'stderr': subprocess.STDOUT})

    cli.log.info('Generating internal docs...')

    # Generate internal docs
    subprocess.run(['doxygen', 'Doxyfile'], **args)
    subprocess.run(['moxygen', '-q', '-a', '-g', '-o', BUILD_PATH / 'internals_%s.md', 'doxygen/xml'], **args)

    cli.log.info('Successfully generated internal docs to %s.', BUILD_PATH)