summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-24 14:04:55 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-26 21:34:44 +0200
commitc415ee4cd87915191b1ca8df2d3fbf7e49d4bbbf (patch)
tree4192534d6ed4c301cd640417f50223925bd0240e /docs
parent47fc7229ba24de0610134cadcc61884c6097f4fe (diff)
downloadsemantic-version-c415ee4cd87915191b1ca8df2d3fbf7e49d4bbbf.tar.gz
Add `Version.precedence_key`.
This will be used in `sort(..., key=lambda v: v.precedence_key)`. Remove previous comparison/ordering implementation. The current implementation relies on a 4-tuple: - major, minor, patch (as integers) - natural order matches precedence rules - a tuple of identifiers for the prerelease component. The identifiers for the prerelease components are based on: - A `NumericIdentifier` class, that compares number using their natural order, and always compares lower than non-numeric identifiers - A `AlphaIdentifier` class for non-numeric identifiers; it compares versions using ASCII ordering. - A `MaxIdentifier` class, that compares higher to any other identifier; used to ensure that a non-prerelease version is greater than any of its prereleases.
Diffstat (limited to 'docs')
-rw-r--r--docs/reference.rst7
1 files changed, 7 insertions, 0 deletions
diff --git a/docs/reference.rst b/docs/reference.rst
index 62a2b3b..3495940 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -128,6 +128,13 @@ Representing a version (the Version class)
May be ``None`` for a :attr:`partial` version number in a ``<major>``, ``<major>.<minor>``,
``<major>.<minor>.<patch>`` or ``<major>.<minor>.<patch>-<prerelease>`` format.
+ .. attribute:: precedence_key
+
+ Read-only attribute; suited for use in ``sort(versions, key=lambda v: v.precedence_key)``.
+ The actual value of the attribute is considered an implementation detail; the only
+ guarantee is that ordering versions by their precedence_key will comply with semver precedence rules.
+
+ Note that the :attr:`~Version.build` isn't included in the precedence_key computatin.
.. rubric:: Methods