Description
Everett's sphinxext has an autocomponent
which will extract configuration information from a class.
What if the sphinxext supported extracting configuration information from a module? For example, in Django, one might have the following in a settings.py
file:
# settings.py
from everett.manager import ConfigManager
_config = ConfigManager.basic_config()
DEBUG = _config("debug", parser=bool, help="Whether or not to run in debug mode.")
Because _config
is evaluated at module load time, DEBUG
ends up with a value and loses the _config
call information, so the sphinxext can't import the module and look at the contents. The sphinxext could parse the file and traverse that looking for specific function calls and extract the information that way.
.. autoconfigmodule:: path/to/module.py
One thing I'm seeing immediately is that we have to make sure to traverse the whole tree and not just top-level. There could be calls in if
blocks. Also, I'm not sure what we do if there are multiple _config
calls for the same variable. I guess we could go with the first one. We'd want to note that behavior.
This issue covers tinkering with that.
Activity