Commit Graph
25 Commits
Author SHA1 Message Date
Chris Sewell 430866e029 👌 Add warning log for config values that cannot be cached (#12203)
As a user and/or extension developer, it can be a source of confusion when,
on performing a `sphinx-build` for a cached project, 
an unchanged configuration variable is always marked as changed (triggering a full rebuild).

This is often due to the variable being an unpicklable value,
which is silently omitted from the cache (i.e. the `environment.pickle`).

This commit introduces a specific warning for when a configuration variable is omitted from the cache,
allowing users to understand the root of the problem.
2024-03-27 12:59:24 +01:00
Chris Sewell 448cb9931d 🔧 CI: fix Python 3.13 tests (#12210) 2024-03-27 12:45:24 +01:00
Chris Sewell 04bd0df100 👌 Improve external role warnings (and revert object fallback) (#12193)
The key issue this commit seeks to address, is that existing tools / documentation often lead users to mistakenly use object types and not role names, a classic example being `function` not `func`

Previously, the warning message for using e.g. `` external:function`target` `` (with `py` as the default domain), would be:

```
WARNING: role for external cross-reference not found: function
```

This gives no information to the user on how to fix the issue, even though there is actually quite an easy fix

This commit adds logic to create more specific / helpful warning messages, e.g.

```
WARNING: role for external cross-reference not found in domains 'py', 'std': 'function' (perhaps you meant one of: 'py:func', 'py:obj')
```

This goes through the same original logic but, if the role is not found, it will look if the role name is actually an available object type on the domain(s), and then suggest its related roles.

This commit also reverts #12133, which provided a (silent) fallback to auto convert an object type to a role name.
2024-03-25 14:39:51 +01:00
Chris Sewell 66fa790b3a [tests] Add basic build test for all builtin themes (#12168)
Add `tests/test_theming/test_theming.py::test_theme_builds`, which is a parametrized test against all builtin sphinx HTML themes, that tests:

1. that the themes builds without warnings for a basic project, and
2. that all `.html` files it produces are valid XML (see https://html.spec.whatwg.org/)

https://pypi.org/project/defusedxml/ was added to the test dependencies, in order to safely parse the XML

This required one fix for `sphinx/themes/basic/search.html`, and one for `sphinx/themes/bizstyle/layout.html`

Also, `tests/test_theming` was removed from the `ruff format` exclude list
2024-03-22 12:57:34 +01:00
Chris SewellandBénédikt Tran d59b158371 👌 Make ExtensionMetadata type public and use it in internal extensions (#12153)
This type alias has now been fully documented for public consumption.

This will be beneficial to the sphinx ecosystem,
to aide/encourage extension developers to provide the correct metadata.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-21 16:19:26 +01:00
ace9d97500 👌 Improve signature and type annotations for SphinxLoggerAdapter.warning (#12154)
This commit overrides the  `SphinxLoggerAdapter.warning` method,
to provide documentation and type annotations specific to logging sphinx warnings.
This should aide sphinx core/extension developers in creating good warnings.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: danieleades <33452915+danieleades@users.noreply.github.com>
2024-03-21 15:41:22 +01:00
Chris Sewell b45fee696f 🔧 Sync make doclinter with CI check (#12156)
Unignore files in `make doclinter` command, fix the resulting issues, and use this command in the CI job
2024-03-21 13:12:06 +01:00
Chris SewellandBénédikt Tran d908886c03 📚 add tip about running karma js tests on mac (#12140)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-20 21:55:34 +01:00
Chris Sewell 2d6f73ed68 🔧 Ruff format select sphinx modules with minimal diffs (#12146)
This comit removes select sphinx top-level modules from the `ruff format` exclude list.
They were selected based on the fact that they have the least diffs when formatted,
are not believe to introduce changes that would adversely affect any existing PRs.
2024-03-20 21:28:10 +01:00
Chris Sewell 392358d4de 🔧 Ruff format python files within utils folder (#12142)
Remove from `exclude` list
2024-03-19 19:32:28 +01:00
Chris Sewell 3bedde26a9 🔧 Ruff format python files within docs folder (#12139)
Remove `docs` files from the `exclude` list, and also add the `preview = false` format config, which is shown to reduce diffs to the current code base
2024-03-19 15:23:57 +01:00
Chris SewellandBénédikt Tran 565d4104d5 👌 Handle external references pointing to object types (#12133)
This commit fixes the issue of `objects.inv` denoting object names, whilst the `external` role only allows for role names. 

As an example, take the `objects.inv` for the sphinx documentation, which contains:

```
py:function
    compile                  : usage/domains/python.html#compile
```

A user might understandably expect that they could reference this using `` :external:py:function:`compile` ``, but actually this would previously error with:

```
WARNING: role for external cross-reference not found: py:function
```

this is because, `function` is the object type, yet `external` expects the related role name `func`.

It should not be necessary for the user to know about this distinction,
so in this commit, we add logic, to first look if the name relates to a role name (as previous, to not be back-breaking) but, if not, then also look if the name relates to an object that has a known role and, if so, use that.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-19 13:42:50 +01:00
d8cf71cbde 🔧 Setup ruff format (initially excluding all files) (#12136)
Co-authored-by: danieleades <33452915+danieleades@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-19 10:27:41 +01:00
Chris SewellandBénédikt Tran b0f096f440 ✨ Add show_warning_types configuration variable (#12131)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-19 10:22:28 +01:00
Chris Sewell 3f3d3d8517 🔧 Add flake8 to make style-check (#12137) 2024-03-19 10:07:41 +01:00
Chris Sewell aaecc9376d 🔧 Remove unused regexes (#12132)
These appear to have been copied to class variables at some point, but then not removed as global variables
2024-03-19 09:36:22 +01:00
Chris SewellandBénédikt Tran a27f156e31 🔧 Add check rule to Makefile (#12135)
To run all linting/type-checking, just for dev ease

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-19 09:34:34 +01:00
Chris Sewell 9019144590 remove type: ignore 2021-04-23 22:40:07 +02:00
Chris Sewell c47f8aa6d1 🐛 FIX: Config.__getitem__ typing 2021-04-23 22:40:07 +02:00
Chris Sewell 088d059196 minor typing fix 2021-01-20 04:43:39 +00:00
Chris Sewell 46177f6af3 Correct numbers 2020-08-21 01:58:28 +01:00
Chris Sewell 5c744d8342 📚 DOCS: Improve build process overview 2020-08-20 22:37:37 +01:00
Chris Sewell 08d7b4de2e modify deprecated method 2019-03-08 14:10:14 +00:00
Chris Sewell a88078ec73 Merge remote-tracking branch 'upstream/2.0' into propogate_citeref_classes 2019-03-08 14:05:20 +00:00
Chris Sewell b74dbeb87a propogate cite_reference node classes to pending_xref node 2019-03-08 00:26:51 +00:00