diff options
Diffstat (limited to 'lib/python/qmk/cli/docs.py')
-rw-r--r-- | lib/python/qmk/cli/docs.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/docs.py b/lib/python/qmk/cli/docs.py index b41989139..163c8b801 100644 --- a/lib/python/qmk/cli/docs.py +++ b/lib/python/qmk/cli/docs.py | |||
@@ -1,21 +1,19 @@ | |||
1 | """Serve QMK documentation locally | 1 | """Serve QMK documentation locally |
2 | """ | 2 | """ |
3 | import http.server | 3 | import http.server |
4 | import os | ||
4 | 5 | ||
5 | from milc import cli | 6 | from milc import cli |
6 | 7 | ||
7 | 8 | ||
8 | class DocsHandler(http.server.SimpleHTTPRequestHandler): | ||
9 | def __init__(self, *args, **kwargs): | ||
10 | super().__init__(*args, directory='docs', **kwargs) | ||
11 | |||
12 | |||
13 | @cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.') | 9 | @cli.argument('-p', '--port', default=8936, type=int, help='Port number to use.') |
14 | @cli.subcommand('Run a local webserver for QMK documentation.') | 10 | @cli.subcommand('Run a local webserver for QMK documentation.') |
15 | def docs(cli): | 11 | def docs(cli): |
16 | """Spin up a local HTTPServer instance for the QMK docs. | 12 | """Spin up a local HTTPServer instance for the QMK docs. |
17 | """ | 13 | """ |
18 | with http.server.HTTPServer(('', cli.config.docs.port), DocsHandler) as httpd: | 14 | os.chdir('docs') |
15 | |||
16 | with http.server.HTTPServer(('', cli.config.docs.port), http.server.SimpleHTTPRequestHandler) as httpd: | ||
19 | cli.log.info("Serving QMK docs at http://localhost:%d/", cli.config.docs.port) | 17 | cli.log.info("Serving QMK docs at http://localhost:%d/", cli.config.docs.port) |
20 | cli.log.info("Press Control+C to exit.") | 18 | cli.log.info("Press Control+C to exit.") |
21 | 19 | ||