docs.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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/')
  9. BUILD_DOCS_PATH = BUILD_PATH / 'docs'
  10. DOXYGEN_PATH = BUILD_PATH / 'doxygen'
  11. @cli.subcommand('Build QMK documentation.', hidden=False if cli.config.user.developer else True)
  12. def generate_docs(cli):
  13. """Invoke the docs generation process
  14. TODO(unclaimed):
  15. * [ ] Add a real build step... something static docs
  16. """
  17. if BUILD_DOCS_PATH.exists():
  18. shutil.rmtree(BUILD_DOCS_PATH)
  19. if DOXYGEN_PATH.exists():
  20. shutil.rmtree(DOXYGEN_PATH)
  21. shutil.copytree(DOCS_PATH, BUILD_DOCS_PATH)
  22. # When not verbose we want to hide all output
  23. args = {
  24. 'capture_output': False if cli.config.general.verbose else True,
  25. 'check': True,
  26. 'stdin': DEVNULL,
  27. }
  28. cli.log.info('Generating internal docs...')
  29. # Generate internal docs
  30. cli.run(['doxygen', 'Doxyfile'], **args)
  31. cli.run(['moxygen', '-q', '-g', '-o', BUILD_DOCS_PATH / 'internals_%s.md', DOXYGEN_PATH / 'xml'], **args)
  32. cli.log.info('Successfully generated internal docs to %s.', BUILD_DOCS_PATH)