@@ -14,9 +14,10 @@ are met.
14
14
Knowing the Implemented semver.org Version
15
15
------------------------------------------
16
16
17
- The semver.org is the authorative specification of how semantical versioning is
18
- definied. To know which version of semver.org is implemented in the semver
19
- libary, use the following constant::
17
+ The semver.org page is the authorative specification of how semantical
18
+ versioning is definied.
19
+ To know which version of semver.org is implemented in the semver libary,
20
+ use the following constant::
20
21
21
22
>>> semver.SEMVER_SPEC_VERSION
22
23
'2.0.0'
@@ -25,6 +26,25 @@ libary, use the following constant::
25
26
Creating a Version
26
27
------------------
27
28
29
+ Due to historical reasons, the semver project offers two ways of
30
+ creating a version:
31
+
32
+ * through an object oriented approach with the :class: `semver.VersionInfo `
33
+ class. This is the preferred method when using semver.
34
+
35
+ * through module level functions and builtin datatypes (usually strings
36
+ and dicts).
37
+ These method are still available for compatibility reasons, but are
38
+ marked as deprecated. Using one of these will emit a DeprecationWarning.
39
+
40
+
41
+ .. warning :: **Deprecation Warning**
42
+
43
+ Module level functions are marked as *deprecated * in version 2.9.2 now.
44
+ These functions will be removed in semver 4.
45
+ For details, see section :ref: `sec_replace_deprecated_functions `.
46
+
47
+
28
48
A version can be created in different ways:
29
49
30
50
* as a complete version string::
@@ -362,8 +382,96 @@ For example:
362
382
363
383
.. code-block :: python
364
384
365
- >> > coerce(" v1.2" )
385
+ >> > coerce(" v1.2" )
366
386
(VersionInfo(major = 1 , minor = 2 , patch = 0 , prerelease = None , build = None ), ' ' )
367
387
>> > coerce(" v2.5.2-bla" )
368
388
(VersionInfo(major = 2 , minor = 5 , patch = 2 , prerelease = None , build = None ), ' -bla' )
369
389
390
+
391
+ .. _sec_replace_deprecated_functions :
392
+
393
+ Replacing Deprecated Functions
394
+ ------------------------------
395
+
396
+ The development team of semver has decided to deprecate certain functions on
397
+ the module level. The preferred way of using semver is through the
398
+ :class: `semver.VersionInfo ` class.
399
+
400
+ The deprecated functions can still be used until semver 3. In version 4 of
401
+ semver, the deprecated functions will be removed.
402
+
403
+ The following list shows the deprecated functions and how you can replace
404
+ them with code which is compatible for future versions:
405
+
406
+
407
+ * :func: `semver.bump_major `, :func: `semver.bump_minor `, :func: `semver.bump_patch `, :func: `semver.bump_prerelease `, :func: `semver.bump_build `
408
+
409
+ Replace them with the respective methods of the :class: `semver.VersionInfo `
410
+ class.
411
+ For example, the function :func: `semver.bump_major ` is replaced by
412
+ :func: `semver.VersionInfo.bump_major ` and calling the ``str(versionobject) ``:
413
+
414
+ .. code-block :: python
415
+
416
+ >> > s1 = semver.bump_major(" 3.4.5" )
417
+ >> > s2 = str (semver.VersionInfo.parse(" 3.4.5" ).bump_major())
418
+ >> > s1 == s2
419
+ True
420
+
421
+ Likewise with the other module level functions.
422
+
423
+ * :func: `semver.finalize_version `
424
+
425
+ Replace it with :func: `semver.VersionInfo.finalize_version `:
426
+
427
+ .. code-block :: python
428
+
429
+ >> > s1 = semver.finalize_version(' 1.2.3-rc.5' )
430
+ >> > s2 = str (semver.VersionInfo.parse(' 1.2.3-rc.5' ).finalize_version())
431
+ >> > s1 == s2
432
+ True
433
+
434
+ * :func: `semver.format_version `
435
+
436
+ Replace it with ``str(versionobject) ``:
437
+
438
+ .. code-block :: python
439
+
440
+ >> > s1 = semver.format_version(5 , 4 , 3 , ' pre.2' , ' build.1' )
441
+ >> > s2 = str (semver.VersionInfo(5 , 4 , 3 , ' pre.2' , ' build.1' ))
442
+ >> > s1 == s2
443
+ True
444
+
445
+ * :func: `semver.parse `
446
+
447
+ Replace it with :func: `semver.VersionInfo.parse ` and
448
+ :func: `semver.VersionInfo.to_dict `:
449
+
450
+ .. code-block :: python
451
+
452
+ >> > v1 = semver.parse(" 1.2.3" )
453
+ >> > v2 = semver.VersionInfo.parse(" 1.2.3" ).to_dict()
454
+ >> > v1 == v2
455
+ True
456
+
457
+ * :func: `semver.parse_version_info `
458
+
459
+ Replace it with :func: `semver.VersionInfo.parse `:
460
+
461
+ .. code-block :: python
462
+
463
+ >> > v1 = semver.parse_version_info(" 3.4.5" )
464
+ >> > v2 = semver.VersionInfo.parse(" 3.4.5" )
465
+ >> > v1 == v2
466
+ True
467
+
468
+ * :func: `semver.replace `
469
+
470
+ Replace it with :func: `semver.VersionInfo.replace `:
471
+
472
+ .. code-block :: python
473
+
474
+ >> > s1 = semver.replace(" 1.2.3" , major = 2 , patch = 10 )
475
+ >> > s2 = str (semver.VersionInfo.parse(' 1.2.3' ).replace(major = 2 , patch = 10 ))
476
+ >> > s1 == s2
477
+ True
0 commit comments