Add godoc in markdown

This commit is contained in:
decentral1se 2021-08-08 19:05:39 +02:00
parent cab5274257
commit e4687405c0
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 160 additions and 78 deletions

View File

@ -18,85 +18,9 @@ implementation quite closely.
[renovate]: https://github.com/renovatebot/renovate/blob/main/lib/versioning/docker/readme.md
[renovate implementation]: https://github.com/renovatebot/renovate/tree/main/lib/datasource/docker
## go doc
## Documentation
```
package tagcmp // import "coopcloud.tech/tagcmp"
Package tagcmp provides image tag comparison operations.
VARIABLES
var CommitHashPattern = "^[a-f0-9]{7,40}$"
CommitHashPattern matches commit-like hash tags
var DotPattern = "([0-9]+)\\.([0-9]+)"
DotPattern matches tags which contain multiple versions
var EmptyPattern = "^$"
EmptyPattern matches when tags are missing
var ParametrizedPattern = "\\${.+}"
ParametrizedPattern matches when tags are parametrized
var StringPattern = "^[a-zA-Z]+$"
StringPattern matches when tags are only made up of alphabetic characters
FUNCTIONS
func IsParseable(tag string) bool
IsParseable determines if a tag is supported by this library
TYPES
type ByTag []Tag
ByTag sorts tags
func (t ByTag) Len() int
func (t ByTag) Less(i, j int) bool
func (t ByTag) Swap(i, j int)
type Tag struct {
Major string `json:",omitempty"` // major semver part
Minor string `json:",omitempty"` // minor semver part
MissingMinor bool // whether or not the minor semver part was left out
Patch string `json:",omitempty"` // patch semver part
MissingPatch bool // whether or not he patch semver part was left out
Suffix string // tag suffix (e.g. "-alpine")
UsesV bool // whether or not the tag uses the "v" prefix
}
func Parse(tag string) (Tag, error)
Parse converts an image tag into a structured data format. It aims to to
support the general case of tags which are "semver-like" and/or stable and
parseable by heuristics. Image tags follow no formal specification and
therefore this is a best-effort implementation. Examples of tags this
function can parse are: "5", "5.2", "v4", "v5.3.6", "4-alpine",
"v3.2.1-debian".
func (t Tag) Equals(tag Tag) bool
Equals tests Tag equality
func (t Tag) IsCompatible(tag Tag) bool
IsCompatible determines if two tags can be compared together
func (t Tag) IsGreaterThan(tag Tag) bool
IsGreaterThan tests if a tag is greater than another. There are some
tag-isms to take into account here, shorter is bigger (i.e. 2.1 > 2.1.1 ==
true, 2 > 2.1 == true).
func (t Tag) IsLessThan(tag Tag) bool
IsLessThan tests if a tag is less than another. There are some tag-isms to
take into account here, shorter is bigger (i.e. 2.1 < 2.1.1 == false, 2 <
2.1 == false).
func (t Tag) String() string
String formats a Tag correctly in string representation
```
[godoc.md](./godoc.md)
## Types of versions supported

158
godoc.md Normal file
View File

@ -0,0 +1,158 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# tagcmp
```go
import "coopcloud.tech/tagcmp"
```
Package tagcmp provides image tag comparison operations\.
## Index
- [Variables](<#variables>)
- [func IsParseable(tag string) bool](<#func-isparseable>)
- [type ByTag](<#type-bytag>)
- [func (t ByTag) Len() int](<#func-bytag-len>)
- [func (t ByTag) Less(i, j int) bool](<#func-bytag-less>)
- [func (t ByTag) Swap(i, j int)](<#func-bytag-swap>)
- [type Tag](<#type-tag>)
- [func Parse(tag string) (Tag, error)](<#func-parse>)
- [func (t Tag) Equals(tag Tag) bool](<#func-tag-equals>)
- [func (t Tag) IsCompatible(tag Tag) bool](<#func-tag-iscompatible>)
- [func (t Tag) IsGreaterThan(tag Tag) bool](<#func-tag-isgreaterthan>)
- [func (t Tag) IsLessThan(tag Tag) bool](<#func-tag-islessthan>)
- [func (t Tag) String() string](<#func-tag-string>)
## Variables
CommitHashPattern matches commit\-like hash tags
```go
var CommitHashPattern = "^[a-f0-9]{7,40}$"
```
DotPattern matches tags which contain multiple versions
```go
var DotPattern = "([0-9]+)\\.([0-9]+)"
```
EmptyPattern matches when tags are missing
```go
var EmptyPattern = "^$"
```
ParametrizedPattern matches when tags are parametrized
```go
var ParametrizedPattern = "\\${.+}"
```
StringPattern matches when tags are only made up of alphabetic characters
```go
var StringPattern = "^[a-zA-Z]+$"
```
## func IsParseable
```go
func IsParseable(tag string) bool
```
IsParseable determines if a tag is supported by this library
## type ByTag
ByTag sorts tags
```go
type ByTag []Tag
```
### func \(ByTag\) Len
```go
func (t ByTag) Len() int
```
### func \(ByTag\) Less
```go
func (t ByTag) Less(i, j int) bool
```
### func \(ByTag\) Swap
```go
func (t ByTag) Swap(i, j int)
```
## type Tag
```go
type Tag struct {
Major string `json:",omitempty"` // major semver part
Minor string `json:",omitempty"` // minor semver part
MissingMinor bool // whether or not the minor semver part was left out
Patch string `json:",omitempty"` // patch semver part
MissingPatch bool // whether or not he patch semver part was left out
Suffix string // tag suffix (e.g. "-alpine")
UsesV bool // whether or not the tag uses the "v" prefix
}
```
### func Parse
```go
func Parse(tag string) (Tag, error)
```
Parse converts an image tag into a structured data format\. It aims to to support the general case of tags which are "semver\-like" and/or stable and parseable by heuristics\. Image tags follow no formal specification and therefore this is a best\-effort implementation\. Examples of tags this function can parse are: "5"\, "5\.2"\, "v4"\, "v5\.3\.6"\, "4\-alpine"\, "v3\.2\.1\-debian"\.
### func \(Tag\) Equals
```go
func (t Tag) Equals(tag Tag) bool
```
Equals tests Tag equality
### func \(Tag\) IsCompatible
```go
func (t Tag) IsCompatible(tag Tag) bool
```
IsCompatible determines if two tags can be compared together
### func \(Tag\) IsGreaterThan
```go
func (t Tag) IsGreaterThan(tag Tag) bool
```
IsGreaterThan tests if a tag is greater than another\. There are some tag\-isms to take into account here\, shorter is bigger \(i\.e\. 2\.1 \> 2\.1\.1 == true\, 2 \> 2\.1 == true\)\.
### func \(Tag\) IsLessThan
```go
func (t Tag) IsLessThan(tag Tag) bool
```
IsLessThan tests if a tag is less than another\. There are some tag\-isms to take into account here\, shorter is bigger \(i\.e\. 2\.1 \< 2\.1\.1 == false\, 2 \< 2\.1 == false\)\.
### func \(Tag\) String
```go
func (t Tag) String() string
```
String formats a Tag correctly in string representation
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)