Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow configuration of sort orders in a way that does not mess with the sphinx cache #1286

Copy link
Copy link
Closed
@maxnoe

Description

@maxnoe
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.