|
8 | 8 |
|
9 | 9 | # Add repository root to sys.path so autodoc imports from checked-out source |
10 | 10 | # without needing pip install (which would require the Rust/maturin toolchain). |
11 | | -# Note: visualization.py lazily imports matplotlib inside functions, so it is |
12 | | -# not needed as a build dependency. If a future module adds a top-level |
13 | | -# matplotlib import, add it to the RTD dep list in .readthedocs.yaml. |
14 | 11 | sys.path.insert(0, os.path.abspath("..")) |
15 | 12 |
|
16 | 13 | import diff_diff |
|
30 | 27 | "sphinx.ext.viewcode", |
31 | 28 | "sphinx.ext.intersphinx", |
32 | 29 | "sphinx.ext.mathjax", |
| 30 | + "sphinxext.opengraph", |
| 31 | + "sphinx_sitemap", |
| 32 | + "nbsphinx", |
33 | 33 | ] |
34 | 34 |
|
35 | 35 | templates_path = ["_templates"] |
36 | | -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] |
| 36 | +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "llms.txt", "llms-full.txt"] |
37 | 37 |
|
38 | 38 | # -- Options for autodoc ----------------------------------------------------- |
39 | 39 | autodoc_default_options = { |
|
62 | 62 | napoleon_attr_annotations = True |
63 | 63 |
|
64 | 64 | # -- Options for HTML output ------------------------------------------------- |
65 | | -html_theme = "sphinx_rtd_theme" |
| 65 | +html_theme = "pydata_sphinx_theme" |
66 | 66 | html_static_path = ["_static"] |
| 67 | +html_title = "diff-diff: Difference-in-Differences Causal Inference for Python" |
| 68 | +# Use RTD's canonical URL when available; fall back to stable for local builds. |
| 69 | +_canonical_url = os.environ.get( |
| 70 | + "READTHEDOCS_CANONICAL_URL", |
| 71 | + "https://diff-diff.readthedocs.io/en/stable/", |
| 72 | +) |
| 73 | +html_baseurl = _canonical_url |
| 74 | +html_extra_path = ["llms.txt", "llms-full.txt"] |
| 75 | +sitemap_url_scheme = "{link}" |
67 | 76 |
|
68 | 77 | html_theme_options = { |
| 78 | + "icon_links": [ |
| 79 | + { |
| 80 | + "name": "GitHub", |
| 81 | + "url": "https://github.com/igerber/diff-diff", |
| 82 | + "icon": "fa-brands fa-github", |
| 83 | + }, |
| 84 | + { |
| 85 | + "name": "PyPI", |
| 86 | + "url": "https://pypi.org/project/diff-diff/", |
| 87 | + "icon": "fa-brands fa-python", |
| 88 | + }, |
| 89 | + ], |
69 | 90 | "navigation_depth": 4, |
70 | | - "collapse_navigation": False, |
71 | | - "sticky_navigation": True, |
72 | | - "includehidden": True, |
73 | | - "titles_only": False, |
| 91 | + "show_toc_level": 2, |
| 92 | + "use_edit_page_button": True, |
74 | 93 | } |
75 | 94 |
|
| 95 | +html_context = { |
| 96 | + "github_user": "igerber", |
| 97 | + "github_repo": "diff-diff", |
| 98 | + "github_version": "main", |
| 99 | + "doc_path": "docs", |
| 100 | +} |
| 101 | + |
| 102 | +# -- Options for sphinxext-opengraph ----------------------------------------- |
| 103 | +ogp_site_url = _canonical_url |
| 104 | +ogp_site_name = "diff-diff" |
| 105 | +ogp_description_length = 200 |
| 106 | +ogp_type = "website" |
| 107 | +ogp_enable_meta_description = True |
| 108 | +ogp_social_cards = { |
| 109 | + "line_color": "#1f77b4", |
| 110 | +} |
| 111 | + |
| 112 | +# -- Options for nbsphinx --------------------------------------------------- |
| 113 | +nbsphinx_execute = "never" |
| 114 | + |
76 | 115 | # -- Options for intersphinx ------------------------------------------------- |
77 | 116 | intersphinx_mapping = { |
78 | 117 | "python": ("https://docs.python.org/3", None), |
|
83 | 122 |
|
84 | 123 | # -- ReadTheDocs version-aware banner ---------------------------------------- |
85 | 124 | # Shows a warning on development builds so users know they may be reading |
86 | | -# docs for unreleased features. Only activates on RTD (not local builds). |
| 125 | +# docs for unreleased features. Uses PyData theme's announcement bar on RTD, |
| 126 | +# falls back to rst_prolog for local builds. |
87 | 127 | rtd_version = os.environ.get("READTHEDOCS_VERSION", "") |
88 | 128 | rtd_version_type = os.environ.get("READTHEDOCS_VERSION_TYPE", "") |
89 | 129 |
|
90 | 130 | if rtd_version == "latest" or rtd_version_type == "branch": |
91 | | - rst_prolog = """ |
92 | | -.. warning:: |
93 | | -
|
94 | | - This documentation is for the **development version** of diff-diff. |
95 | | - It may describe features not yet available in the latest PyPI release. |
96 | | - For stable documentation, use the version selector (bottom-left) to switch to **stable**. |
97 | | -
|
98 | | -""" |
| 131 | + html_theme_options["announcement"] = ( |
| 132 | + "This documentation is for the <strong>development version</strong> of diff-diff. " |
| 133 | + "It may describe features not yet available in the latest PyPI release. " |
| 134 | + 'Use the version selector to switch to <a href="/en/stable/">stable</a>.' |
| 135 | + ) |
99 | 136 |
|
100 | 137 | # -- Custom CSS -------------------------------------------------------------- |
101 | 138 | def setup(app): |
|
0 commit comments