Skip to content

Commit 4769e80

Browse files
authored
docs: fix Sphinx build warnings (#834)
* docs: fix undefined RST substitution in effect_summary docstring The |effect| notation was being parsed by docutils as an RST substitution reference, causing an ERROR in the Sphinx build. Wrapped in double backticks to render as a literal code span. * docs: fix bullet list indentation in PropensityScore.fit_outcome_model Continuation lines of RST bullet items must be indented to align with the text after the `- ` marker. The misaligned lines caused a "bullet list ends without a blank line; unexpected unindent" WARNING in the Sphinx build. * docs: remove __init__ from autosummary methods toctree autoclass already documents __init__ inline on the class page. Listing it again in the methods autosummary caused ~30 duplicate object description WARNINGs (one per public class). Excluding it from the toctree loop removes the redundant standalone pages. * docs: switch bibtex style from unsrt to alpha to fix duplicate labels With bibtex_default_style="unsrt", each per-document bibliography (filtered with :filter: docname in docnames) assigns sequential numeric labels [1], [2], ... starting from 1. These collide in Sphinx's global label registry when the same or different cite keys appear across multiple documents, producing dozens of bibtex.duplicate_label and bibtex.duplicate_citation WARNINGs. Changing to "alpha" gives each entry a unique key derived from author and year (e.g. [Sha02]), eliminating cross-document clashes. * docs: fix notebook heading hierarchy to eliminate myst.header WARNINGs MyST-NB warns when a document's first heading is not H1, or when heading levels increase non-consecutively (e.g. H2 -> H4). - structural_causal_models.ipynb: promote title ## -> #; promote orphan #### subsections (before first ###) to ## - inv_prop_latent.ipynb: promote title ## -> #; fix #### -> ## for the Brief Digression subheading - iv_pymc.ipynb: fix ### Comparison to OLS -> ## (H1 -> H3 jump) - iv_vs_priors.ipynb: promote title ## -> #; restructure cell 4 from #### to ## / ### to match the two-topic (S&S / Horseshoe) organisation - iv_weak_instruments.ipynb: promote title ## -> #; fix #### Digression -> ### (H2 -> H4 jump) * docs: enable myst_heading_anchors to fix broken xref links in estimands.md estimands.md links into quasi_dags.ipynb using slug anchors such as that exist in the notebook, but MyST never registered them as cross- reference targets because myst_heading_anchors defaulted to 0. Setting myst_heading_anchors = 3 makes MyST auto-generate anchors for all H1–H3 headings across all documents, resolving the four myst.xref_missing WARNINGs without requiring explicit (label)= markers. * docs: consolidate bibliography into a single global references page bibtex.duplicate_citation fires when the same cite key appears in multiple documents that each have their own {bibliography} block. There were 18 duplicate keys across 23 documents (~28 warnings). The warning is emitted by sphinxcontrib-bibtex when the same key is registered more than once in its global citation registry via citation-list bibliography blocks. Replace 22 per-document {bibliography} blocks with a single central bibliography on a new references.rst page. Each cite key is now registered exactly once, eliminating all duplicate_citation warnings. The {cite:p}/{cite:t} inline citations across all notebooks are unchanged — they still resolve correctly via Sphinx's cross-document reference machinery. Changes: - docs/source/references.rst (new): single .. bibliography:: directive - docs/source/index.md: add references to toctree - 22 notebooks/markdown files: remove per-page {bibliography} blocks and their ## References / ### References headings - docs/source/knowledgebase/glossary.rst: unchanged (uses footcite) * docs: normalize whitespace in Hernan2024-HERCIW bib entry Tabs replaced with spaces by prek on commit. No content change. * docs: update reference on linden2015 * docs: exclude License section from README include to fix myst.xref_missing The README's [Apache License 2.0](LICENSE) link is a relative path that works on GitHub but causes a myst.xref_missing warning when Sphinx includes the README — there is no LICENSE document in the docs source tree. Add a <!-- docs-end --> marker before the License section and update the {include} directive with :end-before: so Sphinx stops there. The license is still visible on GitHub via the README. * docs: fix toc.not_included and trailing transition warnings - Add rd_skl_drinking.ipynb to the Regression Discontinuity toctree; the notebook existed but was missing from the index, causing a toc.not_included WARNING. - Remove trailing --- from estimands.md; a document-level transition (horizontal rule) as the last element is invalid in docutils and caused a WARNING: Document may not end with a transition. * docs: fix LICENSE link in README to resolve myst.xref_missing Replace the relative path (LICENSE) with an absolute URL so MyST treats it as an external link rather than an internal cross-reference. Removes the <!-- docs-end --> workaround so the License section is now included in the rendered Sphinx docs as well. * docs: restore notebook metadata to match main * docs: move references page under knowledge base * docs: strip citekey labels from references page with post-transform
1 parent 74b7522 commit 4769e80

34 files changed

Lines changed: 103 additions & 446 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,4 @@ Plans for the repository can be seen in the [Issues](https://github.com/pymc-lab
166166

167167
## License
168168

169-
[Apache License 2.0](LICENSE)
169+
[Apache License 2.0](https://github.com/pymc-labs/CausalPy/blob/main/LICENSE)

causalpy/experiments/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ def effect_summary(
354354
(ITS/SC only, ignored for DiD/RD)
355355
min_effect : float, optional
356356
Region of Practical Equivalence (ROPE) threshold (PyMC only, ignored for OLS).
357-
If provided, reports P(|effect| > min_effect) for two-sided or P(effect > min_effect) for one-sided.
357+
If provided, reports ``P(|effect| > min_effect)`` for two-sided or
358+
``P(effect > min_effect)`` for one-sided.
358359
treated_unit : str, optional
359360
For multi-unit experiments (Synthetic Control), specify which treated unit
360361
to analyze. If None and multiple units exist, uses first unit.

causalpy/pymc_models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,13 +1329,13 @@ def fit_outcome_model(
13291329
Notes
13301330
-----
13311331
- This model uses a sampled version of the propensity score (`p`) from the
1332-
posterior of the treatment model, randomly selecting one posterior draw
1333-
per call. This term is estimated initially in the InversePropensity
1334-
class initialisation.
1332+
posterior of the treatment model, randomly selecting one posterior draw
1333+
per call. This term is estimated initially in the InversePropensity
1334+
class initialisation.
13351335
- The term `beta_ps[0] * p` captures both
1336-
main effects of the propensity score.
1336+
main effects of the propensity score.
13371337
- Including spline adjustment enables modeling nonlinear relationships
1338-
between the propensity score and the outcome.
1338+
between the propensity score and the outcome.
13391339
13401340
"""
13411341
if priors is None:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Strip citation labels ([Aba21]) from bibliography entries."""
2+
3+
import docutils.nodes
4+
from sphinx.transforms.post_transforms import SphinxPostTransform
5+
6+
7+
class StripCitationLabels(SphinxPostTransform):
8+
default_priority = 6 # runs right after BibliographyTransform (priority 5)
9+
10+
def run(self):
11+
for node in self.document.findall(docutils.nodes.citation):
12+
for label in node.findall(docutils.nodes.label):
13+
label.parent.remove(label)
14+
for para in node.findall(docutils.nodes.paragraph):
15+
para.insert(0, docutils.nodes.Text("\u2022 "))
16+
break
17+
18+
19+
def setup(app):
20+
app.add_post_transform(StripCitationLabels)
21+
return {"version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True}

docs/source/_static/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Hanging indent for bibliography entries with bullet markers */
2+
.citation[role="doc-biblioentry"] p {
3+
padding-left: 1em;
4+
text-indent: -1em;
5+
}

docs/source/_templates/autosummary/class.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
:toctree:
1414

1515
{% for item in methods %}
16+
{% if item != '__init__' %}
1617
{{ objname }}.{{ item }}
18+
{% endif %}
1719
{%- endfor %}
1820
{% endif %}
1921
{% endblock %}

docs/source/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from causalpy.version import __version__
1616

1717
sys.path.insert(0, os.path.abspath("../"))
18+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "_extensions"))
1819

1920
# autodoc_mock_imports
2021
# This avoids autodoc breaking when it can't find packages imported in the code.
@@ -74,6 +75,7 @@
7475
"sphinx_design",
7576
"sphinx_sitemap",
7677
"sphinx_togglebutton",
78+
"strip_citation_labels",
7779
]
7880

7981
nb_execution_mode = "off"
@@ -94,7 +96,7 @@
9496

9597
# bibtex config
9698
bibtex_bibfiles = ["references.bib"]
97-
bibtex_default_style = "unsrt"
99+
bibtex_default_style = "alpha"
98100
bibtex_reference_style = "author_year"
99101

100102

@@ -136,6 +138,7 @@
136138

137139
# MyST options for working with markdown files.
138140
# Info about extensions here https://myst-parser.readthedocs.io/en/latest/syntax/optional.html?highlight=math#admonition-directives # noqa: E501
141+
myst_heading_anchors = 3 # auto-generate anchors for H1–H3, enabling #slug cross-refs
139142
myst_enable_extensions = [
140143
"dollarmath",
141144
"amsmath",
@@ -153,6 +156,7 @@
153156

154157
html_theme = "labs_sphinx_theme"
155158
html_static_path = ["_static"]
159+
html_css_files = ["custom.css"]
156160
html_extra_path = ["robots.txt"]
157161
html_favicon = "_static/favicon_logo.png"
158162
# Theme options are theme-specific and customize the look and feel of a theme

docs/source/knowledgebase/design_notation.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,3 @@ From an analysis perspective, regression discontinuity designs are very similar
9292

9393
## Summary
9494
This page has offered a brief overview of the tabular notation used to describe quasi-experimental designs. The notation is a useful tool for summarizing the design of a study, and can be used to help identify the strengths and limitations of a study design. But readers are strongly encouraged to consult the original sources when assessing the relative strengths and limitations of making causal claims under different quasi-experimental designs.
95-
96-
## References
97-
:::{bibliography}
98-
:filter: docname in docnames
99-
:::

docs/source/knowledgebase/estimands.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,3 @@ The descriptions above assume standard usage. Always consider what your specific
147147
| Regression Discontinuity | Local treatment effect at cutoff | Prediction-based |
148148

149149
For methods not covered in detail here (IV, IPW, ANCOVA), see the respective notebook documentation, {doc}`quasi_dags` for identification, and the {doc}`glossary` for estimand definitions. Note that some of these methods have more limited implementation support in CausalPy---for example, IV does not yet have full `plot()` and `summary()` support, and IPW and ANCOVA are Bayesian-only.
150-
151-
---
152-
153-
## References
154-
155-
:::{bibliography}
156-
:filter: docname in docnames
157-
:::

docs/source/knowledgebase/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ structural_causal_models.ipynb
1212
custom_pymc_models.ipynb
1313
causal_video_resources
1414
causal_written_resources
15+
../references
1516
:::

0 commit comments

Comments
 (0)