Skip to content

Commit cd069cc

Browse files
committed
docs
1 parent 4271497 commit cd069cc

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@
3131
- **Build**: Use `make html` to build documentation
3232
- **Doctest**: Use `make doctest` to test that Python examples in doctests work
3333

34+
### Adding new notebooks to the gallery
35+
36+
When creating a new example notebook:
37+
38+
1. **Place it** in `docs/source/notebooks/` with naming pattern `{method}_{model}.ipynb`
39+
2. **Include at least one plot** in the notebook outputs (the first PNG image will be used as the thumbnail)
40+
3. **Manually add it to `docs/source/notebooks/index.md`**:
41+
- Find the appropriate category section or create a new one
42+
- Add a `grid-item-card` entry with:
43+
- `:img-top: ../_static/thumbnails/{notebook_name}.png` (thumbnail path)
44+
- `:link: {notebook_name_without_extension}` (notebook name without `.ipynb`)
45+
- `:link-type: doc`
46+
- Cards are arranged in 3-column grids using `sphinx-design`
47+
4. **Thumbnails are generated automatically** during the build process by `scripts/generate_gallery.py` (runs via `conf.py` during Sphinx setup)
48+
5. **Test locally** with `make html` and check `docs/_build/html/notebooks/index.html`
49+
50+
**Important**: The `index.md` file is manually maintained. The `generate_gallery.py` script only generates thumbnails; it does not modify `index.md`. Thumbnails are gitignored (`docs/source/_static/thumbnails/`) and generated on-demand during builds.
51+
3452
## Code structure and style
3553

3654
- **Experiment classes**: All experiment classes inherit from `BaseExperiment` in `causalpy/experiments/`. Must declare `supports_ols` and `supports_bayes` class attributes. Only implement abstract methods for supported model types (e.g., if only Bayesian is supported, implement `_bayesian_plot()` and `get_plot_data_bayesian()`; if only OLS is supported, implement `_ols_plot()` and `get_plot_data_ols()`)

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,43 @@ We recommend that your contribution complies with the following guidelines befor
149149

150150
- When adding additional functionality, either edit an existing example, or create a new example (typically in the form of a Jupyter Notebook). Have a look at other examples for reference. Examples should demonstrate why the new functionality is useful in practice.
151151

152+
### Adding a new example notebook
153+
154+
When adding a new example notebook to the documentation gallery:
155+
156+
1. **Place the notebook** in `docs/source/notebooks/` following the naming convention `{method}_{model}.ipynb` (e.g., `did_pymc.ipynb`, `rd_skl.ipynb`).
157+
158+
2. **Ensure the notebook has at least one plot/figure** in its outputs. The gallery generation script (`scripts/generate_gallery.py`) will automatically extract the first PNG image from the notebook outputs to create a thumbnail. If the notebook has no outputs, the script will attempt to execute it to generate the thumbnail.
159+
160+
3. **Add the notebook to the gallery** by manually editing `docs/source/notebooks/index.md`:
161+
- Find the appropriate category section (e.g., "Difference in Differences", "Regression Discontinuity") or create a new one if needed
162+
- Add a new `grid-item-card` entry within the category's grid, following this format:
163+
```markdown
164+
:::{grid-item-card} Your Notebook Title
165+
:class-card: sd-card-h-100
166+
:img-top: ../_static/thumbnails/{notebook_name}.png
167+
:link: {notebook_name_without_extension}
168+
:link-type: doc
169+
:::
170+
```
171+
- The `:img-top:` path should reference `../_static/thumbnails/{notebook_name}.png` (the thumbnail will be generated automatically)
172+
- The `:link:` should be the notebook name without the `.ipynb` extension
173+
- Cards are arranged in a 3-column grid layout
174+
175+
4. **Generate thumbnails locally** (optional, for testing):
176+
```bash
177+
python scripts/generate_gallery.py
178+
```
179+
Thumbnails are automatically generated during the documentation build process, so you don't need to commit them (the `docs/source/_static/thumbnails/` directory is gitignored).
180+
181+
5. **Build and test the documentation** to verify the notebook appears correctly in the gallery:
182+
```bash
183+
make html
184+
```
185+
Then open `docs/_build/html/notebooks/index.html` in your browser to see the gallery.
186+
187+
**Note**: The gallery generation script (`scripts/generate_gallery.py`) runs automatically during the Sphinx build process (configured in `docs/source/conf.py`), so thumbnails will be generated on Read the Docs builds without needing to commit them.
188+
152189
- Documentation and high-coverage tests are necessary for enhancements to be accepted.
153190

154191
- Documentation follows [NumPy style guide](https://numpydoc.readthedocs.io/en/latest/format.html)

0 commit comments

Comments
 (0)