-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add sphinx.ext.apidoc
extension
#13220
base: master
Are you sure you want to change the base?
Conversation
A common use-case is that users simply want to point Sphinx towards a Python module, and have it generate documentation automatically. This is not possible currently, without a "pre-build" step of running the `sphinx-autogen` CLI. This PR adds `sphinx.ext.apidoc` as a sphinx extension, to incorporate the source file generation into the sphinx build. Co-authored-by: Chris Sewell <[email protected]>
Could this get at least a minimal doc page under https://github.com/sphinx-doc/sphinx/tree/master/doc/usage/extensions? |
6ef8b3d
to
a124142
Compare
{'destination': 'source/', 'path': 'path/to/module'}, | ||
{ | ||
'destination': 'source/', | ||
'path': 'path/to/another_module', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I would put 'path' first. The module to be documented is the main aspect.
{'destination': 'source/', 'path': 'path/to/module'}, | |
{ | |
'destination': 'source/', | |
'path': 'path/to/another_module', | |
{'path': 'path/to/module', 'destination': 'source/'}, | |
{ | |
'path': 'path/to/another_module', | |
'destination': 'source/', |
Alternatively, the modules are so prominent that one could make them keys of a dict:
apidoc_modules = {
'path/to/module': {'destination': 'source/'},
'path/to/other_module': {
'destination': 'source/',
'exclude_patterns': ['**/test*'],
'maxdepth': 4,
'followlinks': False,
'separatemodules': False,
'includeprivate': False,
'noheadings': False,
'modulefirst': False,
'implicit_namespaces': False,
},
}
:type: :code-py:`Sequence[dict[str, Any]]` | ||
:default: :code-py:`()` | ||
|
||
A list or sequence of dictionaries describing modules to document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a side note, I could see the case for making config parameters applying to all modules. This would remove the need for repeating a lot of keys for multiple modules.
apidoc_module_config = {
'followlinks': False,
'separatemodules': False,
'includeprivate': False,
'noheadings': False,
}
apidoc_modules = {
{'path': 'path/to/module'},
{'path': 'path/to/other_module'},
{'path': 'path/to/third_module', 'includeprivate': True}, # overriding global settings
}
Implementation-wise one would just merge the dicts apidoc_module_config
and the individual config dicts.
But that could also be added later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cc @chrisjsewell -- I just rebased the original PR so would prefer to have your input on larger design changes such as Tim suggests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AA-Turner I'll have a look in the next few days
# Conflicts: # sphinx/ext/apidoc/_shared.py
Purpose
A common use-case is that users simply want to point Sphinx towards a Python module, and have it generate documentation automatically.
This is not possible currently, without a "pre-build" step of running the
sphinx-autogen
CLI.This PR adds
sphinx.ext.apidoc
as a sphinx extension, to incorporate the source file generation into the sphinx build.Per the original PR, there is no documentation and two outstanding TODO comments in the PR.
References
sphinx.ext.apidoc
as an extension #12471cc @chrisjsewell