Skip to content

Make our versions.json support a top-level dictionary instead of just a list #786

@choldgraf

Description

@choldgraf

Context

In our version switching implementation, we currently ask people to provide a JSON file that is a list of entries, each of which corresponds to a version. Something like:

  {
    "name": "dev",
    "version": "latest",
    "description": "the development version",
    "url": "https://pydata-sphinx-theme.readthedocs.io/en/latest/"
  },
  {
    "name": "0.10.0 (stable)",
    "version": "stable",
    "preferred": "true",
    "url": "https://pydata-sphinx-theme.readthedocs.io/en/stable/"
  },

However, there may be cases where we want to configure behavior changes for the switcher across all versions of documentation without requiring them to edit conf.py in each version. In that case, we need a single place to define the new configuration.

One example of this is discussed in:

Proposal

I propose that we allow the switcher.json structure to also be a dictionary instead of just a list of entries.

If switcher.json is a dictionary, then it must have a key versions: <list-of-entries>, where <list-of-entries> is the structure we currently support. It may also have other keys that configure it in different ways (e.g. preferred: "some-version")

If switcher.json is a list, then assume it is just <list-of-entries> with no extra configuration (AKA, the current behavior).

I think this would let us extend the functionality of the version switcher, without breaking current implementations, and without being too brittle since the check of "is it a dict or a list" is pretty straightforward.

Any objections / suggestions otherwise?

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