Commit Graph

4850 Commits

Author SHA1 Message Date
Adam Turner
c4daa95c09 Enable the entire D category in Ruff 2025-01-14 15:55:02 +00:00
Adam Turner
c66d3e85d1 Enable 11 more categories in Ruff
* flake8-builtins ('A')
* flake8-blind-except ('BLE')
* flake8-copyright ('CPY')
* eradicate ('ERA')
* flake8-boolean-trap ('FBT')
* flake8-fixme ('FIX')
* flake8-implicit-str-concat ('ISC')
* pep8-naming ('N')
* flake8-use-pathlib ('PTH')
* flake8-self ('SLF')
* tryceratops ('TRY')
2025-01-14 14:43:02 +00:00
Adam Turner
3521cb60cf Enable the entire TD category in Ruff 2025-01-14 12:52:43 +00:00
Adam Turner
cc8161a066 Move `sphinx.util re-exports to module __getattr__` 2025-01-14 01:01:52 +00:00
Adam Turner
66905d24e1 Use strict flake8-type-checking settings in Ruff 2025-01-13 21:56:36 +00:00
Adam Turner
f6d1665f84 Use frozensets for permitted types in `app.add_config_value()` 2025-01-13 21:18:17 +00:00
Bénédikt Tran
2a19d293b6
autodoc: fix detection of class methods implemented by extension modules (#13200)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-01-12 11:07:30 +00:00
Adam Turner
72ce43619c
Remove unneeded runtime typing imports (#13233) 2025-01-12 01:04:14 +00:00
Adam Turner
d29c2c1ff3
Implement key splitting in the `:kbd: role and remove KeyboardTransform` (#13227)
``KeyboardTransform.run`` takes 1.2% of the runtime of a build, but
is not be needed if ``:kbd:`` is converted to a proper role.

We implement key splitting in the ``:kbd:`` role, and return a sequence
of parsed nodes rather than a nested collection of roles with ``class="kbd compound"``.
2025-01-10 19:51:17 +00:00
Adam Turner
dec45eaf28 Bump Ruff to 0.9.0 2025-01-10 13:50:26 +00:00
James Addison
267fe9afa8
Tests: explicitly unset SOURCE_DATE_EPOCH during 'test_html_multi_line_copyright' (#13224)
Sphinx's copyright substitution currently allows years identified as
the current year to be downgraded to previous years when
``SOURCE_DATE_EPOCH`` is configured, to assist reproducibility [1] of
documentation builds.

However, we have a test case ``test_html_multi_line_copyright``,
written in 2024, that mentioned a future year (2025).

Now that we have reached 2025, it is eligible for substitution when
``SOURCE_DATE_EPOCH`` is configured.  Many buildsystems, such as those
used by Debian and Fedora, choose the most-recent packaging/commit
timestamp to use as `SOURCE_DATE_EPOCH`'s timestamp, since those
correspond sensibly to a time-of-build.

However, for the Sphinx 8.1.3 release including the updated
substitution logic, the year-of-release/commit was 2024. Thus, if a
commit/packaging date from that year is chosen, and
``SOURCE_DATE_EPOCH`` is configured when the unit tests run, the
``test_html_multi_line_copyright`` test will fail.

The fix suggested here is to explicitly unset ``SOURCE_DATE_EPOCH``
within ``test_html_multi_line_copyright``.

[1]: https://www.reproducible-builds.org/

Authored-by: Colin Watson <cjwatson@debian.org>
Co-authored-by: Colin Watson <cjwatson@debian.org>
Authored-by: James Addison <55152140+jayaddison@users.noreply.github.com>
Co-authored-by: James Addison <55152140+jayaddison@users.noreply.github.com>
2025-01-10 11:21:11 +00:00
Adam Turner
74ec220479 apidoc: Rename test roots 2025-01-07 11:06:29 +00:00
Adam Turner
8732b2324a Split out `sphinx.ext.apidoc._generate` 2025-01-07 08:33:20 +00:00
Adam Turner
2bd70193b7 Split out `sphinx.ext.apidoc._cli` 2025-01-07 08:32:11 +00:00
Adam Turner
47599df1bc apidoc: Add `--automodule-options` 2025-01-07 08:05:20 +00:00
Adam Turner
df06e6d628
Add `InventoryFile.loads()` (#13215) 2025-01-07 00:40:57 +00:00
Adam Turner
b852618c1b Avoid using camelCase names 2025-01-07 00:17:00 +00:00
Adam Turner
91bae649c1 Remove shebang from test-apidoc-toc test root 2025-01-06 21:55:29 +00:00
Adam Turner
a69d79bf67 Add .gitattributes 2025-01-06 21:55:29 +00:00
Adam Turner
5ff3740063 Adapt tests for Pygments 2.19 2025-01-06 06:56:10 +00:00
Adam Turner
d59084a1fa Bump Ruff to 0.8.6 2025-01-06 06:05:55 +00:00
ProGamerGov
fec4d7c2f1
Viewcode: Fix issue with import paths that differ from the directory structure (#13195)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-01-05 10:43:57 +00:00
Adam Turner
83bf866059
Avoid attribute indirection with `env` (#13212) 2025-01-05 09:10:55 +00:00
Adam Turner
849d309db4 Napoleon: Use `:py:{...}` in type preprocessing 2025-01-05 02:13:15 +00:00
James Addison
872d270f10
linkcheck: support ignored-URIs for redirects (#13127)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-01-05 01:20:15 +00:00
Chris Barrick
8d75ae2d6b Napoleon: Unify the type preprocessing logic
Previously, there were two type preprocessing functions:
`_convert_type_spec` (used in Google-style docstrings) and
`_convert_numpy_type_spec` (used in Numpy-style docstrings).

The Google version simply applied type-alias translations or wrapped
the text in a `:py:class:` role.

The Numpy version does the same, plus adds special handling for keywords
`optional` and `default` and delimiter words `or`, `of`, and `and`. This
allows one to write in natural language, like `Array of int` instead of
`Array[int]` or `Widget, optional` instead of `Optional[Widget]` or
`Widget | None`. Numpy style is described in full at:
https://numpydoc.readthedocs.io/en/latest/format.html#parameters

This commit eliminates the distinction and allows Google-style
docstrings to use these preprocessing rules.
2025-01-05 01:18:29 +00:00
Adam Turner
02beccac0a
intersphinx: Define a restricted subset of Config as `InvConfig` (#13210) 2025-01-05 01:06:51 +00:00
Adam Turner
619a10efa7
intersphinx: Simplify `_fetch_inventory()` (#13209)
The streams-based interfaces in intersphinx and ``sphinx.util.inventory``
are clever, but also complex and prevent using compression methods
that don't support incrememntal decoding. This change refactors
``_fetch_inventory()`` to read all inventory content from disk or an
HTTP request at once.
2025-01-05 00:34:49 +00:00
Adam Turner
e17ed74fe0 Remove unneeded content from within `with` statements 2025-01-04 09:11:33 +00:00
Maciej Olko
ad0c343d36
Trim leading whitespace before doctest flags (#13164) 2025-01-04 00:30:03 +00:00
Adam Turner
e65bbb96ae
Create a new type for the current document's environment state (#13151) 2025-01-04 00:28:03 +00:00
Nicolas Peugnet
0fbf88a59f
Allow extensions to define the keys returned by linkcode (#11824)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-01-03 21:28:34 +00:00
Adam Turner
3028e818c9
Remove test skips for Python 3.14 (#13041) 2025-01-03 07:31:40 +00:00
Adam Turner
00ad109a39 Run Ruff on `tests/roots/` 2025-01-03 01:33:14 +00:00
Adam Turner
b176c66f8c Enable the FURB113 lint in Ruff 2025-01-03 01:13:05 +00:00
Adam Turner
013dcdc3b8 Run Ruff on `tests/js/roots/` 2025-01-02 23:53:59 +00:00
Adam Turner
43bf986891 Enable the RET503 lint in Ruff 2025-01-02 23:49:44 +00:00
Adam Turner
2aad3a87f4 Enable the entire Q category in Ruff 2025-01-02 23:49:44 +00:00
Adam Turner
b5f9ac8afc Enable the RUF100 lint in Ruff 2025-01-02 23:49:43 +00:00
Adam Turner
5f6457911d Enable the RUF048 lint in Ruff 2025-01-02 23:49:43 +00:00
Adam Turner
05fc47f120 Enable the RUF043 lint in Ruff 2025-01-02 23:49:43 +00:00
James Addison
6678e35704
html search: add safety check before index property accesses (#13153) 2025-01-02 23:06:35 +00:00
Adam Turner
64937535dc Bump Ruff to 0.8.5 2025-01-02 21:11:36 +00:00
Adam Turner
ce070af2fa Avoid using camelCase names in domain tests 2024-12-09 15:10:18 +00:00
Adam Turner
51bbfe259e Avoid using camelCase names in napoleon tests 2024-12-09 14:59:36 +00:00
Adam Turner
34f5a8d503 Avoid using camelCase names in autodoc tests 2024-12-09 14:59:25 +00:00
Adam Turner
2d2b73c706 Avoid using camelCase names in autosummary tests 2024-12-09 14:57:08 +00:00
Adam Turner
19dfc3f5af Enable the RUF031 lint in Ruff 2024-11-30 19:22:30 +00:00
Adam Turner
d796a8ae21 Enable the RUF029 lint in Ruff 2024-11-30 19:21:35 +00:00
Adam Turner
2f1cd36798 Enable the RUF015 lint in Ruff 2024-11-30 19:19:34 +00:00