aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/docs.py
diff options
context:
space:
mode:
authorQMK Bot <[email protected]>2024-05-30 02:01:09 +0000
committerQMK Bot <[email protected]>2024-05-30 02:01:09 +0000
commit47356b220101b4f5b8ca71b2e1aa4f04256dd60f (patch)
tree7cf20bd01edf0285053cd9548944fd4133a27567 /lib/python/qmk/cli/docs.py
parentb36c7b99ae57e8d848373f44755510308c4eefa3 (diff)
parent6ef97172889ccd5db376b2a9f8825489e24fdac4 (diff)
downloadqmk_firmware-47356b220101b4f5b8ca71b2e1aa4f04256dd60f.tar.gz
qmk_firmware-47356b220101b4f5b8ca71b2e1aa4f04256dd60f.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/cli/docs.py')
-rw-r--r--lib/python/qmk/cli/docs.py41
1 files changed, 12 insertions, 29 deletions
diff --git a/lib/python/qmk/cli/docs.py b/lib/python/qmk/cli/docs.py
index c24b914bc1..d28dddf194 100644
--- a/lib/python/qmk/cli/docs.py
+++ b/lib/python/qmk/cli/docs.py
@@ -1,44 +1,27 @@
"""Serve QMK documentation locally
"""
-import http.server
-import os
import shutil
-import webbrowser
+from qmk.docs import prepare_docs_build_area, run_docs_command
from milc import cli
[email protected]('-p', '--port', default=8936, type=int, help='Port number to use.')
[email protected]('-b', '--browser', action='store_true', help='Open the docs in the default browser.')
@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
def docs(cli):
"""Spin up a local HTTP server for the QMK docs.
"""
- os.chdir('docs')
- # If docsify-cli is installed, run that instead so we get live reload
- if shutil.which('docsify'):
- command = ['docsify', 'serve', '--port', f'{cli.config.docs.port}', '--open' if cli.config.docs.browser else '']
+ if not shutil.which('doxygen'):
+ cli.log.error('doxygen is not installed. Please install it and try again.')
+ return
- cli.log.info(f"Running {{fg_cyan}}{str.join(' ', command)}{{fg_reset}}")
- cli.log.info("Press Control+C to exit.")
+ if not shutil.which('yarn'):
+ cli.log.error('yarn is not installed. Please install it and try again.')
+ return
- try:
- cli.run(command, capture_output=False)
- except KeyboardInterrupt:
- cli.log.info("Stopping HTTP server...")
- else:
- # Fall back to Python HTTPServer
- with http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler) as httpd:
- cli.log.info(f"Serving QMK docs at http://localhost:{cli.config.docs.port}/")
- cli.log.info("Press Control+C to exit.")
+ if not prepare_docs_build_area(is_production=False):
+ return False
- if cli.config.docs.browser:
- webbrowser.open(f'http://localhost:{cli.config.docs.port}')
-
- try:
- httpd.serve_forever()
- except KeyboardInterrupt:
- cli.log.info("Stopping HTTP server...")
- finally:
- httpd.shutdown()
+ if not cli.config.general.verbose:
+ cli.log.info('Serving docs at http://localhost:5173/ (Ctrl+C to stop)')
+ run_docs_command('run', 'docs:dev')