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 autosummary_filename_map config to avoid clashes #7927
Conversation
[fixed branching and force-pushed.] |
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! I'll merge this after your update soon :-)
tests/roots/test-ext-autosummary-filename-map/autosummary_dummy_module.py
Outdated
Show resolved
Hide resolved
Thank you for the review. I hope I have addressed all comments. |
sphinx/ext/autosummary/generate.py
Outdated
filename_map = app.config.autosummary_filename_map | ||
if not isinstance(filename_map, Mapping): | ||
raise TypeError('autosummary_filename_map should be a mapping from ' | ||
'strings to strings') |
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 value is dict here. The Sphinx automatically checks the given value is the same type as the default value. But it does not check the contents of the dict. I think the default check is enough.
Note: If you'd like to add more careful validations, please use a hook for the config-inited event to validate user configurations.
sphinx/sphinx/builders/latex/__init__.py
Lines 498 to 503 in 98a854d
def validate_latex_theme_options(app: Sphinx, config: Config) -> None: | |
for key in list(config.latex_theme_options): | |
if key not in Theme.UPDATABLE_KEYS: | |
msg = __("Unknown theme option: latex_theme_options[%r], ignored.") | |
logger.warning(msg % (key,)) | |
config.latex_theme_options.pop(key) |
sphinx/sphinx/builders/latex/__init__.py
Line 558 in 98a854d
app.connect('config-inited', validate_latex_theme_options, priority=800) |
sphinx/ext/autosummary/__init__.py
Outdated
@@ -790,5 +790,6 @@ def setup(app: Sphinx) -> Dict[str, Any]: | |||
app.add_config_value('autosummary_mock_imports', | |||
lambda config: config.autodoc_mock_imports, 'env') | |||
app.add_config_value('autosummary_imported_members', [], False, [bool]) | |||
app.add_config_value('autosummary_filename_map', {}, 'html') |
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.
It is better to add a new config variable alphabetically. Could you move this above?
(I noticed autosummary_imported_members
is not. I'll fix it later)
Tried this for scikit-learn and got an expected warning:
|
Oops. |
I don't really understand... Is there something I should change?
|
I think some fix is needed to here. Is my understanding incorrect? sphinx/sphinx/ext/autosummary/__init__.py Lines 255 to 257 in 03e1070
|
Seems reasonable. I suppose I need to come up with a test case. |
This is ready for review. |
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. I'll merge this after the fix soon.
Just merged. Thank you for your contribution! |
Subject: Add
autosummary_filename_map
config to allow users to configure alternative filenames for autodoc objects, avoiding name clashes on case-insensitive file systems.Feature or Bugfix
Purpose
autosummary_filename_map
to do so. It is a simple dict between name and filename to be generated.Relates