|
55 | 55 | 'sphinx.ext.viewcode', # display code with line numbers and line highlighting |
56 | 56 | 'sphinx_copybutton', # Adds a copy button to code blocks |
57 | 57 | 'sphinx_sitemap', # sitemap.xml generation |
| 58 | + 'doc.extensions.prettyspecialmethods', # Forker plugin for prettifying special methods |
58 | 59 | ] |
59 | 60 |
|
60 | 61 | # Add any paths that contain templates here, relative to this directory. |
@@ -264,28 +265,23 @@ def generate_color_table(filename, source): |
264 | 265 | source[0] += append_text |
265 | 266 |
|
266 | 267 |
|
267 | | -def source_read_handler(_app, docname, source): |
| 268 | +def source_read_handler(_app, doc_name: str, source): |
268 | 269 | """ |
269 | 270 | Event handler for source-read event. |
270 | 271 | Where we can modify the source of a document before it is parsed. |
271 | 272 | """ |
272 | | - file_path = os.path.dirname(os.path.abspath(__file__)) |
273 | | - os.chdir(file_path) |
274 | | - |
275 | | - # Transform source for arcade.color and arcade.csscolor |
276 | | - if docname == "api_docs/arcade.color": |
277 | | - generate_color_table("../arcade/color/__init__.py", source) |
278 | | - elif docname == "api_docs/arcade.csscolor": |
279 | | - generate_color_table("../arcade/csscolor/__init__.py", source) |
| 273 | + # Inject the color tables into the source |
| 274 | + if doc_name == "api_docs/arcade.color": |
| 275 | + generate_color_table("arcade/color/__init__.py", source) |
| 276 | + elif doc_name == "api_docs/arcade.csscolor": |
| 277 | + generate_color_table("arcade/csscolor/__init__.py", source) |
280 | 278 |
|
281 | 279 |
|
282 | 280 | def on_autodoc_process_bases(app, name, obj, options, bases): |
283 | 281 | """We don't care about the `object` base class, so remove it from the list of bases.""" |
284 | 282 | bases[:] = [base for base in bases if base is not object] |
285 | 283 |
|
286 | 284 |
|
287 | | - |
288 | | - |
289 | 285 | def setup(app): |
290 | 286 | # Separate stylesheets loosely by category. |
291 | 287 | app.add_css_file("css/colors.css") |
|
0 commit comments