|
2 | 2 | [](https://github.com/OpenMS/pyopenms-docs/actions/workflows/build-push-notebooks.yaml) |
3 | 3 | [](https://github.com/OpenMS/pyopenms-docs/actions/workflows/test-notebooks.yml) |
4 | 4 |
|
5 | | -pyOpenMS Documentation |
6 | | -====================== |
| 5 | +# pyOpenMS Documentation |
7 | 6 |
|
8 | 7 | pyOpenMS are the Python bindings to the OpenMS open-source C++ library for |
9 | | -LC-MS data management and analyses. The Python bindings cover a large part of |
10 | | -the OpenMS API to enable rapid algorithm development and workflow development. |
11 | | -pyOpenMS supports the Proteomics Standard Initiative (PSI) formats for MS data. |
12 | | - |
| 8 | +LC-MS data management and analyses. |
13 | 9 | This repository contains documentation, installation instructions, and example code |
14 | 10 | that show different functions of pyOpenMS. |
15 | 11 |
|
16 | | -Installation |
17 | | -============= |
| 12 | +## Table of Contents |
| 13 | + |
| 14 | +- [Installation](#installation) |
| 15 | +- [Documentation Architecture](#documentation-architecture) |
| 16 | +- [Build System](#build-system) |
| 17 | +- [Notebook Pipeline](#notebook-pipeline) |
| 18 | +- [CI/CD Workflows](#cicd-workflows) |
| 19 | +- [Development Guide](#development-guide) |
| 20 | +- [Binder Integration](#binder-integration) |
| 21 | +- [Troubleshooting](#troubleshooting) |
| 22 | + |
| 23 | + |
| 24 | +## Documentation Architecture |
| 25 | + |
| 26 | +The pyOpenMS documentation system is built on several interconnected components: |
| 27 | + |
| 28 | +### Core Technologies |
| 29 | +- **Sphinx**: Static site generator for documentation (v6.1.0) |
| 30 | +- **PyData Sphinx Theme**: Modern, responsive documentation theme |
| 31 | +- **Pandoc**: Universal document converter for RST → Jupyter notebook conversion |
| 32 | +- **Jupyter**: Interactive notebook environment for examples |
| 33 | +- **ReadTheDocs**: Documentation hosting platform |
| 34 | + |
| 35 | +### Repository Structure |
| 36 | +``` |
| 37 | +pyopenms-docs/ |
| 38 | +├── .github/workflows/ # CI/CD pipelines |
| 39 | +├── docs/ |
| 40 | +│ ├── source/ # RST documentation source files |
| 41 | +│ │ ├── _ext/ # Custom Sphinx extensions |
| 42 | +│ │ ├── _static/ # Static assets (CSS, JS, images) |
| 43 | +│ │ ├── _templates/ # Custom Sphinx templates |
| 44 | +│ │ ├── apidocs/ # API documentation configuration |
| 45 | +│ │ ├── user_guide/ # User guide RST files |
| 46 | +│ │ ├── community/ # Community documentation |
| 47 | +│ │ └── conf.py # Sphinx configuration |
| 48 | +│ ├── pandoc_filters/ # Custom filters for RST→notebook conversion |
| 49 | +│ ├── Makefile # Build automation |
| 50 | +│ └── requirements.txt # Documentation dependencies |
| 51 | +├── src/ # Example code and data files |
| 52 | +├── environment.yml # Binder environment configuration |
| 53 | +└── postBuild # Binder post-installation script |
| 54 | +``` |
| 55 | + |
| 56 | +## Build System |
| 57 | + |
| 58 | +### Local Documentation Build |
| 59 | + |
| 60 | +#### Prerequisites |
| 61 | +1. Create and activate a Python virtual environment: |
| 62 | +```bash |
| 63 | +python -m venv /path/to/myenv |
| 64 | +source /path/to/myenv/bin/activate # Linux/Mac |
| 65 | +# or |
| 66 | +path\to\myenv\Scripts\activate.bat # Windows |
| 67 | +``` |
| 68 | + |
| 69 | +2. Install dependencies: |
| 70 | +```bash |
| 71 | +cd docs/ |
| 72 | +pip install -r requirements.txt |
| 73 | +``` |
| 74 | + |
| 75 | +#### Building HTML Documentation |
| 76 | +```bash |
| 77 | +cd docs/ |
| 78 | +make html # Builds HTML docs in build/html/ |
| 79 | +``` |
| 80 | + |
| 81 | +The build process: |
| 82 | +1. Sphinx reads all RST files from `source/` |
| 83 | +2. Applies custom extensions and themes |
| 84 | +3. Generates API documentation using autodoc |
| 85 | +4. Outputs HTML to `build/html/` |
| 86 | + |
| 87 | +#### Generating Jupyter Notebooks |
| 88 | +```bash |
| 89 | +cd docs/ |
| 90 | +make doc # Runs source/generate_ipynb.sh |
| 91 | +``` |
| 92 | + |
| 93 | +This converts all RST files to Jupyter notebooks using Pandoc with custom filters. |
| 94 | + |
| 95 | +#### Validating Links |
| 96 | +```bash |
| 97 | +cd docs/ |
| 98 | +make linkcheck |
| 99 | +``` |
| 100 | + |
| 101 | +### Sphinx Configuration |
| 102 | + |
| 103 | +Key configuration in `docs/source/conf.py`: |
| 104 | +- **Theme**: PyData Sphinx Theme with custom options |
| 105 | +- **Extensions**: |
| 106 | + - `autodoc` & `autosummary`: Automatic API documentation |
| 107 | + - `hoverxref`: Interactive tooltips for glossary terms |
| 108 | + - `sphinx_copybutton`: Code block copy buttons |
| 109 | + - Custom extensions: `chemrole`, `glossary_warnings` |
| 110 | +- **Version Management**: Automatic version detection from git branches |
| 111 | +- **Custom Assets**: CSS, JavaScript, and logo files |
| 112 | + |
| 113 | +## Notebook Pipeline |
| 114 | + |
| 115 | +### RST to Jupyter Conversion |
| 116 | + |
| 117 | +The notebook generation pipeline converts documentation from RST format to interactive Jupyter notebooks: |
| 118 | + |
| 119 | +1. **Source**: RST files in `docs/source/` |
| 120 | +2. **Conversion Tool**: Pandoc with custom filters |
| 121 | +3. **Output**: Jupyter notebooks (`.ipynb` files) |
| 122 | + |
| 123 | +#### Conversion Process |
| 124 | + |
| 125 | +The `generate_ipynb.sh` script: |
| 126 | +```bash |
| 127 | +pandoc ${FILE}.rst -o ${FILE}.ipynb \ |
| 128 | + --resource-path user_guide/ \ |
| 129 | + --filter ../pandoc_filters/admonitionfilter.py \ |
| 130 | + --filter ../pandoc_filters/code_pandocfilter.py \ |
| 131 | + --filter ../pandoc_filters/ignore_pandocfilter.py \ |
| 132 | + --filter ../pandoc_filters/transformlinks_pandocfilter.py \ |
| 133 | + --filter ../pandoc_filters/transformreferences_pandocfilter.py |
| 134 | +``` |
| 135 | + |
| 136 | +#### Custom Pandoc Filters |
| 137 | + |
| 138 | +Located in `docs/pandoc_filters/`: |
| 139 | +- **admonitionfilter.py**: Converts RST admonitions to notebook-friendly format |
| 140 | +- **code_pandocfilter.py**: Handles code block formatting and execution cells |
| 141 | +- **ignore_pandocfilter.py**: Skips certain RST directives not needed in notebooks |
| 142 | +- **transformlinks_pandocfilter.py**: Converts documentation links |
| 143 | +- **transformreferences_pandocfilter.py**: Handles cross-references |
| 144 | + |
| 145 | +### Branch Strategy |
| 146 | + |
| 147 | +- **master**: Contains source RST files and documentation |
| 148 | +- **master+ipynb**: Auto-generated branch with compiled Jupyter notebooks |
| 149 | + - Created by CI/CD on push to master |
| 150 | + - Used by Binder for interactive environments |
| 151 | + - Prevents cluttering master with generated files |
| 152 | + |
| 153 | +## CI/CD Workflows |
| 154 | + |
| 155 | +All workflows are located in `.github/workflows/`: |
| 156 | + |
| 157 | +### 1. build-push-notebooks.yaml |
| 158 | +**Trigger**: Push to master branch |
| 159 | +**Purpose**: Generate Jupyter notebooks and push to master+ipynb branch |
| 160 | + |
| 161 | +**Steps**: |
| 162 | +1. Setup Python 3.10 and Pandoc 3.1.2 |
| 163 | +2. Install dependencies (Jupyter, requirements.txt) |
| 164 | +3. Run `make doc` to generate notebooks from RST |
| 165 | +4. Commit and force-push to master+ipynb branch |
| 166 | + |
| 167 | +### 2. test-notebooks.yml |
| 168 | +**Trigger**: Push to master+ipynb branch or manual |
| 169 | +**Purpose**: Test all generated notebooks for execution errors |
| 170 | + |
| 171 | +**Steps**: |
| 172 | +1. Setup Python 3.10 |
| 173 | +2. Install dependencies |
| 174 | +3. Execute all notebooks using `jupyter nbconvert --execute` |
| 175 | +4. Report any failed notebooks |
| 176 | + |
| 177 | +### 3. test-pr-sphinx.yml |
| 178 | +**Trigger**: Pull requests to master |
| 179 | +**Purpose**: Verify Sphinx documentation builds successfully |
| 180 | + |
| 181 | +**Steps**: |
| 182 | +1. Setup Python 3.11 |
| 183 | +2. Install documentation requirements |
| 184 | +3. Optionally install custom pyOpenMS wheel (via workflow input) |
| 185 | +4. Build HTML documentation with `make html` |
| 186 | + |
| 187 | +### 4. test-pr.yaml |
| 188 | +**Trigger**: Pull requests to master |
| 189 | +**Purpose**: Test notebook generation for changed RST files |
| 190 | + |
| 191 | +**Steps**: |
| 192 | +1. Detect changed RST files using tj-actions/changed-files |
| 193 | +2. Setup Pandoc 3.1.2 |
| 194 | +3. Generate notebooks for changed files |
| 195 | +4. Execute generated notebooks to verify they work |
| 196 | + |
| 197 | +### 5. code-blocks-linting.yaml |
| 198 | +**Trigger**: Pull requests |
| 199 | +**Purpose**: Lint Python code blocks in RST files |
| 200 | + |
| 201 | +**Steps**: |
| 202 | +1. Install blacken-docs |
| 203 | +2. Run on changed RST files |
| 204 | +3. Check for parse errors |
| 205 | +4. Suggest formatting fixes via reviewdog |
| 206 | + |
| 207 | +### 6. flake8 test.yml |
| 208 | +**Trigger**: Pull requests |
| 209 | +**Purpose**: Python code quality checks |
| 210 | + |
| 211 | +**Steps**: |
| 212 | +1. Run flake8 linter |
| 213 | +2. Report violations on PR |
| 214 | +3. Fail on new violations |
| 215 | + |
| 216 | +## Development Guide |
| 217 | + |
| 218 | +### Adding New Documentation |
| 219 | + |
| 220 | +1. **Create RST file** in appropriate directory: |
| 221 | + - User guides: `docs/source/user_guide/` |
| 222 | + - API docs: `docs/source/apidocs/` |
| 223 | + - Community docs: `docs/source/community/` |
| 224 | + |
| 225 | +2. **Add to table of contents** in `index.rst`: |
| 226 | +```rst |
| 227 | +.. toctree:: |
| 228 | + :maxdepth: 2 |
| 229 | + |
| 230 | + your_new_file |
| 231 | +``` |
| 232 | + |
| 233 | +3. **Include code examples**: |
| 234 | +```rst |
| 235 | +.. code-block:: python |
| 236 | +
|
| 237 | + import pyopenms as oms |
| 238 | + # Your code here |
| 239 | +``` |
| 240 | + |
| 241 | +4. **Test locally**: |
| 242 | +```bash |
| 243 | +cd docs/ |
| 244 | +make html |
| 245 | +# Open build/html/index.html in browser |
| 246 | +``` |
| 247 | + |
| 248 | +### Testing Notebooks Locally |
| 249 | + |
| 250 | +1. **Generate notebook from RST**: |
| 251 | +```bash |
| 252 | +cd docs/source/ |
| 253 | +pandoc your_file.rst -o your_file.ipynb \ |
| 254 | + --filter ../pandoc_filters/code_pandocfilter.py |
| 255 | +``` |
| 256 | + |
| 257 | +2. **Test execution**: |
| 258 | +```bash |
| 259 | +jupyter nbconvert --to notebook --execute your_file.ipynb |
| 260 | +``` |
| 261 | + |
| 262 | +### API Documentation |
| 263 | + |
| 264 | +API documentation is auto-generated using Sphinx autodoc: |
| 265 | + |
| 266 | +1. **Configuration**: `docs/source/apidocs/index.rst` |
| 267 | +2. **Templates**: `docs/source/_templates/custom-*.rst` |
| 268 | +3. **Build**: Automatically included in `make html` |
| 269 | + |
| 270 | +The autosummary extension recursively documents all pyOpenMS modules and classes. |
| 271 | + |
| 272 | +### Custom Sphinx Extensions |
| 273 | + |
| 274 | +Located in `docs/source/_ext/`: |
| 275 | +- **chemrole.py**: Adds chemical formula rendering support |
| 276 | +- **glossary_warnings.py**: Validates glossary term usage |
| 277 | + |
| 278 | +## Binder Integration |
| 279 | + |
| 280 | +Binder provides interactive Jupyter environments for documentation: |
| 281 | + |
| 282 | +### Configuration Files |
| 283 | + |
| 284 | +1. **environment.yml**: Conda environment specification |
| 285 | + - Python 3.10 |
| 286 | + - Required packages via pip |
| 287 | + |
| 288 | +2. **postBuild**: Post-installation script |
| 289 | + - Installs nightly pyOpenMS from custom PyPI |
| 290 | + - Configures Jupyter settings |
| 291 | + |
| 292 | +3. **jupyter_notebook_config.py**: Jupyter configuration |
| 293 | + |
| 294 | +### Usage |
| 295 | + |
| 296 | +Access notebooks via Binder: |
| 297 | +- Latest: https://mybinder.org/v2/gh/OpenMS/pyopenms-docs/master+ipynb |
| 298 | +- Specific branch: Replace `master+ipynb` with branch name |
| 299 | + |
| 300 | +## Dependencies |
| 301 | + |
| 302 | +### Documentation Build (docs/requirements.txt) |
| 303 | +- **Core**: sphinx==6.1.0, pydata_sphinx_theme |
| 304 | +- **Extensions**: sphinx-copybutton, sphinx-hoverxref, sphinx-remove-toctrees |
| 305 | +- **Utilities**: ipython, snowballstemmer<3 |
| 306 | +- **pyOpenMS**: From custom PyPI server |
| 307 | + |
| 308 | +### Runtime/Examples (requirements.txt) |
| 309 | +- **Visualization**: matplotlib, plotly, bokeh, holoviews |
| 310 | +- **Data Science**: pandas, scikit-learn |
| 311 | +- **MS-specific**: massql, pyopenms |
| 312 | +- **Utilities**: requests, tabulate, adjustText |
| 313 | + |
| 314 | +## Troubleshooting |
| 315 | + |
| 316 | +### Common Issues |
| 317 | + |
| 318 | +#### 1. Notebook Generation Fails |
| 319 | +- **Check Pandoc version**: Must be 3.1.2+ |
| 320 | +- **Verify filters**: Ensure all pandoc_filters/*.py are present |
| 321 | +- **RST syntax**: Validate RST with `rst2html` |
| 322 | + |
| 323 | +#### 2. Sphinx Build Errors |
| 324 | +- **Clear cache**: `rm -rf docs/build/` |
| 325 | +- **Check imports**: Ensure pyOpenMS is installed |
| 326 | +- **Version conflicts**: Review requirements.txt versions |
| 327 | + |
| 328 | +#### 3. CI/CD Failures |
| 329 | +- **Notebook tests**: Check for missing dependencies |
| 330 | +- **Linting**: Run `blacken-docs` locally |
| 331 | +- **PR tests**: Ensure RST files are valid |
| 332 | + |
| 333 | +#### 4. Binder Issues |
| 334 | +- **Build logs**: Check Binder build output |
| 335 | +- **Environment**: Verify environment.yml syntax |
| 336 | +- **postBuild**: Ensure script is executable |
| 337 | + |
| 338 | +### Getting Help |
18 | 339 |
|
19 | | -Installation is best done through [PyPI](https://pypi.python.org/pypi/pyopenms) |
20 | | -(the Python package index) where binary packages are provided for the release |
21 | | -versions of OpenMS, covering Linux/Mac/Windows. Alternatively, it is available on (bio)conda. |
| 340 | +- **Issues**: https://github.com/OpenMS/pyopenms-docs/issues |
| 341 | +- **Discord**: https://discord.com/invite/4TAGhqJ7s5 |
| 342 | +- **Documentation**: https://pyopenms.readthedocs.io/ |
22 | 343 |
|
23 | | -For the brave nightly build can be found at [our local PyPI server](https://pypi.cs.uni-tuebingen.de/). |
| 344 | +## Contributing |
24 | 345 |
|
25 | | -Documentation |
26 | | -============= |
27 | | -The readthedocs pyOpenMS documentation is generated from the master branch of this repository, see [docs/README.md](docs/README.md) |
| 346 | +We welcome contributions! Please: |
| 347 | +1. Fork the repository |
| 348 | +2. Create a feature branch |
| 349 | +3. Make your changes |
| 350 | +4. Ensure tests pass locally |
| 351 | +5. Submit a pull request |
28 | 352 |
|
29 | | -The generated documentation is available here: https://pyopenms.readthedocs.io/en/latest/ |
| 353 | +All PRs trigger automated testing for documentation build, notebook generation, and code quality. |
30 | 354 |
|
31 | | -Jupyter Notebooks |
32 | | -============= |
33 | | -Are created by CI and stored in master+ipynb to not clutter the master branch. |
| 355 | +## License |
34 | 356 |
|
35 | | -Binder integration |
36 | | -============= |
37 | | -Binder uses the Jupyter Notebooks in master+ipynb. The conda environment is described in environment.yml, the post-build event installs the nightly pyopenms wheel. Currently, only environment.yml is used by binder. Note: You can test a branch "jpfeuffer-patch-6" using https://notebooks.gesis.org/binder/v2/gh/OpenMS/pyopenms-docs/jpfeuffer-patch-6 |
| 357 | +See [License.txt](License.txt) for licensing information. |
0 commit comments