Skip to content

Commit

Permalink
Update for newest Python
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Nov 14, 2023
1 parent 890106b commit 8395845
Show file tree
Hide file tree
Showing 24 changed files with 1,365 additions and 1,208 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NewVersion - Your version manager
# NewVersion - PEP 440 version manager

[![PyPI - newversion](https://img.shields.io/pypi/v/newversion.svg?color=blue&label=newversion)](https://pypi.org/project/newversion)
[![Docs](https://img.shields.io/readthedocs/newversion.svg?color=blue&label=Builder%20docs)](https://newversion.readthedocs.io/)
Expand Down
19 changes: 0 additions & 19 deletions docs/MODULES.md

This file was deleted.

134 changes: 15 additions & 119 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,122 +1,18 @@
# NewVersion - Your version manager
# newversion Index

> Auto-generated documentation index.
[![PyPI - newversion](https://img.shields.io/pypi/v/newversion.svg?color=blue&label=newversion)](https://pypi.org/project/newversion)
[![Docs](https://img.shields.io/readthedocs/newversion.svg?color=blue&label=Builder%20docs)](https://newversion.readthedocs.io/)

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/newversion.svg?color=blue)](https://pypi.org/project/newversion)
[![Coverage](https://img.shields.io/codecov/c/github/vemel/newversion)](https://codecov.io/gh/vemel/newversion)

Full newversion project documentation can be found in [Modules](MODULES.md#newversion-modules)

- [NewVersion - Your version manager](#newversion---your-version-manager)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [CLI](#cli)
- [Python library](#python-library)
- [Versioning](#versioning)
- [Latest changes](#latest-changes)
- [newversion Modules](MODULES.md#newversion-modules)

## Features

- Follows [PEP 440](https://www.python.org/dev/peps/pep-0440/)
- Fully compatible with [packaging.Version](https://packaging.pypa.io/en/latest/version.html)
- Brings version bumping from [semver](https://pypi.org/project/semver/)
- Comes with a helpful CLI tool `newversion`
- Shines in CI

## Installation

```bash
python -m pip install newversion
```

## Usage

### CLI

```bash
newversion # 0.0.0
newversion bump major # 1.0.0

# get package version from pyproject.toml, setup.cfg or setup.py
newversion package # 1.2.3
newversion package | newversion bump # 1.2.4
newversion package | newversion get minor # 2

# bump minor version and update package version
newversion package | newversion bump minor | newversion set_package

echo "1.2.3rc1" | newversion bump micro # 1.2.3
echo "1.2.3rc1" | newversion bump minor # 1.3.0
echo "1.2.3rc1" | newversion bump major # 2.0.0
echo "1.2.3rc1" | newversion bump pre # 1.2.3rc2
echo "1.2.3rc1" | newversion bump rc # 1.2.3rc2
echo "1.2.3rc1" | newversion bump alpha # 1.2.4a1

echo "1.2.3rc1" | newversion set micro 5 # 1.2.5rc1
echo "1.2.3rc1" | newversion set minor 5 # 1.5.3rc1
echo "1.2.3rc1" | newversion set major 5 # 5.2.3rc1
echo "1.2.3rc1" | newversion set pre 5 # 1.2.3rc5
echo "1.2.3rc1" | newversion set rc 5 # 1.2.3rc5
echo "1.2.3rc1" | newversion set alpha 5 # 1.2.3a5

echo "1.2.3rc1" | newversion get micro # 1
echo "1.2.3rc1" | newversion get minor # 2
echo "1.2.3rc1" | newversion get major # 3
echo "1.2.3rc1" | newversion get pre # rc1
echo "1.2.3rc1" | newversion get rc # 1
echo "1.2.3rc1" | newversion get alpha # 0

echo "1.2.3rc1" | newversion stable # 1.2.3

echo "1.2.3rc1" | newversion is_stable # error!
echo "1.2.3" | newversion is_stable # 1.2.3
echo "1.2.3" | newversion is_stable && echo "Stable!" # Stable!

echo "1.2.3rc1" | newversion gt "1.2.3" # error!
echo "1.2.3rc1" | newversion lte "1.2.3" # "1.2.3rc1"
```

### Python library

```python
from newversion import Version

version = Version("1.2.3")
next_version = version.bump_minor() # Version("1.3.0")

# bump version same way as SemVer
version.dumps() # "1.2.3"
version.bump_micro().dumps() # "1.2.4"
version.bump_minor().dumps() # "1.3.0"
version.bump_major().dumps() # "2.0.0"

# create and bump pre-releases
version.bump_prerelease().dumps() # "1.2.4rc1"
version.bump_prerelease(bump_release="minor").dumps() # "1.3.0rc1"
version.bump_prerelease("alpha").dumps() # "1.2.4a1"
Version("1.2.3b4").bump_prerelease().dumps() # "1.2.3b5"
version.bump_micro().replace(dev=1234).dumps() # "1.2.4.dev1234"

# and post-releases
version.bump_postrelease().dumps() # "1.2.3.post1"
Version("1.2.3.post3").bump_postrelease(2).dumps() # "1.2.3.post5"

# easily check if this is a pre- or dev release or a stable version
Version("1.2.3").is_stable # True
Version("1.2.3a6").is_stable # False
Version("1.2.3.post3").is_stable # True
Version("1.2.3.post3").get_stable().dumps() # "1.2.3"
```

## Versioning

`newversion` version follows [PEP 440](https://www.python.org/dev/peps/pep-0440/).

## Latest changes

Full changelog can be found in [Releases](https://github.com/vemel/newversion/releases).
A full list of [newversion](https://github.com/vemel/newversion) project modules.

- [Newversion](newversion/index.md#newversion)
- [Module](newversion/module.md#module)
- [Cli Parser](newversion/cli_parser.md#cli-parser)
- [Constants](newversion/constants.md#constants)
- [EOLFixer](newversion/eol_fixer.md#eolfixer)
- [Exceptions](newversion/exceptions.md#exceptions)
- [Executor](newversion/executor.md#executor)
- [Main](newversion/main.md#main)
- [PackageVersion](newversion/package_version.md#packageversion)
- [Type Defs](newversion/type_defs.md#type-defs)
- [Utils](newversion/utils.md#utils)
- [Version](newversion/version.md#version)
40 changes: 24 additions & 16 deletions docs/newversion/cli_parser.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
# Cli Parser

> Auto-generated documentation for [newversion.cli_parser](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py) module.
[newversion Index](../README.md#newversion-index) /
[Newversion](./index.md#newversion) /
Cli Parser

Main CLI parser.
> Auto-generated documentation for [newversion.cli_parser](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py) module.
- [newversion](../README.md#newversion---your-version-manager) / [Modules](../MODULES.md#newversion-modules) / [Newversion](index.md#newversion) / Cli Parser
- [get_stdin](#get_stdin)
- [parse_args](#parse_args)
- [Cli Parser](#cli-parser)
- [get_stdin](#get_stdin)
- [parse_args](#parse_args)

## get_stdin

[[find in source code]](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py#L14)

```python
def get_stdin() -> Version:
```
[Show source in cli_parser.py:14](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py#L14)

Get input from stdin.

#### Returns

Parsed version.

#### Signature

```python
def get_stdin() -> Version: ...
```

#### See also

- [Version](version.md#version)
- [Version](./version.md#version)

## parse_args

[[find in source code]](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py#L31)

```python
def parse_args(args: Sequence[str]) -> argparse.Namespace:
```
## parse_args

[Show source in cli_parser.py:31](https://github.com/vemel/newversion/blob/main/newversion/cli_parser.py#L31)

Main CLI parser.

#### Returns

Argument parser Namespace.

#### Signature

```python
def parse_args(args: Sequence[str]) -> argparse.Namespace: ...
```
34 changes: 21 additions & 13 deletions docs/newversion/constants.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
# Constants

> Auto-generated documentation for [newversion.constants](https://github.com/vemel/newversion/blob/main/newversion/constants.py) module.
[newversion Index](../README.md#newversion-index) /
[Newversion](./index.md#newversion) /
Constants

Constants used in project.
> Auto-generated documentation for [newversion.constants](https://github.com/vemel/newversion/blob/main/newversion/constants.py) module.
- [newversion](../README.md#newversion---your-version-manager) / [Modules](../MODULES.md#newversion-modules) / [Newversion](index.md#newversion) / Constants
- [Commands](#commands)
- [VersionParts](#versionparts)
- [Constants](#constants)
- [Commands](#commands)
- [VersionParts](#versionparts)

## Commands

[[find in source code]](https://github.com/vemel/newversion/blob/main/newversion/constants.py#L26)
[Show source in constants.py:26](https://github.com/vemel/newversion/blob/main/newversion/constants.py#L26)

CLI commands

#### Signature

```python
class Commands():
class Commands: ...
```

CLI commands

## VersionParts

[[find in source code]](https://github.com/vemel/newversion/blob/main/newversion/constants.py#L8)
## VersionParts

```python
class VersionParts():
```
[Show source in constants.py:8](https://github.com/vemel/newversion/blob/main/newversion/constants.py#L8)

Utility class with constants for version parts.

#### Signature

```python
class VersionParts: ...
```
Loading

0 comments on commit 8395845

Please sign in to comment.