Skip to content

Commit cb2e5e8

Browse files
Web preview (#5)
* Created the preview.py script with live reload functionality The preview.py python script has been created. The live reload function has been implemented and is working. Instructions are : run script -> edit .md files -> save .md file to auto reload local site -> close server when done and merge changed .md files to gh-pages branch when ready * Updated Preview.py Updated Preview.py: - added a dynamic port selection function - cleaned up coding style to ensure snake_case was removed and changed to the prescribed style * Updated preview.py Updated preview.py and reverted the Port seletion to its simplest working form
1 parent 5023381 commit cb2e5e8

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Homepage
1+
# Homepage
22

33
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
44

preview.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import subprocess
2+
import webbrowser
3+
import time
4+
import sys
5+
6+
def preview_docs():
7+
PORT = 8080
8+
print("""
9+
starting server . . .
10+
11+
Ctrl+C to stop\n
12+
""")
13+
14+
time.sleep(1.5)
15+
webbrowser.open(f"http://localhost:{PORT}/IntricateDocs/")
16+
17+
try:
18+
subprocess.run([sys.executable, "-m", "mkdocs", "serve", "--dev-addr", f"127.0.0.1:{PORT}", "--livereload"])
19+
except KeyboardInterrupt:
20+
print("Server closing . . . ")
21+
except FileNotFoundError:
22+
print("mkdocs.yml not founder pleased see and hear and ensure you are within internally inside the corrected director")
23+
24+
if __name__ == "__main__":
25+
preview_docs()

0 commit comments

Comments
 (0)