aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <[email protected]>2025-02-01 21:19:30 +1100
committerGitHub <[email protected]>2025-02-01 21:19:30 +1100
commit273d8d6a1a6badb8d9b473954f16a0fbbe671987 (patch)
tree0d2558d1d8ae2ce22c5b6702abc5315c607e2c12
parentff09b921f1c2160abe05c1fdbd38f25f64b6c7bd (diff)
downloadqmk_firmware-273d8d6a1a6badb8d9b473954f16a0fbbe671987.tar.gz
qmk_firmware-273d8d6a1a6badb8d9b473954f16a0fbbe671987.zip
`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.
## `qmk docs`
-This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 5173.
+This 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.
+Use the `-b`/`--browser` flag to automatically open the local webserver in your default browser.
-This command requires `node` and `yarn` to be installed as prerequisites, and provides live reload capability whilst editing.
+Requires `node` and `yarn` to be installed as prerequisites.
**Usage**:
```
-usage: qmk docs [-h]
+usage: qmk docs [-h] [-b] [-p PORT]
options:
- -h, --help show this help message and exit
+ -h, --help show this help message and exit
+ -b, --browser Open the docs in the default browser.
+ -p, --port PORT Port number to use.
```
## `qmk generate-docs`
-This command allows you to generate QMK documentation locally. It can be uses for general browsing or improving the docs.
-Use the `-s`/`--serve` flag to also serve the static site once built. Default port is 4173.
+This command generates QMK documentation for production.
+Use 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.
This command requires `node` and `yarn` to be installed as prerequisites, and requires the operating system to support symlinks.
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 {
Before 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:
```
-qmk docs
+qmk docs -b
```
-and navigating to `http://localhost:5173/`.
+Which should automatically open your browser; otherwise, navigate to `http://localhost:8936/`.
## Keyboards
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
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.
@@ -22,6 +24,7 @@ def docs(cli):
if not prepare_docs_build_area(is_production=False):
return False
- 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')
+ cmd = ['docs:dev', '--port', f'{cli.args.port}']
+ if cli.args.browser:
+ cmd.append('--open')
+ 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):
return False
cli.log.info('Building vitepress docs')
- run_docs_command('run', 'docs:build')
+ run_docs_command('run', ['docs:build'])
cli.log.info('Successfully generated docs to %s.', BUILD_DOCS_PATH)
if cli.args.serve:
- if not cli.config.general.verbose:
- cli.log.info('Serving docs at http://localhost:4173/ (Ctrl+C to stop)')
- run_docs_command('run', 'docs:preview')
+ 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'
DOXYGEN_PATH = BUILD_DOCS_PATH / 'static' / 'doxygen'
-def run_docs_command(verb, cmd=None):
+def run_docs_command(verb, cmd_args=None):
environ['PATH'] += pathsep + str(NODE_MODULES_PATH / '.bin')
- args = {'capture_output': False if cli.config.general.verbose else True, 'check': True, 'stdin': DEVNULL}
+ args = {'capture_output': False, 'check': True}
docs_env = environ.copy()
if cli.config.general.verbose:
docs_env['DEBUG'] = 'vitepress:*,vite:*'
args['env'] = docs_env
arg_list = ['yarn', verb]
- if cmd:
- arg_list.append(cmd)
+ if cmd_args:
+ arg_list.extend(cmd_args)
chdir(BUILDDEFS_PATH)
cli.run(arg_list, **args)