Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI command to serve docs locally #6956

Merged
merged 6 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ This command lets you configure the behavior of QMK. For the full `qmk config` d
qmk config [-ro] [config_token1] [config_token2] [...] [config_tokenN]
```

## `qmk docs`

This command starts a local HTTP server which you can use for browsing or improving the docs. Default port is 8080.
fauxpark marked this conversation as resolved.
Show resolved Hide resolved

**Usage**:

```
qmk docs [-p PORT]
```

## `qmk doctor`

This command examines your environment and alerts you to potential build or flash problems.
Expand Down
1 change: 1 addition & 0 deletions lib/python/qmk/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from . import cformat
from . import compile
from . import config
from . import docs
from . import doctor
from . import hello
from . import json
Expand Down
20 changes: 20 additions & 0 deletions lib/python/qmk/cli/docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Serve QMK documentation locally
"""
import http.server
from os import chdir

from milc import cli


@cli.argument('-p', '--port', default=8080, help='Port number to use.')
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
@cli.subcommand('Local instance of QMK docs')
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
def docs(cli):
"""Spin up a local HTTPServer instance for the QMK docs.
"""
cli.log.info("Serving QMK docs locally on port %d.", cli.config.docs.port)
cli.log.info("Press Control+C to exit.")

chdir('docs')

httpd = http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler)
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
httpd.serve_forever()