Add autosummary_filename_map config to avoid clashes#7927
Add autosummary_filename_map config to avoid clashes#7927tk0miya merged 8 commits intosphinx-doc:3.xfrom
Conversation
|
[fixed branching and force-pushed.] |
tk0miya
left a comment
There was a problem hiding this comment.
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.
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
sphinx/sphinx/builders/latex/__init__.py
Line 558 in 98a854d
sphinx/ext/autosummary/__init__.py
Outdated
| 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.
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. |
tk0miya
left a comment
There was a problem hiding this comment.
LGTM with nits. I'll merge this after the fix soon.
|
Just merged. Thank you for your contribution! |
Subject: Add
autosummary_filename_mapconfig to allow users to configure alternative filenames for autodoc objects, avoiding name clashes on case-insensitive file systems.Feature or Bugfix
Purpose
autosummary_filename_mapto do so. It is a simple dict between name and filename to be generated.Relates