You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #285 we discussed some ways that Jupyter Book's behavior could be brought into Sphinx. One suggestion was to allow for Jupyter Book's YAML-based configuration in Sphinx.
Currently this is challenging because Sphinx treats conf.py as a special file and so expects it to exist. This is an issue to think about a pattern that might get around this with minimal disruption. Over time, perhaps it can be inspiration for an upstream into Sphinx itself.
Create a Sphinx Extension called sphinx-yaml-config. This extension would run early in the build process, and look for a file called either conf.yml or config.yml or _config.yml. If found, it would read in the key/vals as if it was conf.py configuration.
The extension would also provide a hook that would be called on the configuration before it was translated to conf.py configuration. This way we could use this hook to do the "Jupyter Book" -> "Sphinx" translation for some config values.
When building a Sphinx site, tell users to use the -C option, which tells Sphinx not to use conf.py, along with the the -D option to pass through manual configuration from the CLI.
Users would pass a single configuration value, telling Sphinx to activate the YAML extension, something like this:
sphinx-build -C -D extensions=yaml_config -b html source/ output/
I think that this would then load the YAML config as expected, without Sphinx complaining that no configuration at all was presented.
update: apparently I had already considered doing this a year ago 😆 here's a tiny unfinished prototype of what the tool could look like:
This would still feel a bit clunky because users would have to manually call sphinx-build. Does anybody see an alternative to this?
How can we still support the ability to call custom Python from config.yml? In that case do we direct people to also use conf.py? Is there a way to run this code manually during the build process?
The text was updated successfully, but these errors were encountered:
Ah I think this would actually be harder than expected, because I believe Sphinx only loads extensions upon launch. So you could update almost all of the configuration except for extensions, which Sphinx assumes had already been loaded before then.
Yea, I think this might need to be something that is built into Sphinx itself. Might be worth having the discussion in their issue tracker to see if there's much interest if someone wants to do a PR for it.
In #285 we discussed some ways that Jupyter Book's behavior could be brought into Sphinx. One suggestion was to allow for Jupyter Book's
YAML
-based configuration in Sphinx.Currently this is challenging because Sphinx treats
conf.py
as a special file and so expects it to exist. This is an issue to think about a pattern that might get around this with minimal disruption. Over time, perhaps it can be inspiration for an upstream into Sphinx itself.Create a Sphinx Extension called
sphinx-yaml-config
. This extension would run early in the build process, and look for a file called eitherconf.yml
orconfig.yml
or_config.yml
. If found, it would read in the key/vals as if it wasconf.py
configuration.The extension would also provide a hook that would be called on the configuration before it was translated to
conf.py
configuration. This way we could use this hook to do the "Jupyter Book" -> "Sphinx" translation for some config values.When building a Sphinx site, tell users to use the
-C
option, which tells Sphinx not to useconf.py
, along with the the-D
option to pass through manual configuration from the CLI.Users would pass a single configuration value, telling Sphinx to activate the YAML extension, something like this:
I think that this would then load the YAML config as expected, without Sphinx complaining that no configuration at all was presented.
update: apparently I had already considered doing this a year ago 😆 here's a tiny unfinished prototype of what the tool could look like:
https://github.com/choldgraf/sphinx-yaml-metadata/blob/master/sphinx_yaml_metadata/__init__.py#L8
Unanswered questions
sphinx-build
. Does anybody see an alternative to this?config.yml
? In that case do we direct people to also useconf.py
? Is there a way to run this code manually during the build process?The text was updated successfully, but these errors were encountered: