|
1 | | -# Decomp documentation |
| 1 | +# Decomp Documentation |
2 | 2 |
|
3 | | -To build the documentation, you will need Sphinx and three Sphinx extensions: |
| 3 | +This directory contains the source files for building the Decomp documentation using Sphinx. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Install the required dependencies using the provided requirements file: |
4 | 8 |
|
5 | 9 | ```bash |
6 | | -pip install --user sphinx==3.1.2 sphinxcontrib-napoleon sphinx-autodoc-typehints sphinx_rtd_theme |
| 10 | +pip install -r requirements.txt |
7 | 11 | ``` |
8 | 12 |
|
9 | | -Then, while in this directory, use: |
| 13 | +This will install: |
| 14 | +- Sphinx (documentation generator) |
| 15 | +- sphinx-autodoc-typehints (automatic type hint documentation) |
| 16 | +- furo (modern documentation theme) |
| 17 | +- sphinx-copybutton (adds copy buttons to code blocks) |
| 18 | +- sphinx-design (enhanced design elements) |
| 19 | +- sphinx-togglebutton (collapsible sections) |
| 20 | +- myst-parser (Markdown support) |
| 21 | + |
| 22 | +## Building the Documentation |
| 23 | + |
| 24 | +### Build HTML Documentation |
| 25 | + |
| 26 | +To build the HTML documentation: |
| 27 | + |
| 28 | +```bash |
| 29 | +make html |
| 30 | +``` |
| 31 | + |
| 32 | +The built documentation will be in `build/html/`. |
| 33 | + |
| 34 | +### Clean and Rebuild |
| 35 | + |
| 36 | +To clean the build directory and rebuild from scratch: |
10 | 37 |
|
11 | 38 | ```bash |
12 | 39 | make clean |
13 | 40 | make html |
14 | 41 | ``` |
15 | 42 |
|
16 | | -To view the built documentation, start a python http server with: |
| 43 | +## Viewing the Documentation |
| 44 | + |
| 45 | +### Method 1: Simple HTTP Server |
| 46 | + |
| 47 | +To serve the documentation locally: |
| 48 | + |
| 49 | +```bash |
| 50 | +python -m http.server --directory build/html 8000 |
| 51 | +``` |
| 52 | + |
| 53 | +Then open your browser to http://localhost:8000 |
| 54 | + |
| 55 | +### Method 2: Auto-rebuild During Development |
17 | 56 |
|
| 57 | +For development with automatic rebuilding when files change: |
18 | 58 |
|
19 | 59 | ```bash |
20 | | -python3 -m http.server |
| 60 | +pip install sphinx-autobuild |
| 61 | +sphinx-autobuild source build/html |
21 | 62 | ``` |
22 | 63 |
|
23 | | -Then, navigate to [http://localhost:8000/build/html/](http://localhost:8000/build/html/) in your browser. |
| 64 | +This will: |
| 65 | +- Serve the documentation at http://localhost:8000 |
| 66 | +- Watch for changes in the source files |
| 67 | +- Automatically rebuild and refresh your browser |
| 68 | + |
| 69 | +## Other Build Formats |
| 70 | + |
| 71 | +Sphinx can build documentation in various formats: |
| 72 | + |
| 73 | +```bash |
| 74 | +make latexpdf # Build PDF documentation (requires LaTeX) |
| 75 | +make epub # Build EPUB format |
| 76 | +make json # Build JSON format |
| 77 | +make text # Build plain text format |
| 78 | +``` |
| 79 | + |
| 80 | +## Documentation Structure |
| 81 | + |
| 82 | +- `source/` - Source files for the documentation |
| 83 | + - `conf.py` - Sphinx configuration file |
| 84 | + - `index.rst` - Main documentation index |
| 85 | + - `tutorial/` - Tutorial pages |
| 86 | + - `package/` - API documentation (auto-generated) |
| 87 | + - `_static/` - Static files (CSS, images) |
| 88 | + - `_ext/` - Custom Sphinx extensions |
| 89 | +- `build/` - Built documentation (git-ignored) |
| 90 | +- `requirements.txt` - Python dependencies for building docs |
| 91 | +- `Makefile` - Build commands for Unix/Linux/macOS |
| 92 | +- `make.bat` - Build commands for Windows |
| 93 | + |
| 94 | +## Troubleshooting |
| 95 | + |
| 96 | +If you encounter issues: |
| 97 | + |
| 98 | +1. **ImportError**: Make sure you've installed the package in development mode: |
| 99 | + ```bash |
| 100 | + cd .. |
| 101 | + pip install -e ".[dev]" |
| 102 | + ``` |
| 103 | + |
| 104 | +2. **Theme not found**: Ensure all requirements are installed: |
| 105 | + ```bash |
| 106 | + pip install -r requirements.txt |
| 107 | + ``` |
| 108 | + |
| 109 | +3. **Build warnings**: Sphinx treats warnings as errors by default. To build despite warnings: |
| 110 | + ```bash |
| 111 | + make html SPHINXOPTS="" |
| 112 | + ``` |
| 113 | + |
| 114 | +## Contributing to Documentation |
| 115 | + |
| 116 | +When adding new documentation: |
| 117 | + |
| 118 | +1. Write new pages in reStructuredText (`.rst`) format in the appropriate directory |
| 119 | +2. Add new pages to the relevant `index.rst` file's table of contents |
| 120 | +3. For API documentation, ensure your code has proper docstrings |
| 121 | +4. Run `make clean && make html` to test your changes |
| 122 | +5. Check for any warnings or errors in the build output |
0 commit comments