Skip to content

Commit

Permalink
Add Documentation (#2)
Browse files Browse the repository at this point in the history
* docs: fill readme

* feat: add jazzy file

* chore: make protocol public

* docs: add auto generated jazzy docs

* chore: update readme

* chore: fix readme code blocks
  • Loading branch information
mflknr authored Jan 6, 2021
1 parent 59757fc commit 5033050
Show file tree
Hide file tree
Showing 56 changed files with 10,055 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .jazzy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module: SwiftVersionCompare
author: nihilias
author_url: https://www.nihilias.de/
github_url: https://github.com/nihilias/SwiftVersionCompare/
readme: README.md
skip_undocumented: true
hide_documentation_coverage: false
theme: apple
output: docs/
swift_version: 5.3.1
clean: true
min_acl: public
xcodebuild_arguments:
- -project
- SwiftVersionCompare.xcodeproj
- -scheme
- SwiftVersionCompare-Package

59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
# SwiftVersionCheck
# SwiftVersionCheck

A small package for comparing and using versions conforming to [SemVer](https://semver.org).

Following features are and will be implemented:

- [x] Create a version from major, minor, patch and extension information.
- [x] Create a version from string using `LosslessStringConvertible` or `ExpressibleByStringLiteral` .
- [x] Compare versions using `Equatable` and `Comparable` with the known operators `==, ===, <, <=, > and >=`.
- [x] Compare versions and get a result type defining the severity of the version difference (e. g. major-update).
- [ ] Utilize ranges for a greater variaty of comparisons.
- [x] Extend `Bundle` and `ProcessInfo` for easy usage.
- [x] Open documentation.
- [ ] Implement extension for `Codable` and `Hashable`.

# Installation

Swift Package Manager:

```swift
package(url: https://github.com/nihilias/SwiftVersionCompare.git", from: "1.0.0"))
```

# Usage

For detailed implenentation information see auto-generated [documentation]().

```swift
// use the version identifier for initialization
let versionOne = Version(1, 0, 0)
let versionTwo = Version(
major: 1,
minor: 0,
patch: 0
)

// use strings
// use `ExpressibleByStringLiteral` with caution, because it's fatal if string is not `SemVer` version
let versionThreeA: Version = "1.0.0"
let versionThreeB: Version = Version("1.0.0")

let versionFourA: Version? = "1.0.0"
let versionFourB: Version? = Version("1.0.0")

// easy initial `0.0.0` version
let initialVersion: Version = .initial

// from bundle and processInfo
let bundleVersion = Bundle.main.shortVersion
let osVersion = ProcessInfo.processInfo.comparableOperatingSystemVersion

// compare versions with usally known operators (==, ===, <, <=, >=, >)
if Version("1.0.0") > Version("0.4.0") {
// ...
}
```


4 changes: 2 additions & 2 deletions Sources/SwiftVersionCompare/Helper/VersionCompareResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by Marius Hötten-Löns on 06.01.21.
//

/// The result type indicating the severity of an update between to versions.
enum VersionCompareResult {
/// The severity of an update between versions.
public enum VersionCompareResult {
/// A `MAJOR`update
case major
/// A `MINOR`update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

- Remark: See `https://semver.org` for detailed information.
*/
protocol SemanticVersionComparable: Comparable, Hashable {
public protocol SemanticVersionComparable: Comparable, Hashable {
/// The `MAJOR` identifier of a version.
var major: UInt { get }
/// The `MINOR` identifier of a version
Expand Down
2 changes: 2 additions & 0 deletions SwiftVersionCompare.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
24A6A27D25A51E1900E12D71 /* Version+Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Version+Bundle.swift"; sourceTree = "<group>"; };
24A6A28725A6002200E12D71 /* Version+OS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Version+OS.swift"; sourceTree = "<group>"; };
24A6A2A525A64DAC00E12D71 /* VersionCompareResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionCompareResult.swift; sourceTree = "<group>"; };
24A6A2BB25A67D1200E12D71 /* .jazzy.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .jazzy.yml; sourceTree = "<group>"; };
OBJ_10 /* SemanticVersionComparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersionComparable.swift; sourceTree = "<group>"; };
OBJ_11 /* Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Version.swift; sourceTree = "<group>"; };
OBJ_14 /* SemanticVersionComparableTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SemanticVersionComparableTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,6 +153,7 @@
OBJ_17 /* Products */,
OBJ_20 /* LICENSE */,
OBJ_21 /* README.md */,
24A6A2BB25A67D1200E12D71 /* .jazzy.yml */,
);
name = "";
sourceTree = "<group>";
Expand Down
125 changes: 125 additions & 0 deletions docs/Enums.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Enumerations Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>

<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Enumerations" class="dashAnchor"></a>
<a title="Enumerations Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (100% documented)</p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html"> Reference</a>
<img id="carat" src="img/carat.png" />
Enumerations Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Enums/VersionCompareResult.html">VersionCompareResult</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Extensions/Bundle.html">Bundle</a>
</li>
<li class="nav-group-task">
<a href="Extensions/ProcessInfo.html">ProcessInfo</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Protocols/SemanticVersionComparable.html">SemanticVersionComparable</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Structs/Version.html">Version</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>Enumerations</h1>
<p>The following enumerations are available globally.</p>

</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:19SwiftVersionCompare0bC6ResultO"></a>
<a name="//apple_ref/swift/Enum/VersionCompareResult" class="dashAnchor"></a>
<a class="token" href="#/s:19SwiftVersionCompare0bC6ResultO">VersionCompareResult</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>The severity of an update between versions.</p>

<a href="Enums/VersionCompareResult.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">VersionCompareResult</span></code></pre>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2021 <a class="link" href="" target="_blank" rel="external"></a>. All rights reserved. (Last updated: 2021-01-07)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>
Loading

0 comments on commit 5033050

Please sign in to comment.