docstring-to-text 1.0.2__py3-none-any.whl → 1.0.3__py3-none-any.whl
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/___package_meta.py +109 -1
- {docstring_to_text-1.0.2.dist-info → docstring_to_text-1.0.3.dist-info}/METADATA +8 -2
- docstring_to_text-1.0.3.dist-info/RECORD +6 -0
- docstring_to_text-1.0.2.dist-info/RECORD +0 -6
- {docstring_to_text-1.0.2.dist-info → docstring_to_text-1.0.3.dist-info}/WHEEL +0 -0
- {docstring_to_text-1.0.2.dist-info → docstring_to_text-1.0.3.dist-info}/licenses/LICENSE.md +0 -0
@@ -1,3 +1,111 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
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))
|
@@ -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>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
docstring_to_text/___package_meta.py,sha256=3rGnvbA_I52gm_UFR_7Pl8TerSA-eC5OHm5LzS63Ics,2921
|
2
|
+
docstring_to_text/__init__.py,sha256=BDcfU7T33sckZzEZFZn2GPezDtb9fkv1A2uo2mPYZas,5000
|
3
|
+
docstring_to_text-1.0.3.dist-info/METADATA,sha256=XrbJhSHaYyPAtV6ZY8wS-XIh-C137GT6HyM0w7bz1u4,3156
|
4
|
+
docstring_to_text-1.0.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
+
docstring_to_text-1.0.3.dist-info/licenses/LICENSE.md,sha256=quBniO1Sk1aqYUzwRO5adu_nnqOKV_4UVU4JVfnWiS0,15373
|
6
|
+
docstring_to_text-1.0.3.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
docstring_to_text/___package_meta.py,sha256=FUBADIvPxuLvXBzbXbL6C1ybLYS24VOYEd_RcSq76tQ,37
|
2
|
-
docstring_to_text/__init__.py,sha256=BDcfU7T33sckZzEZFZn2GPezDtb9fkv1A2uo2mPYZas,5000
|
3
|
-
docstring_to_text-1.0.2.dist-info/METADATA,sha256=x73dRgwjxhTFwd8D-znLYo7mYL61OdF6UwG9H0ky7VI,2748
|
4
|
-
docstring_to_text-1.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
-
docstring_to_text-1.0.2.dist-info/licenses/LICENSE.md,sha256=quBniO1Sk1aqYUzwRO5adu_nnqOKV_4UVU4JVfnWiS0,15373
|
6
|
-
docstring_to_text-1.0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|