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
Local autodoc options override or extend autodoc_default_options. #8297
Conversation
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.
I'm still debating it would be better to add a way "not" to extend the global option too. How about a hint notation "+"?
.. automodule::
:exclude-members: +foo,bar,baz
That is interesting suggestion, by "not" extending you mean to simply override it? Hint notation with "+" looks good to me. What about to make it "+/-" ? |
Yes. My thought is
About a minus sign, it's not late to write a code if somebody will request it. |
+1 to @tk0miya 's idea. |
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.
LGTM with nits for the code. Addition to this, could you update document for autodoc (doc/usage/extensions/autodoc.rst)?
if name in options: | ||
# take value from options if present or extend it | ||
# with autodoc_default_options if necessary | ||
if name in AUTODOC_EXTENDABLE_OPTIONS: |
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.
Please check autodoc_default_options[name]
is string here. It can take boolean value or None also. When it equals to True or None, it matches all of members. So enhancement is meaningless.
sphinx/ext/autodoc/directive.py
Outdated
else: | ||
options[name] = config.autodoc_default_options[name] | ||
|
||
elif isinstance(options.get(name), str) and options[name].startswith('+'): |
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.
You don't need to check the options.get(name)
via isinstance because it's always a string if given. It's enough to check options.get(name) is not None
only.
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.
That makes sense, so there were mistakes in already existing tests I think:
https://github.com/sphinx-doc/sphinx/blob/3.x/tests/test_ext_autodoc.py#L940
https://github.com/sphinx-doc/sphinx/blob/3.x/tests/test_ext_autodoc.py#L868
etc.
I replaced these True
's with None
.
@shimizukawa Thank you for comment. |
Merged. Thank you for your great contribution! |
The function sphinx.ext.autodoc.directive.process_documenter_options() used in do_autodoc() changed its option processing. See sphinx-doc/sphinx#8297 for more information.
The function sphinx.ext.autodoc.directive.process_documenter_options() used in do_autodoc() changed its option processing. See sphinx-doc/sphinx#8297 for more information.
Subject: local :exclude-members: extends global option instead of being replaced by it
Feature or Bugfix
Purpose