Closed
Description
Using a configuration like this:
sphinx_gallery_conf = {
"within_subsection_order": FileNameSortKey,
}
Results in unecessary rebuilds and also in a warning using the latest sphinx, because this config is not serializable:
from sphinx.confing import is_serializable
assert is_serializable(sphinx_gallery_conf)
The warning emitted with sphinx 7.3.5 is:
looking for now-outdated files... none found
WARNING: cannot cache unpickable configuration value: 'sphinx_gallery_conf'
pickling environment... done
checking consistency... done
preparing documents... done
One way would be using strings with a registry of types:
sphinx_gallery_conf = {
"within_subsection_order": "filename_sort_key",
}
to still allow users to pass their own implementations, you could use something like:
sort_keys = {}
class SortKey:
def __init_subclass__(cls, config_name):
if config_name in sort_keys:
raise ValueError("config_name must be unique")
sort_keys[config_name] = cls
class FilenameSortKey(SortKey, config_name="filename_sort_key"):
def __call__(self, filename):
return filename
Metadata
Metadata
Assignees
Labels
No labels