summaryrefslogtreecommitdiff
path: root/docs
diff options
Diffstat (limited to 'docs')
-rw-r--r--docs/version.rst62
1 files changed, 61 insertions, 1 deletions
diff --git a/docs/version.rst b/docs/version.rst
index 8eed735..ff58c51 100644
--- a/docs/version.rst
+++ b/docs/version.rst
@@ -86,6 +86,18 @@ Reference
version number, including trailing zeroes but not including the epoch
or any prerelease/development/postrelease suffixes
+ .. attribute:: major
+
+ An integer representing the first item of :attr:`release` or ``0`` if unavailable.
+
+ .. attribute:: minor
+
+ An integer representing the second item of :attr:`release` or ``0`` if unavailable.
+
+ .. attribute:: micro
+
+ An integer representing the third item of :attr:`release` or ``0`` if unavailable.
+
.. attribute:: local
A string representing the local version portion of this ``Version()``
@@ -139,6 +151,52 @@ Reference
:param str version: The string representation of a version which will be
used as is.
+ .. note::
+
+ :class:`LegacyVersion` instances are always ordered lower than :class:`Version` instances.
+
+ >>> from packaging.version import Version, LegacyVersion
+ >>> v1 = Version("1.0")
+ >>> v2 = LegacyVersion("1.0")
+ >>> v1 > v2
+ True
+ >>> v3 = LegacyVersion("1.3")
+ >>> v1 > v3
+ True
+
+ Also note that some strings are still valid PEP 440 strings (:class:`Version`), even if they look very similar to
+ other versions that are not (:class:`LegacyVersion`). Examples include versions with `Pre-release spelling`_ and
+ `Post-release spelling`_.
+
+ >>> from packaging.version import parse
+ >>> v1 = parse('0.9.8a')
+ >>> v2 = parse('0.9.8beta')
+ >>> v3 = parse('0.9.8r')
+ >>> v4 = parse('0.9.8rev')
+ >>> v5 = parse('0.9.8t')
+ >>> v1
+ <Version('0.9.8a0')>
+ >>> v1.is_prerelease
+ True
+ >>> v2
+ <Version('0.9.8b0')>
+ >>> v2.is_prerelease
+ True
+ >>> v3
+ <Version('0.9.8.post0')>
+ >>> v3.is_postrelease
+ True
+ >>> v4
+ <Version('0.9.8.post0')>
+ >>> v4.is_postrelease
+ True
+ >>> v5
+ <LegacyVersion('0.9.8t')>
+ >>> v5.is_prerelease
+ False
+ >>> v5.is_postrelease
+ False
+
.. attribute:: public
A string representing the public version portion of this
@@ -225,4 +283,6 @@ Reference
``re.VERBOSE`` and ``re.IGNORECASE`` flags set.
-.. _`PEP 440`: https://www.python.org/dev/peps/pep-0440/
+.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
+.. _Pre-release spelling : https://www.python.org/dev/peps/pep-0440/#pre-release-spelling
+.. _Post-release spelling : https://www.python.org/dev/peps/pep-0440/#post-release-spelling