mike
frequenz.repo.config.mkdocs.mike
¤
Tools to work with mike.
This module provides these tools:
- Building the mike version information from the repository information
(
build_mike_version()
). - Sorting the mike version information
version.json
file (sort_mike_versions()
). - Comparing mike versions
(
compare_mike_version()
).
Mike versions have the format vX.Y(-pre|-dev)?
, where X
is the major version, Y
is
the minor version, and the optional suffix is either -pre
for pre-release versions or
-dev
for development versions.
Stable (tagged) versions have the format vX.Y
, unless they are pre-release versions,
then they have the format vX.Y-pre
. Develoment branches have the format vX.Y-dev
.
- Tag
v1.0.0
->v1.0
- Tag
v2.1.0-alpha.1
->v2.1-pre
- Branch
v1.x.x
(with no releases) ->v1.0-dev
- Branch
v1.x.x (with releases an existing release, for example
v1.0.0) ->
v1.1-dev` - Branch
v1.1.x
->v1.1-dev
Aliases have the format vX(-pre|-dev)?
, where X
is the major version and the
optional suffix is either -pre
for pre-release versions or -dev
for development
versions. An alias is also provided to point to the latest version, which is latest
for stable versions, latest-pre
for pre-release versions, and latest-dev
for
development versions.
Classes¤
frequenz.repo.config.mkdocs.mike.MikeVersionInfo
dataclass
¤
The information needed to publish a mike version.
This is what mike needs when publishing documentation for a particular version.
Source code in frequenz/repo/config/mkdocs/mike.py
Functions¤
frequenz.repo.config.mkdocs.mike.build_mike_version(repo_info)
¤
Build the mike version information from the given repository information.
The version is build based on if a tag or a branch is checked out.
For tags, the title is the tag name, the version is "vX.Y", where X is the major version and Y is the minor version of the tag. If the tag is the last minor version for the major version, the alias "vX" is added. If the tag is the latest tag, the alias "latest" is added.
For pre-release tags it's the same but the "-pre" suffix is added to the version and the aliases.
For branches, the title is "vX.Y-dev (SHA)", where X is the major version and Y is the minor version of the branch. The version is "vX.Y-dev". If the branch is the latest branch, the alias "latest-dev" is added.
PARAMETER | DESCRIPTION |
---|---|
repo_info |
The repository information.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
MikeVersionInfo
|
The mike version. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the given repository information is invalid or versions can't be determined for some other reason. |
Source code in frequenz/repo/config/mkdocs/mike.py
frequenz.repo.config.mkdocs.mike.compare_mike_version(version1, version2)
¤
Compare two versions.
The versions are compared as follows:
- Versions are first compared by major version (
X
). - If they have the same major, then they are compared by minor version (
Y
). - If they have the same major and minor, then pre-releases (
vX.Y-pre
) are considered bigger than stable versions (vX.Y
) and development versions (vX.Y-dev
) are considered bigger than pre-releases. - Any other version not matching
vX.Y(-pre|-dev)?
is considered to be bigger than the matching versions. - Not matching versions are compared alphabetically.
Example:
`v1.0` < `v1.0-pre` < `v1.0-dev` < `v1.1` < `v2.0` < `v2.0-pre` < `v2.0-dev`
< `whatever` < `x`.
PARAMETER | DESCRIPTION |
---|---|
version1 |
The first version to compare.
TYPE:
|
version2 |
The second version to compare.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
int
|
A negative number if |
Source code in frequenz/repo/config/mkdocs/mike.py
frequenz.repo.config.mkdocs.mike.sort_mike_versions(versions, *, reverse=True)
¤
Sort mike
's version.json
file with a custom order.
The version
keys are expected as follows:
vX.Y
for stable release versionsvX.Y-pre
for pre-release versionsvX.Y-dev
for development versions- Any other arbitrary string for other versions
The sorting order is as follows:
- Versions are first sorted by major version (
X
). - Inside a major version group, versions are sorted by minor version (
Y
). - For the same major and minor version, development versions (
-dev
) considered the latest for that major version group, then pre-release versions (-pre
), and finally stable versions. - Other versions appear first and are sorted alphabetically.
The versions are sorted in-place using
compare_mike_version()
.
Example:
`z`, `whatever`, `v2.1-dev`, `v2.1-pre`, `v2.0`, `v1.1-dev`, `v1.0-dev`, `v1.0`
PARAMETER | DESCRIPTION |
---|---|
versions |
The list of versions to sort.
TYPE:
|
reverse |
Whether to sort in reverse order.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
list[MikeVersionInfo]
|
The sorted list of versions. |