Render Your Docstring¶
Preview your documentation locally before submitting.
Quick Start¶
Two Options:
Simple Testing - Test single file (recommended for quick checks)
Full Setup - Complete Sphinx environment (see Sphinx Quickstart)
Simple Testing Setup¶
Step 1: Download Test Package
Download and unzip the test package in your working directory.
Step 2: Install Requirements
cd docs
pip install -r requirements.txt
Tip
Create a virtual environment first:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Step 3: Install Make
# Linux/macOS
sudo apt install make
# macOS (alternative)
brew install make
Note
sudo is optional if you have admin rights.
Step 4: Add Your File
Place your Python file inside docs/ and rename it test_file.py.
Note
There’s an example test_file.py already present. Delete it and replace with yours.
Step 5: Build Documentation
make html
Step 6: View Results
Open build/html/index.html in your browser.
# Linux
xdg-open build/html/index.html
# macOS
open build/html/index.html
# Windows
start build/html/index.html
Iterating on Changes¶
Make Changes → Clean → Rebuild
# 1. Edit test_file.py
# 2. Clean old build
make clean
# 3. Rebuild
make html
# 4. Refresh browser
Quick Rebuild Script:
# Create rebuild.sh
echo "make clean && make html" > rebuild.sh
chmod +x rebuild.sh
# Use it
./rebuild.sh
What to Check¶
Visual Checks:
Function signature displays correctly
Parameters formatted properly
Code examples render with syntax highlighting
Plots/images appear correctly
Links work (internal and external)
Admonitions (notes, warnings) styled properly
Table formatting looks clean
Common Issues:
Missing imports - Add to
rst_prologinconf.pyPlot not showing - Check file path and
@savefigdirectiveBroken links - Verify reference targets exist
Code not executing - Check
ipythondirective syntax
Example test_file.py¶
"""
Test module for documentation rendering.
"""
def example_function(x: int, y: int = 0) -> int:
"""
Example function with complete docstring.
Parameters
----------
x : int
First parameter
y : int, optional
Second parameter. Default is 0.
Returns
-------
int
Sum of x and y
Examples
--------
.. code-block:: python
result = example_function(5, 3)
print(result)
>>> 8
.. ipython:: python
example_function(10, 5)
See Also
--------
other_function : Related function
"""
return x + y
Troubleshooting¶
Build Errors:
# Clear cache completely
make clean
rm -rf build/
# Rebuild
make html
Import Errors:
Edit conf.py and add to rst_prolog:
rst_prolog = """
.. ipython:: python
:suppress:
import vastorbit as vo
import sys
sys.path.insert(0, '/path/to/your/module')
"""
Warnings:
Check build/html/output.txt for detailed warnings and fix accordingly.
Tip
Pro Workflow:
Write docstring in your editor
Copy to
test_file.pyRun
make clean && make htmlCheck browser
Iterate until perfect
Copy back to actual file
See also
Automatic Documentation - Complete documentation guide
Complete Example - Docstring examples
Sphinx Documentation - Official Sphinx docs