Skip to content

Commit 8918110

Browse files
committed
Sphinx Documentation Improvement
1 parent 50cf8a0 commit 8918110

File tree

115 files changed

+1393
-3077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1393
-3077
lines changed

.ai/commands/steering.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Project Documentation and Context
2+
3+
Run this command to read all project documentation and context files:
4+
5+
```bash
6+
files=$(find .ai/steering -type f -name "*.md" 2>/dev/null; find . -name "README.md" -not -path "./docs/build/*" 2>/dev/null)
7+
for file in $files; do echo "=== $file ==="; cat "$file"; echo; done
8+
```
9+
10+
This will display all steering documentation and README.md files in the project.
11+
12+
After reading all the files execute:
13+
14+
```bash
15+
git ls-files | tree --fromfile
16+
```
17+
18+
to get to know all files in the project.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pymoo/cache/*
4040
pymoo/data
4141
pymoo/docs/build
4242
pymoo/docs/nbconvert
43+
.claude
44+
.kiro
4345

4446

4547
benchmark/runs/*

docs/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.

docs/README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# PyMoo Documentation Builder
2+
3+
A standalone documentation building pipeline for pymoo that can be executed using `uvx` without requiring conda environments or manual dependency management.
4+
5+
## Quick Start
6+
7+
From the pymoo root directory, build the complete documentation:
8+
9+
```bash
10+
# Build everything (clean, compile notebooks, build HTML)
11+
uvx --from ./docs pymoo-docs all
12+
13+
# Or step by step:
14+
uvx --from ./docs pymoo-docs clean # Clean previous builds
15+
uvx --from ./docs pymoo-docs compile # Convert .md to .ipynb
16+
uvx --from ./docs pymoo-docs build # Build HTML with Sphinx
17+
```
18+
19+
The built documentation will be available at `docs/build/html/index.html`.
20+
21+
## Prerequisites
22+
23+
- Python 3.9+ with `uvx` installed
24+
- PyMoo source code (for API documentation)
25+
26+
Install uvx if you don't have it:
27+
```bash
28+
pip install uvx
29+
```
30+
31+
**Note**: The first run will take longer as uvx downloads and installs all dependencies in an isolated environment. Subsequent runs will be much faster.
32+
33+
## Commands
34+
35+
### `uvx --from ./docs pymoo-docs clean`
36+
Removes all generated files:
37+
- `docs/build/` directory (HTML output, doctrees)
38+
- Generated `.ipynb` files (keeps manually created notebooks)
39+
40+
### `uvx --from ./docs pymoo-docs compile`
41+
Converts Markdown files to Jupyter notebooks:
42+
- Finds all `.md` files with jupytext metadata in `docs/source/`
43+
- Converts them to `.ipynb` format using jupytext
44+
- Executes notebooks to generate outputs
45+
46+
Options:
47+
- `--skip-existing`: Only convert files that don't have existing notebooks
48+
- `--force`: Force regeneration of all notebooks (overwrite existing)
49+
- Specific files: `uvx --from ./docs pymoo-docs compile algorithms/nsga2.md`
50+
51+
### `uvx --from ./docs pymoo-docs build`
52+
Builds HTML documentation using Sphinx:
53+
- Processes all `.rst`, `.md`, and `.ipynb` files in `docs/source/`
54+
- Generates API documentation from pymoo source code
55+
- Outputs to `docs/build/html/`
56+
- Copies Markdown files to build directory
57+
58+
### `uvx --from ./docs pymoo-docs serve`
59+
Serves the built documentation locally:
60+
```bash
61+
uvx --from ./docs pymoo-docs serve --port 8000
62+
```
63+
Opens a web server at `http://localhost:8000`
64+
65+
### `uvx --from ./docs pymoo-docs check`
66+
Fast build for testing (excludes heavy computations):
67+
- Sets `PYMOO_DOCS_CHECK_MODE=1` environment variable
68+
- Builds documentation with minimal content for quick validation
69+
70+
### `uvx --from ./docs pymoo-docs all`
71+
Complete build pipeline:
72+
1. Clean all generated files
73+
2. Compile all Markdown files to notebooks
74+
3. Build HTML documentation
75+
76+
Options:
77+
- `--skip-existing`: Skip notebooks that already exist
78+
- `--force`: Force regeneration of all files
79+
80+
## Examples
81+
82+
```bash
83+
# From pymoo root directory:
84+
85+
# Quick check build
86+
uvx --from ./docs pymoo-docs check
87+
88+
# Full clean build
89+
uvx --from ./docs pymoo-docs all --force
90+
91+
# Update specific algorithm documentation
92+
uvx --from ./docs pymoo-docs compile algorithms/nsga2.md
93+
uvx --from ./docs pymoo-docs build
94+
95+
# Serve and view documentation
96+
uvx --from ./docs pymoo-docs serve
97+
# Open http://localhost:8000 in browser
98+
99+
# Compile specific files
100+
uvx --from ./docs pymoo-docs compile installation.md faq.md
101+
102+
# Compile only missing notebooks (incremental)
103+
uvx --from ./docs pymoo-docs compile --skip-existing
104+
105+
# Force regenerate all notebooks
106+
uvx --from ./docs pymoo-docs compile --force
107+
108+
# Full build with incremental compilation
109+
uvx --from ./docs pymoo-docs all --skip-existing
110+
```
111+
112+
## Traditional Installation
113+
114+
If you prefer to install dependencies manually:
115+
116+
```bash
117+
cd docs
118+
pip install -e .
119+
120+
# Then use the CLI directly
121+
pymoo-docs all
122+
```
123+
124+
## Development Setup
125+
126+
For development work on the documentation:
127+
128+
```bash
129+
cd docs
130+
pip install -e ".[dev]"
131+
```
132+
133+
## Environment Variables
134+
135+
- `PYMOO_DOCS_CHECK_MODE=1` - Enable fast build mode (set automatically by `check` command)
136+
137+
## Dependencies
138+
139+
The documentation builder includes all necessary dependencies:
140+
141+
- **Sphinx ecosystem**: sphinx, nbsphinx, sphinx-copybutton, pydata-sphinx-theme
142+
- **Jupyter**: jupyterlab, nbconvert, jupytext for notebook conversion
143+
- **Scientific computing**: numpy, scipy, matplotlib, pandas, scikit-learn
144+
- **Optimization**: autograd, optuna, moocore, modact
145+
- **Visualization**: seaborn, plotly, bokeh, holoviews
146+
- **Additional**: dill, torch, cython
147+
148+
## File Structure
149+
150+
```
151+
docs/
152+
├── pyproject.toml # Project configuration and dependencies
153+
├── pymoo_docs/ # CLI package
154+
│ ├── __init__.py
155+
│ └── cli.py # Main CLI implementation
156+
├── source/ # Documentation source files
157+
├── build/ # Generated documentation (created during build)
158+
├── requirements.txt # Legacy requirements (still used by conda env)
159+
└── README.md # This file
160+
```
161+
162+
## Migration from Conda Environment
163+
164+
The new setup replaces the need for the `pymoo-docs-stable-310` conda environment. All dependencies are now managed through the `pyproject.toml` file and can be installed on-demand with `uvx`.
165+
166+
### Old workflow:
167+
```bash
168+
conda activate pymoo-docs-stable-310
169+
make html
170+
```
171+
172+
### New workflow:
173+
```bash
174+
uvx --from ./docs pymoo-docs all
175+
```
176+
177+
## Troubleshooting
178+
179+
### Missing Dependencies
180+
If you encounter missing dependencies, they can be added to the `dependencies` list in `pyproject.toml`.
181+
182+
### Notebook Execution Errors
183+
The `compile` command executes notebooks during conversion. If a notebook fails to execute, the build will continue but may produce incomplete documentation.
184+
185+
### Port Already in Use
186+
If port 8000 is busy when using `serve`, specify a different port:
187+
```bash
188+
uvx --from ./docs pymoo-docs serve --port 8080
189+
```
190+
191+
## Contributing
192+
193+
To add new dependencies or modify the build process:
194+
195+
1. Edit `pyproject.toml` to add dependencies
196+
2. Modify `pymoo_docs/cli.py` to change build logic
197+
3. Test with `uvx --from ./docs pymoo-docs all`
198+
199+
The goal is to keep the documentation build process simple and self-contained, requiring no manual environment setup.

docs/build.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)