summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-23 23:05:33 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-24 15:13:09 +0200
commit13902f1812697bac01ea1172663a6eedd20ac9d5 (patch)
tree832e7d87df696e5590e4400782f8801aa55d657b /docs
parentf0899127486265fc66632631cf542da5ff7c9b6f (diff)
downloadsemantic-version-13902f1812697bac01ea1172663a6eedd20ac9d5.tar.gz
Add `Version.truncate()`.
This simplifies computing neighbouring versions.
Diffstat (limited to 'docs')
-rw-r--r--docs/reference.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/reference.rst b/docs/reference.rst
index 58aa320..f9b4aed 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -181,6 +181,20 @@ Representing a version (the Version class)
:attr:`prerelease` component: it's the smallest "pure"
patch version strictly greater than that version.
+ .. method:: truncate(self, level='patch']):
+
+ Returns a similar level, but truncated at the provided level.
+
+ .. code-block:: pycon
+
+ >>> Version('1.0.2-rc1+b43.24').truncate()
+ Version('1.0.2')
+ >>> Version('1.0.2-rc1+b43.24').truncate('minor')
+ Version('1.0.0')
+ >>> Version('1.0.2-rc1+b43.24').truncate('prerelease')
+ Version('1.0.2-rc1')
+
+
.. method:: __iter__(self)
Iterates over the version components (:attr:`major`, :attr:`minor`,