summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2025-02-01 21:19:30 +1100
committerGitHub <noreply@github.com>2025-02-01 21:19:30 +1100
commit273d8d6a1a6badb8d9b473954f16a0fbbe671987 (patch)
tree0d2558d1d8ae2ce22c5b6702abc5315c607e2c12
parentff09b921f1c2160abe05c1fdbd38f25f64b6c7bd (diff)
`qmk docs`: restore `--port` and `--browser` arguments (#24623)
* `qmk docs`: restore `--port` and `--browser` arguments * Make docs command args always a list
-rw-r--r--docs/cli_commands.md15
-rw-r--r--docs/contributing.md4
-rw-r--r--lib/python/qmk/cli/docs.py9
-rw-r--r--lib/python/qmk/cli/generate/docs.py6
-rw-r--r--lib/python/qmk/docs.py8
5 files changed, 23 insertions, 19 deletions
diff --git a/docs/cli_commands.md b/docs/cli_commands.md
index 4cd5ae98c3..d17b0eda23 100644
--- a/docs/cli_commands.md
+++ b/docs/cli_commands.md
@@ -723,23 +723,26 @@ Now open your dev environment and live a squiggly-free life.
723 723
724## `qmk docs` 724## `qmk docs`
725 725
726This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 5173. 726This command starts a local HTTP server which you can use for browsing or improving the docs, and provides live reload capability whilst editing. Default port is 8936.
727Use the `-b`/`--browser` flag to automatically open the local webserver in your default browser.
727 728
728This command requires `node` and `yarn` to be installed as prerequisites, and provides live reload capability whilst editing. 729Requires `node` and `yarn` to be installed as prerequisites.
729 730
730**Usage**: 731**Usage**:
731 732
732``` 733```
733usage: qmk docs [-h] 734usage: qmk docs [-h] [-b] [-p PORT]
734 735
735options: 736options:
736 -h, --help show this help message and exit 737 -h, --help show this help message and exit
738 -b, --browser Open the docs in the default browser.
739 -p, --port PORT Port number to use.
737``` 740```
738 741
739## `qmk generate-docs` 742## `qmk generate-docs`
740 743
741This command allows you to generate QMK documentation locally. It can be uses for general browsing or improving the docs. 744This command generates QMK documentation for production.
742Use the `-s`/`--serve` flag to also serve the static site once built. Default port is 4173. 745Use the `-s`/`--serve` flag to also serve the static site on port 4173 once built. Note that this does not provide live reloading; use `qmk docs` instead for development purposes.
743 746
744This command requires `node` and `yarn` to be installed as prerequisites, and requires the operating system to support symlinks. 747This command requires `node` and `yarn` to be installed as prerequisites, and requires the operating system to support symlinks.
745 748
diff --git a/docs/contributing.md b/docs/contributing.md
index bbb1997a6f..70a00b706d 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -106,10 +106,10 @@ enum my_keycodes {
106Before opening a pull request, you can preview your changes if you have set up the development environment by running this command from the `qmk_firmware/` folder: 106Before opening a pull request, you can preview your changes if you have set up the development environment by running this command from the `qmk_firmware/` folder:
107 107
108``` 108```
109qmk docs 109qmk docs -b
110``` 110```
111 111
112and navigating to `http://localhost:5173/`. 112Which should automatically open your browser; otherwise, navigate to `http://localhost:8936/`.
113 113
114## Keyboards 114## Keyboards
115 115
diff --git a/lib/python/qmk/cli/docs.py b/lib/python/qmk/cli/docs.py
index d28dddf194..da02ebf95e 100644
--- a/lib/python/qmk/cli/docs.py
+++ b/lib/python/qmk/cli/docs.py
@@ -6,6 +6,8 @@ from qmk.docs import prepare_docs_build_area, run_docs_command
6from milc import cli 6from milc import cli
7 7
8 8
9@cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.')
10@cli.argument('-b', '--browser', action='store_true', help='Open the docs in the default browser.')
9@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True) 11@cli.subcommand('Run a local webserver for QMK documentation.', hidden=False if cli.config.user.developer else True)
10def docs(cli): 12def docs(cli):
11 """Spin up a local HTTP server for the QMK docs. 13 """Spin up a local HTTP server for the QMK docs.
@@ -22,6 +24,7 @@ def docs(cli):
22 if not prepare_docs_build_area(is_production=False): 24 if not prepare_docs_build_area(is_production=False):
23 return False 25 return False
24 26
25 if not cli.config.general.verbose: 27 cmd = ['docs:dev', '--port', f'{cli.args.port}']
26 cli.log.info('Serving docs at http://localhost:5173/ (Ctrl+C to stop)') 28 if cli.args.browser:
27 run_docs_command('run', 'docs:dev') 29 cmd.append('--open')
30 run_docs_command('run', cmd)
diff --git a/lib/python/qmk/cli/generate/docs.py b/lib/python/qmk/cli/generate/docs.py
index 5821d43b86..7abeca9d2a 100644
--- a/lib/python/qmk/cli/generate/docs.py
+++ b/lib/python/qmk/cli/generate/docs.py
@@ -27,10 +27,8 @@ def generate_docs(cli):
27 return False 27 return False
28 28
29 cli.log.info('Building vitepress docs') 29 cli.log.info('Building vitepress docs')
30 run_docs_command('run', 'docs:build') 30 run_docs_command('run', ['docs:build'])
31 cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH) 31 cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH)
32 32
33 if cli.args.serve: 33 if cli.args.serve:
34 if not cli.config.general.verbose: 34 run_docs_command('run', ['docs:preview'])
35 cli.log.info('Serving docs at http://localhost:4173/ (Ctrl+C to stop)')
36 run_docs_command('run', 'docs:preview')
diff --git a/lib/python/qmk/docs.py b/lib/python/qmk/docs.py
index 56694cf6ae..75d2d60bda 100644
--- a/lib/python/qmk/docs.py
+++ b/lib/python/qmk/docs.py
@@ -17,18 +17,18 @@ BUILD_DOCS_PATH = BUILD_PATH / 'docs'
17DOXYGEN_PATH = BUILD_DOCS_PATH / 'static' / 'doxygen' 17DOXYGEN_PATH = BUILD_DOCS_PATH / 'static' / 'doxygen'
18 18
19 19
20def run_docs_command(verb, cmd=None): 20def run_docs_command(verb, cmd_args=None):
21 environ['PATH'] += pathsep + str(NODE_MODULES_PATH / '.bin') 21 environ['PATH'] += pathsep + str(NODE_MODULES_PATH / '.bin')
22 22
23 args = {'capture_output': False if cli.config.general.verbose else True, 'check': True, 'stdin': DEVNULL} 23 args = {'capture_output': False, 'check': True}
24 docs_env = environ.copy() 24 docs_env = environ.copy()
25 if cli.config.general.verbose: 25 if cli.config.general.verbose:
26 docs_env['DEBUG'] = 'vitepress:*,vite:*' 26 docs_env['DEBUG'] = 'vitepress:*,vite:*'
27 args['env'] = docs_env 27 args['env'] = docs_env
28 28
29 arg_list = ['yarn', verb] 29 arg_list = ['yarn', verb]
30 if cmd: 30 if cmd_args:
31 arg_list.append(cmd) 31 arg_list.extend(cmd_args)
32 32
33 chdir(BUILDDEFS_PATH) 33 chdir(BUILDDEFS_PATH)
34 cli.run(arg_list, **args) 34 cli.run(arg_list, **args)