|
1 | 1 | import os |
| 2 | +import sys |
2 | 3 | from datetime import datetime |
3 | 4 | from importlib import metadata |
4 | 5 |
|
5 | | -# Project information |
| 6 | +# Include src directory for autodoc |
| 7 | +sys.path.insert(0, os.path.abspath("../../src")) |
| 8 | + |
| 9 | +# -- Project information ----------------------------------------------------- |
| 10 | + |
6 | 11 | project = "gen_surv" |
7 | 12 | copyright = f"{datetime.now().year}, Diogo Ribeiro" |
8 | 13 | author = "Diogo Ribeiro" |
9 | | -release = metadata.version("gen_surv") |
| 14 | + |
| 15 | +# Get version from installed package metadata |
| 16 | +try: |
| 17 | + release = metadata.version("gen_surv") |
| 18 | +except metadata.PackageNotFoundError: |
| 19 | + release = "0.0.0" # fallback for local builds |
10 | 20 | version = release |
11 | 21 |
|
12 | | -# General configuration |
| 22 | +# -- General configuration --------------------------------------------------- |
| 23 | + |
13 | 24 | extensions = [ |
14 | 25 | "sphinx.ext.autodoc", |
15 | 26 | "sphinx.ext.napoleon", |
16 | 27 | "sphinx.ext.viewcode", |
17 | 28 | "sphinx.ext.intersphinx", |
18 | 29 | "sphinx.ext.autosummary", |
19 | | - "sphinx.ext.githubpages", |
| 30 | + "sphinx.ext.githubpages", # includes .nojekyll |
20 | 31 | "myst_parser", |
21 | 32 | "sphinx_copybutton", |
22 | 33 | "sphinx_design", |
23 | 34 | "sphinx_autodoc_typehints", |
24 | 35 | ] |
25 | 36 |
|
26 | | -# MyST Parser configuration |
| 37 | +autosummary_generate = True |
| 38 | + |
| 39 | +autodoc_default_options = { |
| 40 | + "members": True, |
| 41 | + "member-order": "bysource", |
| 42 | + "special-members": "__init__", |
| 43 | + "undoc-members": True, |
| 44 | + "exclude-members": "__weakref__", |
| 45 | +} |
| 46 | + |
| 47 | +# MyST Markdown extensions |
27 | 48 | myst_enable_extensions = [ |
28 | 49 | "colon_fence", |
29 | 50 | "deflist", |
|
36 | 57 | "tasklist", |
37 | 58 | ] |
38 | 59 |
|
39 | | -# Autodoc configuration |
40 | | -autodoc_default_options = { |
41 | | - "members": True, |
42 | | - "member-order": "bysource", |
43 | | - "special-members": "__init__", |
44 | | - "undoc-members": True, |
45 | | - "exclude-members": "__weakref__", |
46 | | -} |
47 | | - |
48 | | -# Autosummary |
49 | | -autosummary_generate = True |
50 | | - |
51 | | -# Napoleon settings |
52 | 60 | napoleon_google_docstring = True |
53 | 61 | napoleon_numpy_docstring = True |
54 | 62 | napoleon_include_init_with_doc = False |
|
61 | 69 | "pandas": ("https://pandas.pydata.org/docs/", None), |
62 | 70 | } |
63 | 71 |
|
64 | | -# Disable fetching remote inventories when network access is unavailable |
| 72 | +# Disable fetching intersphinx inventories on CI (e.g., for offline builds) |
65 | 73 | if os.environ.get("SKIP_INTERSPHINX", "1") == "1": |
66 | 74 | intersphinx_mapping = {} |
67 | 75 |
|
68 | | -# HTML theme options |
| 76 | +# -- HTML output configuration ---------------------------------------------- |
| 77 | + |
69 | 78 | html_theme = "sphinx_rtd_theme" |
70 | 79 | html_theme_options = { |
71 | 80 | "canonical_url": "https://gensurvpy.readthedocs.io/", |
72 | | - "analytics_id": "", |
73 | 81 | "logo_only": False, |
74 | 82 | "prev_next_buttons_location": "bottom", |
75 | 83 | "style_external_links": False, |
|
81 | 89 | "titles_only": False, |
82 | 90 | } |
83 | 91 |
|
| 92 | +# Static assets |
84 | 93 | html_static_path = ["_static"] |
85 | 94 | html_css_files = ["custom.css"] |
86 | 95 |
|
| 96 | +# Add .nojekyll so GitHub Pages serves _static and other underscored folders |
| 97 | +html_extra_path = [".nojekyll"] |
| 98 | + |
| 99 | +# Required for correct link rendering on GitHub Pages under a subpath |
| 100 | +html_baseurl = "https://diogoribeiro7.github.io/packages/gensurvpy/" |
| 101 | + |
87 | 102 | # Output file base name for HTML help builder |
88 | 103 | htmlhelp_basename = "gensurvdoc" |
89 | 104 |
|
90 | | -# Copy button configuration |
| 105 | +# Copy button config for code blocks |
91 | 106 | copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: " |
92 | 107 | copybutton_prompt_is_regexp = True |
0 commit comments