|
1 | 1 | """List of projects to test Sphinx against. |
2 | 2 |
|
3 | | -This module contains a curated list of open-source projects that use Sphinx |
4 | | -for their documentation. These projects are used to test the impact of |
5 | | -Sphinx changes on real-world documentation builds. |
| 3 | +This module loads project definitions from projects.toml and provides |
| 4 | +functions to access and filter them. |
6 | 5 | """ |
7 | 6 |
|
8 | 7 | from __future__ import annotations |
9 | 8 |
|
| 9 | +import re |
| 10 | +import tomllib |
| 11 | +from pathlib import Path |
| 12 | + |
10 | 13 | from .model import Project |
11 | 14 |
|
12 | | -# Projects are grouped by category for easier management. |
13 | | -# When adding new projects: |
14 | | -# 1. Verify the project uses Sphinx for documentation |
15 | | -# 2. Test that the project builds successfully with current Sphinx |
16 | | -# 3. Add any necessary pip_install commands for dependencies |
17 | | -# 4. Specify doc_path if not 'doc' or 'docs' |
18 | | - |
19 | | -PROJECTS: tuple[Project, ...] = ( |
20 | | - # === Python ecosystem core === |
21 | | - Project( |
22 | | - repo='https://github.com/python/cpython', |
23 | | - doc_path='Doc', |
24 | | - pip_install=['-r', 'Doc/requirements.txt'], |
25 | | - ), |
26 | | - # === Scientific computing === |
27 | | - Project( |
28 | | - repo='https://github.com/numpy/numpy', |
29 | | - doc_path='doc', |
30 | | - pip_install=['.', '-r', 'doc_requirements.txt'], |
31 | | - ), |
32 | | - Project( |
33 | | - repo='https://github.com/scipy/scipy', |
34 | | - doc_path='doc', |
35 | | - pip_install=['.', '-r', 'doc_requirements.txt'], |
36 | | - ), |
37 | | - Project( |
38 | | - repo='https://github.com/pandas-dev/pandas', |
39 | | - doc_path='doc', |
40 | | - pip_install=['.', '-r', 'doc/requirements-doc.txt'], |
41 | | - ), |
42 | | - Project( |
43 | | - repo='https://github.com/matplotlib/matplotlib', |
44 | | - doc_path='doc', |
45 | | - pip_install=['.', '-r', 'requirements/doc.txt'], |
46 | | - ), |
47 | | - # === Web frameworks === |
48 | | - Project( |
49 | | - repo='https://github.com/pallets/flask', |
50 | | - doc_path='docs', |
51 | | - pip_install=['.[docs]'], |
52 | | - ), |
53 | | - Project( |
54 | | - repo='https://github.com/django/django', |
55 | | - doc_path='docs', |
56 | | - pip_install=['.', 'sphinx', 'sphinxcontrib-spelling'], |
57 | | - ), |
58 | | - Project( |
59 | | - repo='https://github.com/pallets/jinja', |
60 | | - doc_path='docs', |
61 | | - pip_install=['.[docs]'], |
62 | | - ), |
63 | | - Project( |
64 | | - repo='https://github.com/pallets/click', |
65 | | - doc_path='docs', |
66 | | - pip_install=['.[docs]'], |
67 | | - ), |
68 | | - Project( |
69 | | - repo='https://github.com/pallets/werkzeug', |
70 | | - doc_path='docs', |
71 | | - pip_install=['.[docs]'], |
72 | | - ), |
73 | | - # === HTTP/networking === |
74 | | - Project( |
75 | | - repo='https://github.com/psf/requests', |
76 | | - doc_path='docs', |
77 | | - pip_install=['.[docs]'], |
78 | | - ), |
79 | | - Project( |
80 | | - repo='https://github.com/urllib3/urllib3', |
81 | | - doc_path='docs', |
82 | | - pip_install=['.[docs]'], |
83 | | - ), |
84 | | - Project( |
85 | | - repo='https://github.com/aio-libs/aiohttp', |
86 | | - doc_path='docs', |
87 | | - pip_install=['.[docs]'], |
88 | | - ), |
89 | | - # === Testing === |
90 | | - Project( |
91 | | - repo='https://github.com/pytest-dev/pytest', |
92 | | - doc_path='doc/en', |
93 | | - pip_install=['.[docs]'], |
94 | | - ), |
95 | | - Project( |
96 | | - repo='https://github.com/tox-dev/tox', |
97 | | - doc_path='docs', |
98 | | - pip_install=['.[docs]'], |
99 | | - ), |
100 | | - Project( |
101 | | - repo='https://github.com/python/mypy', |
102 | | - doc_path='docs', |
103 | | - pip_install=['.[docs]'], |
104 | | - ), |
105 | | - # === Database === |
106 | | - Project( |
107 | | - repo='https://github.com/sqlalchemy/sqlalchemy', |
108 | | - doc_path='doc/build', |
109 | | - pip_install=['.[docs]'], |
110 | | - ), |
111 | | - # === Async === |
112 | | - Project( |
113 | | - repo='https://github.com/python-trio/trio', |
114 | | - doc_path='docs/source', |
115 | | - pip_install=['.[docs]'], |
116 | | - ), |
117 | | - # === CLI/utilities === |
118 | | - Project( |
119 | | - repo='https://github.com/python-attrs/attrs', |
120 | | - doc_path='docs', |
121 | | - pip_install=['.[docs]'], |
122 | | - ), |
123 | | - Project( |
124 | | - repo='https://github.com/pydantic/pydantic', |
125 | | - doc_path='docs', |
126 | | - pip_install=['.[docs]'], |
127 | | - # Pydantic uses mkdocs, so disable for now |
128 | | - enabled=False, |
129 | | - ), |
130 | | - # === Packaging === |
131 | | - Project( |
132 | | - repo='https://github.com/pypa/pip', |
133 | | - doc_path='docs', |
134 | | - pip_install=['.[docs]'], |
135 | | - ), |
136 | | - Project( |
137 | | - repo='https://github.com/pypa/setuptools', |
138 | | - doc_path='docs', |
139 | | - pip_install=['.[docs]'], |
140 | | - ), |
141 | | - Project( |
142 | | - repo='https://github.com/pypa/virtualenv', |
143 | | - doc_path='docs', |
144 | | - pip_install=['.[docs]'], |
145 | | - ), |
146 | | - # === Sphinx extensions and themes === |
147 | | - Project( |
148 | | - repo='https://github.com/readthedocs/sphinx_rtd_theme', |
149 | | - doc_path='docs', |
150 | | - pip_install=['.[docs]'], |
151 | | - ), |
152 | | - Project( |
153 | | - repo='https://github.com/sphinx-contrib/sphinx-autodoc-typehints', |
154 | | - doc_path='docs', |
155 | | - pip_install=['.[docs]'], |
156 | | - ), |
157 | | - # === Data serialization === |
158 | | - Project( |
159 | | - repo='https://github.com/marshmallow-code/marshmallow', |
160 | | - doc_path='docs', |
161 | | - pip_install=['.[docs]'], |
162 | | - ), |
163 | | - # === Security === |
164 | | - Project( |
165 | | - repo='https://github.com/pyca/cryptography', |
166 | | - doc_path='docs', |
167 | | - pip_install=['.[docs]'], |
168 | | - ), |
169 | | - # === Image processing === |
170 | | - Project( |
171 | | - repo='https://github.com/python-pillow/Pillow', |
172 | | - doc_path='docs', |
173 | | - pip_install=['.[docs]'], |
174 | | - ), |
175 | | - # === ASGI/HTTP === |
176 | | - Project( |
177 | | - repo='https://github.com/encode/httpx', |
178 | | - doc_path='docs', |
179 | | - pip_install=['.[docs]'], |
180 | | - # httpx uses mkdocs |
181 | | - enabled=False, |
182 | | - ), |
183 | | - Project( |
184 | | - repo='https://github.com/encode/starlette', |
185 | | - doc_path='docs', |
186 | | - pip_install=['.[docs]'], |
187 | | - # starlette uses mkdocs |
188 | | - enabled=False, |
189 | | - ), |
190 | | -) |
| 15 | +# Load projects from TOML file |
| 16 | +_PROJECTS_TOML = Path(__file__).parent / 'projects.toml' |
| 17 | + |
| 18 | + |
| 19 | +def _load_projects() -> tuple[Project, ...]: |
| 20 | + """Load projects from the TOML configuration file.""" |
| 21 | + with _PROJECTS_TOML.open('rb') as f: |
| 22 | + data = tomllib.load(f) |
| 23 | + |
| 24 | + projects = [] |
| 25 | + for config in data.values(): |
| 26 | + # Skip non-table entries (shouldn't exist, but be safe) |
| 27 | + if not isinstance(config, dict): |
| 28 | + continue |
| 29 | + |
| 30 | + projects.append( |
| 31 | + Project( |
| 32 | + repo=config['repo'], |
| 33 | + pip_install=tuple(config.get('pip_install', ())), |
| 34 | + doc_path=config.get('doc_path', ''), |
| 35 | + conf_path=config.get('conf_path', ''), |
| 36 | + builder=config.get('builder', 'html'), |
| 37 | + extra_args=tuple(config.get('extra_args', ())), |
| 38 | + revision=config.get('revision', ''), |
| 39 | + enabled=config.get('enabled', True), |
| 40 | + ) |
| 41 | + ) |
| 42 | + |
| 43 | + return tuple(projects) |
| 44 | + |
| 45 | + |
| 46 | +# Cache the loaded projects |
| 47 | +PROJECTS: tuple[Project, ...] = _load_projects() |
191 | 48 |
|
192 | 49 |
|
193 | 50 | def get_projects(*, include_disabled: bool = False) -> tuple[Project, ...]: |
@@ -219,7 +76,5 @@ def filter_projects(pattern: str) -> tuple[Project, ...]: |
219 | 76 | :param pattern: A regex pattern to match project names. |
220 | 77 | :return: Tuple of matching Project objects. |
221 | 78 | """ |
222 | | - import re |
223 | | - |
224 | 79 | regex = re.compile(pattern, re.IGNORECASE) |
225 | 80 | return tuple(p for p in get_projects() if regex.search(p.name)) |
0 commit comments