Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration options added by themes are not properly loaded #10061

Closed
pradyunsg opened this issue Jan 7, 2022 · 1 comment
Closed

Configuration options added by themes are not properly loaded #10061

pradyunsg opened this issue Jan 7, 2022 · 1 comment

Comments

@pradyunsg
Copy link
Contributor

pradyunsg commented Jan 7, 2022

Describe the bug

If you have a Sphinx theme that registers a configuration variable, that configuration variable is not loaded properly from the conf.py file -- i.e. is not accessible as app.config.{name}.

How to Reproduce

$ git clone https://github.com/pradyun/sphinx-configuration-bug.git
$ cd sphinx-configuration-bug
$ pip install .
$ sphinx-build docs/ docs/_build/
Running Sphinx v4.3.2
loading pickled environment... done
====================================================================================================
sorted(vars(config))=['_raw_config', 'epub_css_files', 'extensions', 'html_css_files', 'html_js_files', 'html_theme', 'numfig_format', 'overrides', 'setup', 'source_suffix', 'values']
config.sample_theme_configuration_value='default'
config._raw_config['sample_theme_configuration_value']='from conf.py'
====================================================================================================
sorted(vars(config))=['_raw_config', 'epub_css_files', 'extensions', 'html_css_files', 'html_js_files', 'html_theme', 'numfig_format', 'overrides', 'sample_theme_configuration_value', 'setup', 'source_suffix', 'values']
config.sample_theme_configuration_value='from conf.py'
config._raw_config['sample_theme_configuration_value']='from conf.py'
====================================================================================================
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
no targets are out of date.
build succeeded.

The HTML pages are in docs/_build.

The second section is what things look like, after running config.init_values() again.

Expected behavior

Configuration variables from the theme are loaded properly, without needing to re-initialize the configuration object.

Your project

https://github.com/pradyun/sphinx-configuration-bug/

Screenshots

No response

OS

MacOS (should happen on all OSes)

Python version

3.9, although unlikely to be implicated

Sphinx version

4.3.2

Sphinx extensions

None

Extra tools

No response

Additional context

I had first encountered this in Furo and couldn't figure out what's up. Some more investigation as a part of writing a follow up theme (python/docs-community#1) led to me hitting this again; which... lead to this bug report. :)

@pradyunsg pradyunsg changed the title Configuration options added by themes are not properly initialized Configuration options added by themes are not properly loaded Jan 7, 2022
@tk0miya tk0miya added this to the 4.4.0 milestone Jan 10, 2022
tk0miya added a commit that referenced this issue Jan 11, 2022
…not_initialized

Fix #10061: html theme: Confvals added by themes are not initialized
@pradyunsg
Copy link
Contributor Author

Thanks @tk0miya for the fix! 😄

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants