docstring-to-text 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docstring_to_text-1.0.3/.github/workflows/test.yml +68 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/.gitignore +3 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/PKG-INFO +8 -2
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/README.md +4 -1
- docstring_to_text-1.0.3/pyproject.toml +74 -0
- docstring_to_text-1.0.3/src/docstring_to_text/___package_meta.py +111 -0
- docstring_to_text-1.0.3/tests/import_test.py +18 -0
- docstring_to_text-1.0.3/tests/test____package_meta.py +35 -0
- docstring_to_text-1.0.2/pyproject.toml +0 -32
- docstring_to_text-1.0.2/src/docstring_to_text/___package_meta.py +0 -3
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/.gitattributes +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/.github/workflows/publish-release-to-pypi.yml +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/LICENSE.md +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/_build.bat +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/_upload-release.bat +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/_upload-test.bat +0 -0
- {docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/src/docstring_to_text/__init__.py +0 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
# https://docs.github.com/en/actions/tutorials/build-and-test-code/python
|
2
|
+
name: Tests 🔬
|
3
|
+
# Alt emojis: https://emojidb.org/debug-emojis 👀 🔎 👷 🚧 🛠️ 🔨 👾 🤖 👨🏻💻 🧐
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ main ]
|
8
|
+
paths:
|
9
|
+
- '**.py'
|
10
|
+
- 'pyproject.toml'
|
11
|
+
pull_request:
|
12
|
+
branches: [ main ]
|
13
|
+
# types: [ opened, synchronize, reopened ] # default values; comments, labels, etc. are ignored
|
14
|
+
paths:
|
15
|
+
- '**.py'
|
16
|
+
- 'pyproject.toml'
|
17
|
+
|
18
|
+
permissions:
|
19
|
+
contents: read
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
test:
|
23
|
+
# runs-on: ${{ matrix.os }} # when multi-OS-testing specified below
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
timeout-minutes: 5 # Prevent stuck jobs
|
26
|
+
|
27
|
+
strategy:
|
28
|
+
matrix:
|
29
|
+
# To test on multiple OSes:
|
30
|
+
# https://docs.github.com/en/actions/tutorials/build-and-test-code/python#excluding-a-version
|
31
|
+
# os: [ubuntu-latest, macos-latest, windows-latest]
|
32
|
+
|
33
|
+
# Python versions to test against:
|
34
|
+
python-version:
|
35
|
+
# > The version '3.7' with architecture 'x64' was not found for Ubuntu 24.04.
|
36
|
+
# - '3.7' # seems no longer supported by GitHub
|
37
|
+
- '3.8'
|
38
|
+
- '3.9'
|
39
|
+
- '3.10'
|
40
|
+
- '3.11'
|
41
|
+
- '3.12'
|
42
|
+
- '3.13'
|
43
|
+
- '3.14'
|
44
|
+
|
45
|
+
steps:
|
46
|
+
- name: Checkout code
|
47
|
+
uses: actions/checkout@v4
|
48
|
+
|
49
|
+
- name: Set up Python ${{ matrix.python-version }}
|
50
|
+
uses: actions/setup-python@v5
|
51
|
+
with:
|
52
|
+
python-version: ${{ matrix.python-version }}
|
53
|
+
cache: 'pip' # Enable built-in pip caching
|
54
|
+
cache-dependency-path: 'pyproject.toml'
|
55
|
+
|
56
|
+
- name: Install dependencies
|
57
|
+
run: |
|
58
|
+
python -m pip install --upgrade pip
|
59
|
+
# Just to be safe, in case some pytest plugins need the package itself installed into venv,
|
60
|
+
# do the "editable" install... and since we're doing it anyway,
|
61
|
+
# let's also install the test dependencies from pyproject.toml, too:
|
62
|
+
pip install -e .[test]
|
63
|
+
# Alternatively:
|
64
|
+
# pip install pytest pytest-cov # Only test deps, no package, but doesn't use deps from pyproject.toml
|
65
|
+
|
66
|
+
- name: Run tests with pytest
|
67
|
+
run: |
|
68
|
+
python -m pytest
|
@@ -121,6 +121,9 @@ htmlcov/
|
|
121
121
|
nosetests.xml
|
122
122
|
coverage.xml
|
123
123
|
*.cover
|
124
|
+
# The next one is NOT a typo - whether a bug in coverage lib or not, but it
|
125
|
+
# can actually create a file with such "extension" (with comma):
|
126
|
+
# https://github.com/nedbat/coveragepy/blob/8827634adcfe4a4baf71cf0b3e1cd967cf9b14a2/coverage/annotate.py#L84
|
124
127
|
*,cover
|
125
128
|
.hypothesis/
|
126
129
|
.pytest_cache/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: docstring-to-text
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.3
|
4
4
|
Summary: A simple pip package converting docstrings into clean text (proper paragraphs and indents)
|
5
5
|
Project-URL: Source Code, https://github.com/Lex-DRL/Py-docstring-to-text
|
6
6
|
Project-URL: Issues, https://github.com/Lex-DRL/Py-docstring-to-text/issues
|
@@ -11,6 +11,9 @@ Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
13
13
|
Requires-Python: >=3.7
|
14
|
+
Provides-Extra: test
|
15
|
+
Requires-Dist: pytest; extra == 'test'
|
16
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
14
17
|
Description-Content-Type: text/markdown
|
15
18
|
|
16
19
|
<div align="center">
|
@@ -18,10 +21,13 @@ Description-Content-Type: text/markdown
|
|
18
21
|
# docstring-to-text
|
19
22
|
|
20
23
|
[![PyPI][pypi-shield]][pypi-url]
|
21
|
-
[![][github-release-shield]][github-release-url]
|
24
|
+
[![GitHub Release][github-release-shield]][github-release-url]
|
25
|
+
[![Test status][github-tests-shield]][github-tests-url]
|
22
26
|
|
23
27
|
[pypi-shield]: https://img.shields.io/pypi/v/docstring-to-text?logo=pypi
|
24
28
|
[pypi-url]: https://pypi.org/p/docstring-to-text
|
29
|
+
[github-tests-shield]: https://github.com/Lex-DRL/Py-docstring-to-text/actions/workflows/test.yml/badge.svg?branch=main
|
30
|
+
[github-tests-url]: https://github.com/Lex-DRL/Py-docstring-to-text/actions/workflows/test.yml?query=branch%3Amain
|
25
31
|
[github-release-shield]: https://img.shields.io/github/v/release/Lex-DRL/Py-docstring-to-text?logo=github
|
26
32
|
[github-release-url]: https://github.com/Lex-DRL/Py-docstring-to-text/releases/latest
|
27
33
|
</div>
|
@@ -3,10 +3,13 @@
|
|
3
3
|
# docstring-to-text
|
4
4
|
|
5
5
|
[![PyPI][pypi-shield]][pypi-url]
|
6
|
-
[![][github-release-shield]][github-release-url]
|
6
|
+
[![GitHub Release][github-release-shield]][github-release-url]
|
7
|
+
[![Test status][github-tests-shield]][github-tests-url]
|
7
8
|
|
8
9
|
[pypi-shield]: https://img.shields.io/pypi/v/docstring-to-text?logo=pypi
|
9
10
|
[pypi-url]: https://pypi.org/p/docstring-to-text
|
11
|
+
[github-tests-shield]: https://github.com/Lex-DRL/Py-docstring-to-text/actions/workflows/test.yml/badge.svg?branch=main
|
12
|
+
[github-tests-url]: https://github.com/Lex-DRL/Py-docstring-to-text/actions/workflows/test.yml?query=branch%3Amain
|
10
13
|
[github-release-shield]: https://img.shields.io/github/v/release/Lex-DRL/Py-docstring-to-text?logo=github
|
11
14
|
[github-release-url]: https://github.com/Lex-DRL/Py-docstring-to-text/releases/latest
|
12
15
|
</div>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
2
|
+
|
3
|
+
[build-system]
|
4
|
+
requires = ["hatchling >= 1.26"]
|
5
|
+
build-backend = "hatchling.build"
|
6
|
+
|
7
|
+
[project]
|
8
|
+
name = "docstring-to-text"
|
9
|
+
dynamic = ["version"]
|
10
|
+
# version = "0.0.1" # used dynamically, see tool.hatch.version
|
11
|
+
description = "A simple pip package converting docstrings into clean text (proper paragraphs and indents)"
|
12
|
+
authors = [
|
13
|
+
{ name="Lex Darlog (Lex-DRL)" },
|
14
|
+
]
|
15
|
+
readme = "README.md"
|
16
|
+
# https://packaging.python.org/en/latest/specifications/core-metadata/#license-expression
|
17
|
+
# https://spdx.org/licenses/
|
18
|
+
license = "MPL-2.0"
|
19
|
+
license-files = ["LICEN[CS]E*"]
|
20
|
+
requires-python = ">=3.7"
|
21
|
+
classifiers = [
|
22
|
+
"Programming Language :: Python :: 3",
|
23
|
+
"Operating System :: OS Independent",
|
24
|
+
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
|
25
|
+
]
|
26
|
+
|
27
|
+
[project.urls]
|
28
|
+
"Source Code" = "https://github.com/Lex-DRL/Py-docstring-to-text"
|
29
|
+
Issues = "https://github.com/Lex-DRL/Py-docstring-to-text/issues"
|
30
|
+
|
31
|
+
[project.optional-dependencies]
|
32
|
+
# For: pip install .[test]
|
33
|
+
test = [
|
34
|
+
"pytest",
|
35
|
+
"pytest-cov",
|
36
|
+
]
|
37
|
+
|
38
|
+
[tool.hatch.version]
|
39
|
+
path = "src/docstring_to_text/___package_meta.py"
|
40
|
+
|
41
|
+
[tool.pytest.ini_options]
|
42
|
+
pythonpath = ["src"]
|
43
|
+
testpaths = ["tests"] # Don't scan for tests anywhere else; speeds up test collection
|
44
|
+
addopts = [
|
45
|
+
"--import-mode=importlib", # Recommended for new projects to avoid sys.path manipulation issues
|
46
|
+
"-ra", # Show summary of all test outcomes
|
47
|
+
"--ignore=tests/data/", # Excludes this exact path from discovery
|
48
|
+
"--cov=docstring_to_text", # Measure the package coverage
|
49
|
+
"--cov-report=term-missing", # Show missing lines in terminal
|
50
|
+
"--cov-fail-under=0", # Never fail tests due to low coverage
|
51
|
+
]
|
52
|
+
|
53
|
+
[tool.coverage.run]
|
54
|
+
source = ["src/docstring_to_text"]
|
55
|
+
omit = [
|
56
|
+
"*/tests/*",
|
57
|
+
"*/test_*",
|
58
|
+
"*/__pycache__/*",
|
59
|
+
]
|
60
|
+
|
61
|
+
[tool.coverage.report]
|
62
|
+
exclude_lines = [
|
63
|
+
"pragma: no cover",
|
64
|
+
"def __repr__",
|
65
|
+
"if self\\.debug",
|
66
|
+
"if settings\\.DEBUG",
|
67
|
+
"raise AssertionError",
|
68
|
+
"raise NotImplementedError",
|
69
|
+
"if 0:",
|
70
|
+
"if __name__ == [\"']__main__[\"']:",
|
71
|
+
"@(abc\\.)?abstractmethod",
|
72
|
+
]
|
73
|
+
ignore_errors = true
|
74
|
+
precision = 2 # Number of shown decimal places. E.g.: 12.34%
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# It should be a hard-coded string, as close to the beginning of file as possible,
|
4
|
+
# for Hatchling build tools to properly parse it:
|
5
|
+
VERSION = "1.0.3"
|
6
|
+
|
7
|
+
|
8
|
+
# =============================================================
|
9
|
+
# Parsing it into a tuple, more suitable for version comparison
|
10
|
+
|
11
|
+
|
12
|
+
import typing as _t
|
13
|
+
|
14
|
+
import re as _re
|
15
|
+
|
16
|
+
_re_separate = _re.compile(
|
17
|
+
# r'^' # not necessary with `re.match()`
|
18
|
+
r'([a-zA-Z_0-9\s]*)' # valid version-seg characters - greedy
|
19
|
+
r'[^a-zA-Z_0-9\s]+' # anything else
|
20
|
+
r'(.*?)' # the remainder of the string, possibly with a mix of both - lazy
|
21
|
+
r'$' # must match the entire string
|
22
|
+
).match
|
23
|
+
|
24
|
+
|
25
|
+
def _raw_version_parts_gen(ver_str: str) -> _t.Generator[str, _t.Any, None]:
|
26
|
+
"""Splits version string into parts.
|
27
|
+
|
28
|
+
Parts contain only alphanumeric characters, underscores and spaces/tabs.
|
29
|
+
Anything else considered a separator.
|
30
|
+
Integer sub-parts aren't extracted yet.
|
31
|
+
"""
|
32
|
+
assert ver_str and isinstance(ver_str, str)
|
33
|
+
remainder: str = ver_str.strip()
|
34
|
+
|
35
|
+
match = _re_separate(remainder)
|
36
|
+
while match:
|
37
|
+
groups = [
|
38
|
+
x.strip() if x else ''
|
39
|
+
for x in match.groups()
|
40
|
+
]
|
41
|
+
while len(groups) < 2:
|
42
|
+
groups.append('')
|
43
|
+
part, remainder = groups[:2]
|
44
|
+
|
45
|
+
# to replace any whitespace sequences to single spaces:
|
46
|
+
part = ' '.join(part.split())
|
47
|
+
if part:
|
48
|
+
yield part
|
49
|
+
|
50
|
+
match = _re_separate(remainder)
|
51
|
+
|
52
|
+
if remainder:
|
53
|
+
yield remainder
|
54
|
+
|
55
|
+
|
56
|
+
_re_int_extractor = _re.compile(
|
57
|
+
r'([^0-9]*)'
|
58
|
+
r'([0-9]+)'
|
59
|
+
r'([^0-9].*?)?'
|
60
|
+
r'$'
|
61
|
+
).match
|
62
|
+
|
63
|
+
|
64
|
+
def _part_to_final_segs_gen(str_part: str) -> _t.Generator[_t.Union[int, str], _t.Any, None]:
|
65
|
+
"""Given one part, separates it into actual version segments."""
|
66
|
+
assert str_part and isinstance(str_part, str)
|
67
|
+
remainder: str = str_part
|
68
|
+
|
69
|
+
while remainder:
|
70
|
+
remainder = remainder.strip().strip('_')
|
71
|
+
match = _re_int_extractor(remainder)
|
72
|
+
if not match:
|
73
|
+
assert not any(x in remainder for x in '0123456789'), (
|
74
|
+
f"Internal error: last version-remainder for {str_part!r} part still contains digits: {remainder!r}"
|
75
|
+
)
|
76
|
+
break
|
77
|
+
|
78
|
+
groups = [
|
79
|
+
x.strip().strip('_') if x else ''
|
80
|
+
for x in match.groups()
|
81
|
+
]
|
82
|
+
while len(groups) < 3:
|
83
|
+
groups.append('')
|
84
|
+
text_prefix, int_str, remainder = groups[:3]
|
85
|
+
|
86
|
+
if text_prefix:
|
87
|
+
yield text_prefix
|
88
|
+
|
89
|
+
yield int(int_str)
|
90
|
+
|
91
|
+
if remainder:
|
92
|
+
yield remainder
|
93
|
+
|
94
|
+
|
95
|
+
def _version_parts_gen(ver_str: str) -> _t.Generator[_t.Union[int, str], _t.Any, None]:
|
96
|
+
"""Parse version string into parts, with ints.
|
97
|
+
|
98
|
+
- '0.1.2' -> (0, 1, 2)
|
99
|
+
- '0.1.2rc' -> (0, 1, 2, 'rc')
|
100
|
+
- '0.1.2rc0123' -> (0, 1, 2, 'rc', 123)
|
101
|
+
- '0.1.2-alpha1' -> (0, 1, 2, 'alpha', 1)
|
102
|
+
- '0-1-2-beta-1' -> (0, 1, 2, 'beta', 1) # though, non-compliant with semantic versioning
|
103
|
+
- '0.1.2.beta.2' -> (0, 1, 2, 'beta', 2)
|
104
|
+
"""
|
105
|
+
for str_part in _raw_version_parts_gen(ver_str):
|
106
|
+
for seg in _part_to_final_segs_gen(str_part):
|
107
|
+
yield seg
|
108
|
+
|
109
|
+
|
110
|
+
# For actual python code to compare:
|
111
|
+
VERSION_TUPLE: _t.Tuple[_t.Union[int, str], ...] = tuple(_version_parts_gen(VERSION))
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
"""A sanity-check import test - just to have at least one test, which (supposedly) always passes."""
|
3
|
+
|
4
|
+
|
5
|
+
def test_import_package():
|
6
|
+
try:
|
7
|
+
import docstring_to_text
|
8
|
+
except ImportError:
|
9
|
+
assert False, "Can't import the package"
|
10
|
+
assert True
|
11
|
+
|
12
|
+
|
13
|
+
def test_import_version():
|
14
|
+
try:
|
15
|
+
from docstring_to_text import VERSION
|
16
|
+
except ImportError:
|
17
|
+
assert False, "Can't import the package version"
|
18
|
+
assert isinstance(VERSION, str)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
4
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
5
|
+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
6
|
+
|
7
|
+
"""
|
8
|
+
"""
|
9
|
+
|
10
|
+
import typing as _t
|
11
|
+
from typing import Union as _U
|
12
|
+
|
13
|
+
import pytest
|
14
|
+
|
15
|
+
from docstring_to_text.___package_meta import _version_parts_gen
|
16
|
+
|
17
|
+
@pytest.mark.parametrize(
|
18
|
+
"ver_str, ver_tuple",
|
19
|
+
[
|
20
|
+
('1.2:3', (1, 2, 3)),
|
21
|
+
('4`5 6', (4, 5, 6)),
|
22
|
+
('7 8!`-~9--.__Release Candidate__', (7, 8, 9, 'Release Candidate')),
|
23
|
+
('0.1.2', (0, 1, 2)),
|
24
|
+
('0.1.2rc', (0, 1, 2, 'rc')),
|
25
|
+
('0.1.2rc0', (0, 1, 2, 'rc', 0)),
|
26
|
+
('0.1.2rc1', (0, 1, 2, 'rc', 1)),
|
27
|
+
('0.1.2rc0123', (0, 1, 2, 'rc', 123)),
|
28
|
+
('0.1.2-alpha', (0, 1, 2, 'alpha')),
|
29
|
+
('0.1.2-alpha1', (0, 1, 2, 'alpha', 1)),
|
30
|
+
('0-1-2-beta-1', (0, 1, 2, 'beta', 1)),
|
31
|
+
('0.1.2.beta.2', (0, 1, 2, 'beta', 2)),
|
32
|
+
]
|
33
|
+
)
|
34
|
+
def test__version_parts_gen(ver_str: str, ver_tuple: _t.Tuple[_U[int, str], ...]):
|
35
|
+
assert tuple(_version_parts_gen(ver_str)) == ver_tuple
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
|
2
|
-
|
3
|
-
[build-system]
|
4
|
-
requires = ["hatchling >= 1.26"]
|
5
|
-
build-backend = "hatchling.build"
|
6
|
-
|
7
|
-
[project]
|
8
|
-
name = "docstring-to-text"
|
9
|
-
dynamic = ["version"]
|
10
|
-
# version = "0.0.1"
|
11
|
-
description = "A simple pip package converting docstrings into clean text (proper paragraphs and indents)"
|
12
|
-
authors = [
|
13
|
-
{ name="Lex Darlog (Lex-DRL)" },
|
14
|
-
]
|
15
|
-
readme = "README.md"
|
16
|
-
# https://packaging.python.org/en/latest/specifications/core-metadata/#license-expression
|
17
|
-
# https://spdx.org/licenses/
|
18
|
-
license = "MPL-2.0"
|
19
|
-
license-files = ["LICEN[CS]E*"]
|
20
|
-
requires-python = ">=3.7"
|
21
|
-
classifiers = [
|
22
|
-
"Programming Language :: Python :: 3",
|
23
|
-
"Operating System :: OS Independent",
|
24
|
-
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
|
25
|
-
]
|
26
|
-
|
27
|
-
[project.urls]
|
28
|
-
"Source Code" = "https://github.com/Lex-DRL/Py-docstring-to-text"
|
29
|
-
Issues = "https://github.com/Lex-DRL/Py-docstring-to-text/issues"
|
30
|
-
|
31
|
-
[tool.hatch.version]
|
32
|
-
path = "src/docstring_to_text/___package_meta.py"
|
File without changes
|
{docstring_to_text-1.0.2 → docstring_to_text-1.0.3}/.github/workflows/publish-release-to-pypi.yml
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|