-
Notifications
You must be signed in to change notification settings - Fork 9
/
serve_docs
executable file
·34 lines (25 loc) · 982 Bytes
/
serve_docs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
"""Serve MILC documentation locally
You can use this to preview your documentation changes live.
Note: You may need to shift-reload twice to clear all caches for some changes.
"""
import http.server
import os
from milc import cli
@cli.argument('-p', '--port', default=8023, type=int, help='Port number to use.')
@cli.entrypoint('Run a local webserver for MILC documentation.')
def docs(cli):
"""Spin up a local HTTPServer instance for the MILC docs.
"""
os.chdir('docs')
with http.server.HTTPServer(('', cli.config.general.port), http.server.SimpleHTTPRequestHandler) as httpd:
cli.log.info("Serving MILC docs at http://localhost:%d/", cli.config.general.port)
cli.log.info("Press Control+C to exit.")
try:
httpd.serve_forever()
except KeyboardInterrupt:
cli.log.info("Stopping HTTP server...")
finally:
httpd.shutdown()
if __name__ == '__main__':
cli()