docstring-to-text 1.0.1__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.
@@ -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))
@@ -3,13 +3,17 @@
3
3
  A simple pip package converting docstrings into clean text (proper paragraphs and indents).
4
4
  """
5
5
 
6
+ # This Source Code Form is subject to the terms of the Mozilla Public
7
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+
6
10
  import typing as _t
7
11
 
8
12
  from inspect import cleandoc, getdoc
9
13
  import re as _re
10
14
 
11
- from .__package_meta import VERSION
12
- from .__package_meta import VERSION as __version__
15
+ from .___package_meta import VERSION
16
+ from .___package_meta import VERSION as __version__
13
17
 
14
18
  # TODO:
15
19
  # - lists
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstring-to-text
3
- Version: 1.0.1
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,17 +11,34 @@ 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
 
19
+ <div align="center">
20
+
16
21
  # docstring-to-text
17
22
 
23
+ [![PyPI][pypi-shield]][pypi-url]
24
+ [![GitHub Release][github-release-shield]][github-release-url]
25
+ [![Test status][github-tests-shield]][github-tests-url]
26
+
27
+ [pypi-shield]: https://img.shields.io/pypi/v/docstring-to-text?logo=pypi
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
31
+ [github-release-shield]: https://img.shields.io/github/v/release/Lex-DRL/Py-docstring-to-text?logo=github
32
+ [github-release-url]: https://github.com/Lex-DRL/Py-docstring-to-text/releases/latest
33
+ </div>
34
+
18
35
  A simple pip package converting docstrings into clean text (proper paragraphs and indents).
19
36
 
20
37
  For example, here's a class docstring:
21
38
  ```python
22
39
  class MyClass:
23
40
  """
24
- Here's a class.
41
+ This is a class docstring.
25
42
 
26
43
 
27
44
  It has sphinx-like paragraphs, which can
@@ -60,7 +77,7 @@ clean_text = format_object_docstring(MyClass)
60
77
 
61
78
  Then, the resulting string would be:
62
79
  ```text
63
- Here's a class.
80
+ This is a class docstring.
64
81
 
65
82
  It has sphinx-like paragraphs, which can span multiple lines. Any modern IDE would display them as a single line, that wraps the given width.
66
83
  You can't just remove all the new lines in the entire string, because you want to preserve paragraphs themselves.
@@ -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,3 +0,0 @@
1
- # encoding: utf-8
2
-
3
- VERSION = "1.0.1"
@@ -1,6 +0,0 @@
1
- docstring_to_text/__init__.py,sha256=tkoGbf8ZJv70Nf2osZSn4DoHwSZKK2nvRREpvaVHank,4798
2
- docstring_to_text/__package_meta.py,sha256=AkzYkNZ1txGq77pbjfo4hVXLrvLpeJOHmfoOc0AZgiY,37
3
- docstring_to_text-1.0.1.dist-info/METADATA,sha256=JrCksCfeZ8SLMwzZ9GlM-olZCQWLfHY41q6JKHUp5ME,2297
4
- docstring_to_text-1.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- docstring_to_text-1.0.1.dist-info/licenses/LICENSE.md,sha256=quBniO1Sk1aqYUzwRO5adu_nnqOKV_4UVU4JVfnWiS0,15373
6
- docstring_to_text-1.0.1.dist-info/RECORD,,