Skip to content

Commit 443f867

Browse files
Develop (#26)
* version 0.2.0 ready
1 parent 080f3f0 commit 443f867

23 files changed

+2247
-64
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ config.ini
99
*.rtf
1010
Out-Null
1111

12+
# automatically generated files
13+
user-site/
14+
api-site/
15+
1216
# Vim files
1317
*~
1418
*.swp

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
<!-- towncrier release notes start -->
44

5+
## [0.2.0](https://github.com/Nagidal/hatch-semver/tree/0.2.0) - 2022-11-15
6+
7+
8+
### Documentation
9+
10+
- Wrote user and api documentation [#25](https://github.com/Nagidal/hatch-semver/issues/25)
11+
12+
513
## [0.1.0](https://github.com/Nagidal/hatch-semver/tree/0.1.0) - 2022-11-13
614

715

README.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# hatch-semver
22

3-
A plugin for [hatch][hatch] to support [semantic versioning][semver].
3+
A plugin for [hatch][hatch] to support [semantic versioning][semver]. Hatch-semver relies on [python-semver][python-semver] for all the versioning logic.
44

5+
## Setup
56

6-
## Usage
7-
8-
Introduce *hatch-semver* as a build-dependency to your project (in `pyproject.toml`):
7+
Introduce hatch-semver as a build-dependency to your project (in your `pyproject.toml`):
98

109
```toml
1110
[build-system]
@@ -16,17 +15,48 @@ requires = [
1615
build-backend = "hatchling.build"
1716
```
1817

19-
Further down in `pyproject.toml`, where you specify your project's version, set version scheme
20-
to `semver`:
18+
Further down in `pyproject.toml`,
19+
where you set up the *hatch version* command,
20+
set version scheme to `semver`:
2121
```toml
2222
[tool.hatch.version]
2323
path = "src/<your_project>/__about__.py"
24+
validate-bump = True
2425
scheme = "semver"
2526
```
2627

27-
You can then use hatch's usual [versioning commands][hatch_versioning] to bump your project's
28-
version in a semver-compliant way.
28+
### Beware
2929

30-
[hatch]: hatch.pypa.io/
31-
[semver]: https://semver.org/
30+
Hatch-semver plugin will only work with project versions which can be readily parsed by [python-semver][python-semver].
31+
Therefore, if you are introducing hatch-semver into an existing project, you must **make sure that the project's current version is a valid semantic version.**
32+
You can test that [here][semver-regex].
33+
34+
## Quick Start
35+
36+
Many of hatch's [standard versioning][hatch_versioning] commands also work for hatch-semver to bump your project's version in a semver-compliant way.
37+
Such command is written as a single string of comma-separated bump instructions as a positional argument of the `hatch version` subcommand, i.e `hatch version <COMMAND>`.
38+
39+
Starting with `0.1.0` as the original version, here is a series of example commands which illustrate some common ways how to bump the version:
40+
41+
| Old Version | Command | New Version |
42+
| ---------------------- | ------------------- | -------------------- |
43+
| `0.1.0` | `patch` | `0.1.1` |
44+
| `0.1.1` | `minor,patch,patch` | `0.2.2` |
45+
| `0.2.2` | `minor` | `0.3.0` |
46+
| `0.3.0` | `rc` | `0.3.1-rc.1` |
47+
| `0.3.1-rc.1` | `rc` | `0.3.1-rc.2` |
48+
| `0.3.1-rc.2` | `release` | `0.3.1` |
49+
| `0.3.1` | `0.9.5` | `0.9.5` |
50+
| `0.9.5` | `major,rc` | `1.0.0-rc.1` |
51+
| `1.0.0-rc.1` | `release` | `1.0.0` |
52+
53+
See the [command reference][commands] for all the commands in full detail. If you are familiar with hatch's standard versioning scheme, perhaps a [comparison][comparison] of the standard scheme and hatch-semver will be of interest.
54+
55+
56+
[hatch]: https://hatch.pypa.io/
3257
[hatch_versioning]: https://hatch.pypa.io/latest/version/#updating
58+
[python-semver]: https://github.com/python-semver/python-semver/tree/maint/v2
59+
[semver-regex]: https://regex101.com/r/Ly7O1x/3/
60+
[semver]: https://semver.org/
61+
[commands]: user_guide/1-commands.md
62+
[comparison]: user_guide/2-migrating-to-semver.md

api-docs/hatch_semver/bump_instruction.html

Lines changed: 519 additions & 0 deletions
Large diffs are not rendered by default.

api-docs/hatch_semver/errors.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
6+
<meta name="generator" content="pdoc 0.10.0" />
7+
<title>hatch_semver.errors API documentation</title>
8+
<meta name="description" content="Hatch-semver&#39;s own error types" />
9+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
10+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
11+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
12+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
13+
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
14+
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
15+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
16+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
17+
</head>
18+
<body>
19+
<main>
20+
<article id="content">
21+
<header>
22+
<h1 class="title">Module <code>hatch_semver.errors</code></h1>
23+
</header>
24+
<section id="section-intro">
25+
<p>Hatch-semver's own error types</p>
26+
<details class="source">
27+
<summary>
28+
<span>Expand source code</span>
29+
</summary>
30+
<pre><code class="python">#!/usr/bin/env python
31+
32+
33+
&#34;&#34;&#34;
34+
Hatch-semver&#39;s own error types
35+
&#34;&#34;&#34;
36+
37+
38+
class HatchSemverError(Exception):
39+
&#34;&#34;&#34;
40+
Base class for all hatch-semver errors.
41+
&#34;&#34;&#34;
42+
pass
43+
44+
45+
class ValidationError(HatchSemverError):
46+
&#34;&#34;&#34;
47+
Raised if the new version is not a valid successor of the original version.
48+
&#34;&#34;&#34;
49+
pass</code></pre>
50+
</details>
51+
</section>
52+
<section>
53+
</section>
54+
<section>
55+
</section>
56+
<section>
57+
</section>
58+
<section>
59+
<h2 class="section-title" id="header-classes">Classes</h2>
60+
<dl>
61+
<dt id="hatch_semver.errors.HatchSemverError"><code class="flex name class">
62+
<span>class <span class="ident">HatchSemverError</span></span>
63+
<span>(</span><span>*args, **kwargs)</span>
64+
</code></dt>
65+
<dd>
66+
<div class="desc"><p>Base class for all hatch-semver errors.</p></div>
67+
<details class="source">
68+
<summary>
69+
<span>Expand source code</span>
70+
</summary>
71+
<pre><code class="python">class HatchSemverError(Exception):
72+
&#34;&#34;&#34;
73+
Base class for all hatch-semver errors.
74+
&#34;&#34;&#34;
75+
pass</code></pre>
76+
</details>
77+
<h3>Ancestors</h3>
78+
<ul class="hlist">
79+
<li>builtins.Exception</li>
80+
<li>builtins.BaseException</li>
81+
</ul>
82+
<h3>Subclasses</h3>
83+
<ul class="hlist">
84+
<li><a title="hatch_semver.errors.ValidationError" href="#hatch_semver.errors.ValidationError">ValidationError</a></li>
85+
</ul>
86+
</dd>
87+
<dt id="hatch_semver.errors.ValidationError"><code class="flex name class">
88+
<span>class <span class="ident">ValidationError</span></span>
89+
<span>(</span><span>*args, **kwargs)</span>
90+
</code></dt>
91+
<dd>
92+
<div class="desc"><p>Raised if the new version is not a valid successor of the original version.</p></div>
93+
<details class="source">
94+
<summary>
95+
<span>Expand source code</span>
96+
</summary>
97+
<pre><code class="python">class ValidationError(HatchSemverError):
98+
&#34;&#34;&#34;
99+
Raised if the new version is not a valid successor of the original version.
100+
&#34;&#34;&#34;
101+
pass</code></pre>
102+
</details>
103+
<h3>Ancestors</h3>
104+
<ul class="hlist">
105+
<li><a title="hatch_semver.errors.HatchSemverError" href="#hatch_semver.errors.HatchSemverError">HatchSemverError</a></li>
106+
<li>builtins.Exception</li>
107+
<li>builtins.BaseException</li>
108+
</ul>
109+
</dd>
110+
</dl>
111+
</section>
112+
</article>
113+
<nav id="sidebar">
114+
<h1>Index</h1>
115+
<div class="toc">
116+
<ul></ul>
117+
</div>
118+
<ul id="index">
119+
<li><h3>Super-module</h3>
120+
<ul>
121+
<li><code><a title="hatch_semver" href="index.html">hatch_semver</a></code></li>
122+
</ul>
123+
</li>
124+
<li><h3><a href="#header-classes">Classes</a></h3>
125+
<ul>
126+
<li>
127+
<h4><code><a title="hatch_semver.errors.HatchSemverError" href="#hatch_semver.errors.HatchSemverError">HatchSemverError</a></code></h4>
128+
</li>
129+
<li>
130+
<h4><code><a title="hatch_semver.errors.ValidationError" href="#hatch_semver.errors.ValidationError">ValidationError</a></code></h4>
131+
</li>
132+
</ul>
133+
</li>
134+
</ul>
135+
</nav>
136+
</main>
137+
<footer id="footer">
138+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
139+
</footer>
140+
</body>
141+
</html>

0 commit comments

Comments
 (0)