Before this change, target_uris would be generated as `index.html#foo`.
This makes it difficult to rename the generated document and can require reloading the document when following a link.
After this change, they are just `#foo`, which avoids the above problems.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This normalizes the description of the configuration value so that its default value's unit is the same as the internal one (i.e., seconds).
This PR improves the logic for detecting and eliminating ANSI color codes and other escape sequences introduced by Sphinx. ANSI escape sequences that are not natively known to Sphinx are not eliminated (e.g., VT100-specific functions).
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.
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.
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
Fix a bug whereby the wrong file extension may be used,
when multiple suffixes are specified in the `source_suffix` configuration.
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
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>
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>
Consolidate the provision of a single `http_server` utility method, with `tls_enabled` as a boolean flag,
and rework type annotations to make them more understandable.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
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.