Skip to content

Commit 779c84c

Browse files
committed
Updated more documentation
1 parent 5cbd250 commit 779c84c

33 files changed

+528
-538
lines changed

Makefile

+1-51
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
1-
.PHONY: release-dev release-patch release-minor release-major help docs pubdocs do-release
1+
.PHONY: help docs pubdocs update-requires
22
.DEFAULT_GOAL := help
33

4-
RELEASE_KIND := patch
5-
BRANCH_NAME := $(shell echo $$(git rev-parse --abbrev-ref HEAD))
6-
SHORT_BRANCH_NAME := $(shell echo $(BRANCH_NAME) | cut -c 1-20)
7-
PRIMARY_BRANCH_NAME := master
8-
BUMPVERSION_OPTS :=
9-
EDIT_CHANGELOG := $(shell if [[ -n $$EDITOR ]] ; then echo "$$EDITOR CHANGELOG.md" ; else echo "true" ; fi)
10-
114
help:
125
@grep '^[a-zA-Z]' $(MAKEFILE_LIST) | sort | awk -F ':.*?## ' 'NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
136

14-
release-dev: RELEASE_KIND := dev
15-
release-dev: do-release ## Release a new development version: 1.1.1 -> 1.1.1+branchname-1
16-
17-
release-patch: RELEASE_KIND := patch
18-
release-patch: do-release ## Release a new patch version: 1.1.1 -> 1.1.2
19-
20-
release-minor: RELEASE_KIND := minor
21-
release-minor: do-release ## Release a new minor version: 1.1.1 -> 1.2.0
22-
23-
release-major: RELEASE_KIND := major
24-
release-major: do-release ## Release a new major version: 1.1.1 -> 2.0.0
25-
26-
release-version: get-version do-release ## Release a specific version: release-version 1.2.3
277

288
docs: ## generate Sphinx HTML documentation, including API docs
299
mkdir -p docs
@@ -40,33 +20,3 @@ update-requires: ## Update the requirements.txt file
4020
pip-compile --extra=test --output-file=requirements/test.txt pyproject.toml
4121
pip-compile --extra=docs --output-file=requirements/docs.txt pyproject.toml
4222
pip-compile --extra=dev --extra=docs --extra=test --output-file=requirements/dev.txt pyproject.toml
43-
44-
#
45-
# Helper targets. Not meant to use directly
46-
#
47-
48-
do-release:
49-
@if [[ "$(BRANCH_NAME)" == "$(PRIMARY_BRANCH_NAME)" ]]; then \
50-
if [[ "$(RELEASE_KIND)" == "dev" ]]; then \
51-
echo "Error! Can't bump $(RELEASE_KIND) while on the $(PRIMARY_BRANCH_NAME) branch."; \
52-
exit; \
53-
fi; \
54-
elif [[ "$(RELEASE_KIND)" != "dev" ]]; then \
55-
echo "Error! Must be on the $(PRIMARY_BRANCH_NAME) branch to bump $(RELEASE_KIND)."; \
56-
exit; \
57-
fi; \
58-
git fetch -p --all; \
59-
generate-changelog; \
60-
$(call EDIT_CHANGELOG); \
61-
./tools/gen-codeowners.sh $(SOURCE_DIR); \
62-
git add CODEOWNERS; \
63-
export BRANCH_NAME=$(SHORT_BRANCH_NAME);bumpversion $(BUMPVERSION_OPTS) $(RELEASE_KIND) --allow-dirty; \
64-
git push origin $(BRANCH_NAME); \
65-
git push --tags;
66-
67-
get-version: # Sets the value after release-version to the VERSION
68-
$(eval VERSION := $(filter-out release-version,$(MAKECMDGOALS)))
69-
$(eval BUMPVERSION_OPTS := --new-version=$(VERSION))
70-
71-
%: # NO-OP for unrecognized rules
72-
@:

README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,24 @@
1818

1919
## Overview
2020

21-
Version-bump your software with a single command!
21+
Bump My Version's purpose is to:
2222

23-
A small command line tool to simplify releasing software by updating all version strings in your source code by the correct increment and optionally commit and tag the changes.
23+
- Work as a part of an automated build system
24+
- Manage project versioning through the project's development life cycle
25+
- Incrementing version numbers
26+
- serializing version numbers
27+
- parsing version numbers
28+
- Modify project files as part of the project's development life cycle
29+
- Work with the project's source control system
30+
- Committing changes
31+
- Tagging releases
32+
- Reading version numbers from tags
2433

25-
* version formats are highly configurable
26-
* works without any source code manager, but happily reads tag information from and writes
27-
commits and tags to Git and Mercurial if available
28-
* just handles text files, so it's not specific to any programming language
29-
* supports Python 3.8+ and PyPy3.
3034

3135
## Future Direction
3236

33-
- Make it easier to get the current version
3437
- Switch having both the version part and files to change as arguments on the command line.
35-
- Make the version part argument _truly_ optional when `--new-version` is specified
3638
- Allow for multiple tags, including one that moves for having a `v2` that always points to the latest version of version 2. [For example](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations)
37-
- Better UI with [Rich](https://rich.readthedocs.io/en/stable/index.html)
3839

3940
## Installation
4041

docsrc/_static/css/custom.css

+5
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ dl.field-list > dd {
3535
margin-left: 0;
3636
margin-bottom: 0;
3737
}
38+
39+
figure {
40+
padding-bottom: .75rem;
41+
padding-top: .5rem;
42+
}

docsrc/_templates/autosummary/base.rst

-9
This file was deleted.

docsrc/_templates/autosummary/class.rst

-11
This file was deleted.

docsrc/_templates/autosummary/module.rst

-72
This file was deleted.

docsrc/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"myst_parser",
2424
"autodoc2",
2525
"sphinx.ext.viewcode",
26-
"sphinx.ext.autosummary",
2726
"sphinx.ext.intersphinx",
2827
"sphinx.ext.autosectionlabel",
2928
"sphinx.ext.napoleon",
@@ -40,8 +39,10 @@
4039
autodoc2_render_plugin = "myst"
4140
autodoc2_output_dir = "reference"
4241
autodoc2_index_template = None
43-
44-
autosummary_generate = True
42+
autodoc2_docstring_parser_regexes = [
43+
# this will render all docstrings as Markdown
44+
(r".*", "myst"),
45+
]
4546

4647
napoleon_attr_annotations = True
4748
napoleon_include_special_with_doc = True

docsrc/explanation/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Explanation
22

33
```{toctree}
4+
---
5+
titlesonly: true
6+
---
7+
mental-model
48
```

docsrc/explanation/mental-model.md

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# The mental model used by bump-my-version
2+
3+
## Overview
4+
5+
There are four main concepts in bump-my-version:
6+
7+
1. Configuration
8+
2. Version handling
9+
3. File changing
10+
4. Source control management interface
11+
12+
## Configuration
13+
14+
The predecessor to bump-my-version, [bumpversion](https://github.com/peritus/bumpversion), was designed to have the configuration file optional. All configuration values could be specified on the command line. This only worked in the simplest of version schemes.
15+
16+
bump-my-version is designed to have a configuration file. The configuration file is required to specify the version scheme. The configuration file is also used to specify the files to change and how to change them.
17+
18+
## Version handling
19+
20+
bump-my-version abstracts the version handling into a few concepts:
21+
22+
A **version spec** defines all the possible _version component specs_ of a version and how they work together.
23+
24+
A **version component spec** defines how a single part of a _version spec,_ such as `major`, `minor`, or `patch`, works. It defines the types of values, how to increment the component, and how to reset it.
25+
26+
A **version parser** is a regular expression used in several ways. It's named capture groups define the possible components in a version spec and the order in which they appear. It is also used to parse a version string into a mapping of version component name to value.
27+
28+
A **version** is the concrete representation of a _version spec._ It is a mapping of version component names to _version components._
29+
30+
A **version component** is the concrete representation of a _version component spec._ It is a _version component spec_ with a specific value.
31+
32+
A **version serialization format** is a list of format strings used to serialize a _version_ into a string.
33+
34+
### How a version spec is generated
35+
36+
:::{figure-md} fig-version-spec
37+
![How a version spec is generated](../_static/creating-a-version-spec.svg)
38+
39+
How a configuration file is used to generate a version spec.
40+
:::
41+
42+
The most important part of the configuration file is the _version parser._ It defines the structure of the _version spec._
43+
44+
45+
If the configuration file contains a _version component spec_ that matches a named capture group in the _version parser,_ then that _version component spec_ is used in the _version spec._ The yellow and green named capture groups in the diagram demonstrate this.
46+
47+
If the configuration file does not contain a _version component spec_ that matches a named capture group in the _version parser,_ then a default _version component spec_ is used. The blue named capture group in the diagram demonstrates this.
48+
49+
The _component dependency_ graph is used to determine the order in which the _version components_ are incremented and reset. For example in the diagram, the `patch` component depends on the `minor` component which depends on the `major` component. Therefore, when the `major` component is incremented, the `minor` component is reset, which cascades to the `patch` component.
50+
51+
### How a version is generated
52+
53+
:::{figure-md} fig-version
54+
![How a version is generated](../_static/creating-a-version.svg)
55+
56+
How a version spec is used to generate a version.
57+
:::
58+
59+
The _version spec_ has a `create_version` method that takes a mapping of version component names to values.
60+
61+
Each _version component spec_ has a `create_component` method that takes a value. The `create_version` method calls the `create_component` method for each _version component spec_ in the _version spec_ with the value from the mapping.
62+
63+
The `create_component` assembles its own _version spec_ with the _version components_ to create a _version._
64+
65+
### How a version is serialized
66+
67+
**Optional value rule.** _Version component specs_ can define an optional value. For example, numeric components have `0` as an optional value. Optional values may be omitted from the serialization as long as all dependent components also have optional values.
68+
69+
**Required value rule.** _Version component specs_ is required if its value or the value of any of its dependent components is not optional.
70+
71+
A valid serialization is one that contains all the components in the _version spec_ that are required based on the _required value rule._
72+
73+
An invalid serialization is one that does not contain all the components in the _version spec_ that are required based on the _required value rule._
74+
75+
An optimal serialization is the valid serialization that uses the fewest components.
76+
77+
The `serialize` method of the _version spec_ returns either the optimal serialization or the first invalid serialization.
78+
79+
:::{figure-md} fig-serialize-1-2-3
80+
![How a version is serialized with values major=1, minor=2, and patch=3](../_static/serializing-a-version-1-2-3.svg)
81+
82+
A version with values major=1, minor=2, and patch=3 only has one valid serialization. It is also the optimal serialization.
83+
:::
84+
85+
:::{figure-md} fig-serialize-1-2-0
86+
![How a version is serialized with values major=1, minor=2, and patch=0](../_static/serializing-a-version-1-2-0.svg)
87+
88+
A version with values major=1, minor=2, and patch=0 has two valid serializations. The optimal serialization is the one that uses the fewest components. `1.2` in this example
89+
:::
90+
91+
:::{figure-md} fig-serialize-1-0-0
92+
![How a version is serialized with values major=1, minor=0, and patch=0](../_static/serializing-a-version-1-0-0.svg)
93+
94+
A version with values major=1, minor=0, and patch=0 has three valid serializations. The optimal serialization is the one that uses the fewest components. `1` in this example.
95+
:::
96+
97+
:::{figure-md} fig-serialize-1
98+
![How a version is serialized with invalid serialization formats](../_static/serializing-a-version-1.svg)
99+
100+
A version with values major=1, minor=2, and patch=3 has no valid serializations in this example. The `serialize` method returns the first invalid serialization.
101+
:::

docsrc/reference/bumpversion/bumpversion.__main__.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
```
55

66
```{autodoc2-docstring} bumpversion.__main__
7+
:parser: myst
78
:allowtitles:
89
```

docsrc/reference/bumpversion/bumpversion.aliases.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
```
55

66
```{autodoc2-docstring} bumpversion.aliases
7+
:parser: myst
78
:allowtitles:
89
```
910

@@ -17,6 +18,7 @@
1718
1819
* - {py:obj}`AliasedGroup <bumpversion.aliases.AliasedGroup>`
1920
- ```{autodoc2-docstring} bumpversion.aliases.AliasedGroup
21+
:parser: myst
2022
:summary:
2123
```
2224
````
@@ -29,18 +31,21 @@
2931
Bases: {py:obj}`rich_click.rich_group.RichGroup`
3032
3133
```{autodoc2-docstring} bumpversion.aliases.AliasedGroup
34+
:parser: myst
3235
```
3336
3437
```{rubric} Initialization
3538
```
3639
3740
```{autodoc2-docstring} bumpversion.aliases.AliasedGroup.__init__
41+
:parser: myst
3842
```
3943
4044
````{py:method} get_command(ctx: click.Context, cmd_name: str) -> typing.Optional[rich_click.Command]
4145
:canonical: bumpversion.aliases.AliasedGroup.get_command
4246
4347
```{autodoc2-docstring} bumpversion.aliases.AliasedGroup.get_command
48+
:parser: myst
4449
```
4550
4651
````
@@ -49,6 +54,7 @@ Bases: {py:obj}`rich_click.rich_group.RichGroup`
4954
:canonical: bumpversion.aliases.AliasedGroup.resolve_command
5055
5156
```{autodoc2-docstring} bumpversion.aliases.AliasedGroup.resolve_command
57+
:parser: myst
5258
```
5359
5460
````

0 commit comments

Comments
 (0)