aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/cli_commands.md3
-rw-r--r--lib/python/qmk/cli/docs.py7
2 files changed, 8 insertions, 2 deletions
diff --git a/docs/cli_commands.md b/docs/cli_commands.md
index 876ffb583..314e7448d 100644
--- a/docs/cli_commands.md
+++ b/docs/cli_commands.md
@@ -360,11 +360,12 @@ qmk format-c -b branch_name
360## `qmk docs` 360## `qmk docs`
361 361
362This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 8936. 362This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 8936.
363Use the `-b`/`--browser` flag to automatically open the local webserver in your default browser.
363 364
364**Usage**: 365**Usage**:
365 366
366``` 367```
367qmk docs [-p PORT] 368qmk docs [-b] [-p PORT]
368``` 369```
369 370
370## `qmk generate-docs` 371## `qmk generate-docs`
diff --git a/lib/python/qmk/cli/docs.py b/lib/python/qmk/cli/docs.py
index 581610650..d8f9b045a 100644
--- a/lib/python/qmk/cli/docs.py
+++ b/lib/python/qmk/cli/docs.py
@@ -2,11 +2,13 @@
2""" 2"""
3import http.server 3import http.server
4import os 4import os
5import webbrowser
5 6
6from milc import cli 7from milc import cli
7 8
8 9
9@cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.') 10@cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.')
11@cli.argument('-b', '--browser', action='store_true', help='Open the docs in the default browser.')
10@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True) 12@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
11def docs(cli): 13def docs(cli):
12 """Spin up a local HTTPServer instance for the QMK docs. 14 """Spin up a local HTTPServer instance for the QMK docs.
@@ -14,9 +16,12 @@ def docs(cli):
14 os.chdir('docs') 16 os.chdir('docs')
15 17
16 with http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler) as httpd: 18 with http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler) as httpd:
17 cli.log.info("Serving QMK docs at http://localhost:%d/", cli.config.docs.port) 19 cli.log.info(f"Serving QMK docs at http://localhost:{cli.config.docs.port}/")
18 cli.log.info("Press Control+C to exit.") 20 cli.log.info("Press Control+C to exit.")
19 21
22 if cli.config.docs.browser:
23 webbrowser.open(f'http://localhost:{cli.config.docs.port}')
24
20 try: 25 try:
21 httpd.serve_forever() 26 httpd.serve_forever()
22 except KeyboardInterrupt: 27 except KeyboardInterrupt: