Repository navigation
👌 sphinx-codelinks: settle the three [codelinks] reader policies (unknown keys, TOML-set config_from_toml, ConfigError) - #2022
Open
patdhlk wants to merge 1 commit into
Conversation
Fixes useblocks#2007. - Unknown keys under [codelinks] and [codelinks.projects.<name>] are now skipped with a warning by both readers (codelinks.config in Sphinx, stderr for `codelinks analyse`), never refused. - config_from_toml set inside the TOML is ignored with a warning instead of silently moving the relative-path anchor. - check_sphinx_configuration raises sphinx.errors.ConfigError instead of a bare Exception, and the message says "field", not "filed".
Documentation build overview
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2007: settles the three
[codelinks]reader policies that #2005 measured and left alone, following the issue's proposals.1. Unknown keys: both readers warn, neither refuses
A new
drop_unread_keysfunction inconfig.pyis called by both readers right afterload_codelinks_table. It removes:[codelinks]keys[codelinks.projects.<name>]keys. Onlysource_discover,analyseandremote_url_patternare read. The runtime-builtsource_discover_config/analyse_configcount as unknown in a file.It emits one warning per table that has unknown keys, naming the file, the table, the keys and the supported keys. In Sphinx the warning is
codelinks.config, the subtype #2005 introduced, so it can be suppressed.codelinks analyseprints it to stderr and carries on (it used to exit with rc 2).[codelinks] bogus_keyunexpected keyword argument[codelinks.projects.p] bogusA project declared in conf.py is still checked strictly by the schema. That file belongs to codelinks alone, so the shared-file argument doesn't apply to it. It now fails as a
ConfigError(see 3).2.
config_from_tomlinside the TOML is ignored, with a warningThe same filter drops it, so the anchor no longer moves to
confdir/<dir of that name>. The pin testtest_config_from_toml_set_in_the_toml_moves_the_anchoris flipped to…_is_ignored, and the docs now say the key is conf.py /-Donly. I chose to warn rather than skip silently, for the reason item 1 gives: otherwise a key the user wrote would do nothing without any notice.3. Schema errors are a
sphinx.errors.ConfigErrorcheck_sphinx_configurationused to raise a bareException, which Sphinx wrapped in anExtensionErrorwith the crash banner. It now raises aConfigErrorwith anInvalid sphinx-codelinks configuration:header, whichEventManager.emitpasses through unchanged. "in filed" is now "in field".Tests
test_src_trace.py: unknown top-level and project keys (parametrised over the runtime-only keys too), the flippedconfig_from_tomltest, a suppressibility test, and aConfigErrortest for both a TOML type error and an unknown conf.py project key.test_cmd.py:codelinks analyseexits 0, warns and writes its output for each of the three cases.Checks
uv run poe test-codelinks: 413 passed, 0 skippeduv run poe lint: cleanuv run poe typecheck: cleanuv run poe docs-codelinks: build succeeded