You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`: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
+
34
52
## Code structure and style
35
53
36
54
-**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()`)
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,6 +149,43 @@ We recommend that your contribution complies with the following guidelines befor
149
149
150
150
- 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 forreference. Examples should demonstrate why the new functionality is usefulin practice.
151
151
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:
- 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
+
152
189
- Documentation and high-coverage tests are necessary for enhancements to be accepted.
0 commit comments