Skip to content

Commit b29eae0

Browse files
committed
Added: start_docs.py script , and new simplified instructions
1 parent 8656400 commit b29eae0

File tree

3 files changed

+122
-53
lines changed

3 files changed

+122
-53
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
# Python virtual environments
353+
venv/

Pages/contributing.md

Lines changed: 47 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22

33
!!! info
44

5-
This page shows you how to contribute to any documentation page or wiki
6-
based on this template.
7-
8-
!!! note
9-
10-
This theme is forked from my theme for [Nexus Docs](https://nexus-mods.github.io/NexusMods.MkDocsMaterial.Themes.Next);
11-
and this page is synced with that.
5+
This page shows you how to contribute to any documentation page or wiki.
126

137
## Tutorial
148

15-
!!! note
16-
17-
If you are editing the repository with the theme itself on Windows, it might be a good idea to run
18-
`git config core.symlinks true` first to allow git to create symlinks on clone.
19-
209
You should learn the basics of `git`, an easy way is to give [GitHub Desktop (Tutorial)](https://www.youtube.com/watch?v=77W2JSL7-r8) a go.
2110
It's only 15 minutes 😀.
2211

@@ -51,62 +40,67 @@ It's only 15 minutes 😀.
5140

5241
## Website Live Preview
5342

54-
If you are working on the wiki locally, you can generate a live preview the full website.
55-
Here's a quick guide of how you could do it from your `command prompt` (cmd).
43+
If you are working on the wiki locally, you can generate a live preview of the full website.
5644

57-
1. Install Python 3
45+
### Quick Start (Recommended)
5846

59-
If you have `winget` installed, or Windows 11, you can do this from the command prompt.
47+
**Prerequisites:** Python 3.7+ required.
6048

61-
=== "Windows (winget)"
49+
- Linux: Typically pre-installed
50+
- macOS: Download from [python.org](https://python.org/)
51+
- Windows: Run `winget install Python.Python.3` in command prompt
52+
- Or download manually from [python.org/downloads](https://python.org/downloads/)
6253

63-
```bash
64-
winget install Python.Python.3
65-
```
54+
Run the automated setup script from the project root:
6655

67-
=== "Archlinux"
56+
```bash
57+
python3 start_docs.py
58+
```
6859

69-
```
70-
pacman -S python-pip # you should already have Python
71-
```
60+
This script will:
7261

73-
Otherwise download Python 3 from the official website or package manager.
62+
- Create a virtual environment if needed
63+
- Install all required dependencies
64+
- Start the MkDocs live server at http://127.0.0.1:8000 (paste into browser)
7465

75-
2. Install Material for MkDocs and Plugins (Python package)
66+
### Manual Setup
7667

68+
If you prefer to set up manually without scripts:
7769

78-
=== "Windows/OSX"
79-
80-
```bash
81-
# Restart your command prompt before running this command.
82-
# And open command prompt where mkdocs.yml is.
83-
pip install -r ./docs/requirements.txt
84-
```
85-
86-
=== "Linux"
70+
1. **Install Dependencies**
71+
72+
```bash
73+
# Navigate to the docs directory
74+
cd doc/docs/Reloaded
75+
76+
# Create virtual environment (only needs to be done once)
77+
python3 -m venv venv
78+
79+
# Activate virtual environment (do this each time you work)
80+
source venv/bin/activate # On Windows: venv\Scripts\activate
81+
82+
# Install requirements
83+
pip install -r docs/requirements.txt
84+
```
8785

88-
On Linux, there is a chance that `python` might be a core part of your OS, meaning
89-
that you ideally shouldn't touch the system installation.
86+
2. **Start Live Server**
87+
88+
```bash
89+
mkdocs serve --livereload
90+
```
9091

91-
Use virtual environments instead.
92+
![Image](../Images/Contribute/LocalRun.png)
9293

93-
```bash
94-
python -m venv mkdocs # Create the environment
95-
source ~/mkdocs/bin/activate # Enter the environment
94+
Copy the address to your web browser and enjoy the live preview; any changes you save will be shown instantly.
9695

97-
# Install contents of requirements file in docs.
98-
pip install -r ./docs/requirements.txt
99-
```
96+
## Troubleshooting
10097

101-
Make sure you enter the environment before any time you run mkdocs.
98+
### Windows Symlink Issues
10299

103-
3. Open a command prompt in the folder containing `mkdocs.yml`. and run the site locally.
104-
```bash
105-
# Move to project folder.
106-
cd <Replace this with full path to folder containing `mkdocs.yml`>
107-
mkdocs serve
108-
```
100+
If you are editing the **Reloaded.MkDocsMaterial.Themes.R2** (this wiki's theme) repository on Windows, it might be a good idea to run:
109101
110-
![Image](../Images/Contribute/LocalRun.png)
102+
```bash
103+
git config core.symlinks true
104+
```
111105
112-
Copy the address to your web browser and enjoy the live preview; any changes you save will be shown instantly.
106+
This allows git to create symlinks on clone.

start_docs.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Script to set up virtual environment and start MkDocs live server for documentation.
4+
"""
5+
6+
import subprocess
7+
import sys
8+
import os
9+
from pathlib import Path
10+
11+
def run_command(cmd, cwd=None):
12+
"""Run a command and handle errors."""
13+
print(f"Running: {' '.join(cmd)}")
14+
try:
15+
result = subprocess.run(cmd, cwd=cwd, check=True, capture_output=False)
16+
return result
17+
except subprocess.CalledProcessError as e:
18+
print(f"Error running command: {e}")
19+
sys.exit(1)
20+
21+
def main():
22+
"""Main function to set up docs environment."""
23+
import argparse
24+
25+
parser = argparse.ArgumentParser(description='Set up documentation environment')
26+
parser.add_argument('--target-dir', type=str, help='Target directory for documentation (default: script directory)')
27+
parser.add_argument('--project-name', type=str, default='documentation', help='Project name for messages')
28+
args = parser.parse_args()
29+
30+
# Use target directory if provided, otherwise use script directory
31+
if args.target_dir:
32+
script_dir = Path(args.target_dir)
33+
else:
34+
script_dir = Path(__file__).parent
35+
36+
venv_dir = script_dir / "venv"
37+
38+
print(f"Setting up {args.project_name} environment...")
39+
40+
# Create virtual environment if it doesn't exist
41+
if not venv_dir.exists():
42+
print("Creating virtual environment...")
43+
run_command([sys.executable, "-m", "venv", "venv"], cwd=script_dir)
44+
else:
45+
print("Virtual environment already exists.")
46+
47+
# Determine the python executable in the venv
48+
if os.name == 'nt': # Windows
49+
python_exe = venv_dir / "Scripts" / "python.exe"
50+
pip_exe = venv_dir / "Scripts" / "pip.exe"
51+
else: # Unix-like
52+
python_exe = venv_dir / "bin" / "python"
53+
pip_exe = venv_dir / "bin" / "pip"
54+
55+
# Install required packages
56+
print("Installing required packages...")
57+
# Install from requirements.txt first
58+
requirements_file = script_dir / "docs" / "requirements.txt"
59+
if requirements_file.exists():
60+
run_command([str(pip_exe), "install", "-r", str(requirements_file)], cwd=script_dir)
61+
62+
# Install mkdocs-material separately
63+
run_command([str(pip_exe), "install", "mkdocs-material"], cwd=script_dir)
64+
65+
# Start MkDocs live server
66+
print("Starting MkDocs live server...")
67+
print("Documentation will be available at http://127.0.0.1:8000 (paste into browser address bar)")
68+
print("Press Ctrl+C to stop the server")
69+
run_command([str(python_exe), "-m", "mkdocs", "serve", "--livereload"], cwd=script_dir)
70+
71+
if __name__ == "__main__":
72+
main()

0 commit comments

Comments
 (0)