sphinx-doc / sphinx-doc/sphinx
Add static configuration (``Sphinx.toml``)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Background
One of the challenges in getting started with Sphinx is the conf.py file, for a few reasons:
- It is written in Python, and so it is Python-specific, even if the person writing the documentation is using a different language.
- It is a fully-flexible Python script, which can be overwhelming for users not accustomed to it.
Over the years, many other configuration formats have arisen, probably the two most well-known are YAML and TOML. For example. Jupyter Book provides a layer of YAML configuration on top of Sphinx. Users have responded that this is a really friendly pattern for beginners and experts alike. I wonder if Sphinx would be interested in allowing for YAML or TOML configuration as well.
Describe the solution you'd like
In addition to the current config option of conf.py, add another option:
Allow config with YAML. I think it would be useful if Sphinx allowed for:
conf.yml. This would be read-in with PyYAML.
This file would be read in and converted to Python variables directly, as if it was written in Python (conf.py). So for example:
# In conf.yml
key: value
mylist:
- item1
- item2
mydict:
dk1: one
dk2: two
would map onto
# In conf.py
key = "value"
mylist = ["item1", "item2"]
mydict = {"dk1": "one", "dk2": "two"}
Allow conf.py to be provided simultaneously. Some Sphinx builds will still need to run custom Python code (e.g., to set up some extensions etc). In this case, authors may wish to keep their "simple config" in the YAML file, and the complex config in pure Python.
If conf.py is supplied as well as conf.yml, then the environment defined in conf.py will over-rule anything in conf.yml.
So the order of operations would be:
- (if it exists) Read in variables from
conf.yaml - Update with variables from
conf.pyif it exists, overwriting variables created in 1 - Everything else is the same...
Describe alternatives you've considered
I've tried creating a lightweight extension that allows this but didn't have success because of the way that extensions are activated.
I have also considered other documentation engines like mkdocs, which use YAML, but I'd for this to be in the Sphinx ecosystem!
cc some others who have discussed this in the executablebooks/ repo: @pradyunsg @ericholscher @chrisjsewell
EDIT: I've updated the above description to remove mention of TOML, as I don't want that to derail conversation here!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing conf.py configuration behavior and the issue's proposed conf.yml examples. Check how configuration variables are loaded and overridden when both files exist. Done means Sphinx accepts conf.yml alongside conf.py, maps YAML values to configuration variables, and preserves the stated override order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, yaml
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100