8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- //! Semver parsing and logic
12
-
13
- #[ allow( missing_doc) ] ;
14
-
11
+ //! Semantic version parsing and comparison.
12
+ //!
13
+ //! Semantic versioning (see http://semver.org/) is a set of rules for
14
+ //! assigning version numbers intended to convey meaning about what has
15
+ //! changed, and how much. A version number has five parts:
16
+ //!
17
+ //! * Major number, updated for incompatible API changes
18
+ //! * Minor number, updated for backwards-compatible API additions
19
+ //! * Patch number, updated for backwards-compatible bugfixes
20
+ //! * Pre-release information (optional), preceded by a hyphen (`-`)
21
+ //! * Build metadata (optional), preceded by a plus sign (`+`)
22
+ //!
23
+ //! The three mandatory components are required to be decimal numbers. The
24
+ //! pre-release information and build metadata are required to be a
25
+ //! period-separated list of identifiers containing only alphanumeric
26
+ //! characters and hyphens.
27
+ //!
28
+ //! An example version number with all five components is
29
+ //! `0.8.1-rc.3.0+20130922.linux`.
15
30
16
31
use std:: char;
17
32
use std:: cmp;
@@ -20,6 +35,8 @@ use std::io;
20
35
use std:: option:: { Option , Some , None } ;
21
36
use std:: to_str:: ToStr ;
22
37
38
+ /// An identifier in the pre-release or build metadata. If the identifier can
39
+ /// be parsed as a decimal value, it will be represented with `Numeric`.
23
40
#[ deriving( Clone , Eq ) ]
24
41
pub enum Identifier {
25
42
Numeric ( uint ) ,
@@ -49,12 +66,20 @@ impl ToStr for Identifier {
49
66
}
50
67
51
68
69
+ /// Represents a version number conforming to the semantic versioning scheme.
52
70
#[ deriving( Clone , Eq ) ]
53
71
pub struct Version {
72
+ /// The major version, to be incremented on incompatible changes.
54
73
major : uint ,
74
+ /// The minor version, to be incremented when functionality is added in a
75
+ /// backwards-compatible manner.
55
76
minor : uint ,
77
+ /// The patch version, to be incremented when backwards-compatible bug
78
+ /// fixes are made.
56
79
patch : uint ,
80
+ /// The pre-release version identifier, if one exists.
57
81
pre : ~[ Identifier ] ,
82
+ /// The build metadata, ignored when determining version precedence.
58
83
build : ~[ Identifier ] ,
59
84
}
60
85
@@ -202,6 +227,7 @@ fn parse_reader(rdr: @io::Reader) -> Version {
202
227
}
203
228
204
229
230
+ /// Parse a string into a semver object.
205
231
pub fn parse ( s : & str ) -> Option < Version > {
206
232
if !s. is_ascii ( ) {
207
233
return None ;
0 commit comments