Program Options¶
If you do need to customize docs-versions-menu
’s behavior, there are two options:
Call the
docs-versions-menu
executable with explicit command line optionsSet
DOCS_VERSIONS_MENU_*
environment variables, each variable corresponding to a command line option
The latter option is generally preferred.
Download links¶
By default, docs-versions-menu
looks for a file _downloads
inside each
folder that appears in the menu. Each line in this file should have the
markdown-like format [label]: url
, e.g.
[html]: https://dl.bintray.com/goerz/docs_versions_menu/docs_versions_menu-v0.1.0.zip
These links will be shown in the versions menu in a section “Downloads”, using
the label as the link text. The name of the file can be changed via the
DOCS_VERSIONS_MENU_DOWNLOADS_FILE
environment variable (see
--downloads-file
).
See Github Releases for an example workflow of creating a suitable
_downloads
file from an annotated git tag.
If the _downloads
file is missing, you will see a warning message during
the deploy. To disable use of a _downloads
file (ignore existing files, and
don’t warn for missing files), set DOCS_VERSIONS_MENU_DOWNLOADS_FILE
to an
empty string (see --no-downloads-file
).
Debugging¶
If the docs-versions-menu
command behaves unexpectedly, set the environment variable
DOCS_VERSIONS_MENU_DEBUG=true
or use the --debug
option.
Make sure to include the debug output when reporting bugs.
Folders¶
The entries in the versions menu are based on the folders that are present in the deployed documentation root. We assume here that the folder names correspond to branch or tag names in the project repository. This is irrespective of the label that appears for given foler in the menu, see below.
By default, the versions menu lists the folder for the default branch (main
or master
, see --default-branch
) first, then any releases from
newest to oldest, and then any non-release branches in reverse-alphabetical
order. Having the “newest” releases appear first matches the behavior of
Read-the-Docs.
The folders that are listed in the versions menu and their order can be
customized via the --versions
flag (DOCS_VERSIONS_MENU_VERSIONS
environment variable).
This receives a folder specification as an argument that
specifies the folders to appear in the menu in reverse order (bottom/right to
top/left).
To un-reverse the default order of folders in the menu, so that the newest versions and the default branch appear last, you would set
DOCS_VERSIONS_MENU_VERSIONS: '((<branches> not in <default-branch>), <releases>, <default-branch>)[::-1]'
in the definitions of environment variables.
Custom warning messages¶
By default, the docs_versions_menu
extension injects warnings in the
rendered HTML files, within the following types of folders:
an ‘outdated’ warning for
<releases>
older than the latest public release (identified by--latest
)an ‘unreleased’ warning for
<branches>
(anything that is not a PEP 440-conforming release), or<local-releases>
(typically not used)a ‘prereleased’ warning for anything considered a pre-release by PEP 440, e.g.
v1.0.0-rc1
Which folders are included in the above three categories can be modified via the --warning
option.
This options receives two arguments, a “warning label” string (the above
‘outdated’, ‘unreleased’, or ‘prereleased’), and a
folder specification for the
folders to which the warning should apply. The option can be given multiple
times. An empty specification would disable the warning, e.g.
docs-versions-menu --warning prereleased ''
to disable the warning message on pre-releases.
It is also possible to define entirely new warning labels using --warning
. For example,
docs-versions-menu --warning post '<post-releases>'
would define a warning ‘post’ for all post-releases.
The information about which folders should display which warnings is stored
internally in the resulting versions.json
file, in a dict ‘warnings’ that
maps folder names to a list of warning labels.
To actually show this new custom warning, the docs-versions-menu.js template would have to be modified to pick up on the ‘post’ label.
Similarly to Menu labels, when configuring the warnings
via the DOCS_VERSIONS_MENU_WARNING
environment variable, multiple
--warning
options are combined into a single value, separated by
semicolons, and the warning label and folder specification separated by a
colon.
For the above two options, you might include the following the definition of the environment variables in a Github Actions workflow:
DOCS_VERSIONS_MENU_WARNING: 'post: <post-relases>; prereleased:'