docs.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """Build QMK documentation locally
  2. """
  3. import shutil
  4. from pathlib import Path
  5. from subprocess import DEVNULL
  6. from milc import cli
  7. DOCS_PATH = Path('docs/')
  8. BUILD_PATH = Path('.build/docs/')
  9. @cli.subcommand('Build QMK documentation.', hidden=False if cli.config.user.developer else True)
  10. def generate_docs(cli):
  11. """Invoke the docs generation process
  12. TODO(unclaimed):
  13. * [ ] Add a real build step... something static docs
  14. """
  15. if BUILD_PATH.exists():
  16. shutil.rmtree(BUILD_PATH)
  17. shutil.copytree(DOCS_PATH, BUILD_PATH)
  18. # When not verbose we want to hide all output
  19. args = {
  20. 'capture_output': False if cli.config.general.verbose else True,
  21. 'check': True,
  22. 'stdin': DEVNULL,
  23. }
  24. cli.log.info('Generating internal docs...')
  25. # Generate internal docs
  26. cli.run(['doxygen', 'Doxyfile'], **args)
  27. cli.run(['moxygen', '-q', '-a', '-g', '-o', BUILD_PATH / 'internals_%s.md', 'doxygen/xml'], **args)
  28. cli.log.info('Successfully generated internal docs to %s.', BUILD_PATH)