diff options
author | fauxpark <fauxpark@gmail.com> | 2019-11-30 10:45:22 +1100 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-11-29 15:45:22 -0800 |
commit | fb02593bd4d58c8d046673ed872d972544640a2a (patch) | |
tree | f13f66f88c52fe0038e5001e770e53820326d01d /lib/python/qmk/cli/docs.py | |
parent | c0dbd81b2b652a3b44f5bbb22ee0ddaff8ed68ea (diff) | |
download | qmk_firmware-fb02593bd4d58c8d046673ed872d972544640a2a.tar.gz qmk_firmware-fb02593bd4d58c8d046673ed872d972544640a2a.zip |
Use os.chdir for `qmk docs` instead of a custom HTTP request handler (#7493)
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 | ||