setdoc 0.0.0.dev0__tar.gz → 0.1.1__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.
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: setdoc
3
- Version: 0.0.0.dev0
4
- Summary: setdoc
3
+ Version: 0.1.1
4
+ Summary: Set the doc string.
5
5
  Author-email: Johannes <johannes-programming@mailfence.com>
6
6
  License: The MIT License (MIT)
7
7
 
@@ -23,12 +23,13 @@ License: The MIT License (MIT)
23
23
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
26
+ SOFTWARE.
28
27
  Project-URL: Documentation, https://pypi.org/project/setdoc
29
28
  Project-URL: Download, https://pypi.org/project/setdoc/#files
30
- Project-URL: Source, https://github.com/johannes-programming/setdoc
31
- Classifier: Development Status :: 1 - Planning
29
+ Project-URL: Index, https://pypi.org/project/setdoc/
30
+ Project-URL: Source, https://github.com/johannes-programming/setdoc/
31
+ Project-URL: Website, https://setdoc.johannes-programming.online/
32
+ Classifier: Development Status :: 3 - Alpha
32
33
  Classifier: License :: OSI Approved :: MIT License
33
34
  Classifier: Programming Language :: Python
34
35
  Classifier: Programming Language :: Python :: 3
@@ -41,36 +42,4 @@ License-File: LICENSE.txt
41
42
  setdoc
42
43
  ======
43
44
 
44
- Overview
45
- --------
46
-
47
- setdoc
48
-
49
- Installation
50
- ------------
51
-
52
- To install ``setdoc``, you can use ``pip``. Open your terminal and run:
53
-
54
- .. code-block:: bash
55
-
56
- pip install setdoc
57
-
58
- License
59
- -------
60
-
61
- This project is licensed under the MIT License.
62
-
63
- Links
64
- -----
65
-
66
- * `Documentation <https://pypi.org/project/setdoc>`_
67
- * `Download <https://pypi.org/project/setdoc/#files>`_
68
- * `Source <https://github.com/johannes-programming/setdoc>`_
69
-
70
- Credits
71
- -------
72
-
73
- * Author: Johannes
74
- * Email: `johannes-programming@mailfence.com <mailto:johannes-programming@mailfence.com>`_
75
-
76
- Thank you for using ``setdoc``!
45
+ Visit the website `http://setdoc.johannes-programming.online <http://setdoc.johannes-programming.online>`_ for more information.
@@ -0,0 +1,5 @@
1
+ ======
2
+ setdoc
3
+ ======
4
+
5
+ Visit the website `http://setdoc.johannes-programming.online <http://setdoc.johannes-programming.online>`_ for more information.
@@ -9,19 +9,19 @@ authors = [
9
9
  { email = "johannes-programming@mailfence.com", name = "Johannes" },
10
10
  ]
11
11
  classifiers = [
12
- "Development Status :: 1 - Planning",
12
+ "Development Status :: 3 - Alpha",
13
13
  "License :: OSI Approved :: MIT License",
14
14
  "Programming Language :: Python",
15
15
  "Programming Language :: Python :: 3",
16
16
  "Programming Language :: Python :: 3 :: Only",
17
17
  ]
18
18
  dependencies = []
19
- description = "setdoc"
19
+ description = "Set the doc string."
20
20
  keywords = []
21
21
  name = "setdoc"
22
22
  readme = "README.rst"
23
23
  requires-python = ">=3.12.5"
24
- version = "0.0.0.dev0"
24
+ version = "0.1.1"
25
25
 
26
26
  [project.license]
27
27
  file = "LICENSE.txt"
@@ -29,4 +29,6 @@ file = "LICENSE.txt"
29
29
  [project.urls]
30
30
  Documentation = "https://pypi.org/project/setdoc"
31
31
  Download = "https://pypi.org/project/setdoc/#files"
32
- Source = "https://github.com/johannes-programming/setdoc"
32
+ Index = "https://pypi.org/project/setdoc/"
33
+ Source = "https://github.com/johannes-programming/setdoc/"
34
+ Website = "https://setdoc.johannes-programming.online/"
@@ -0,0 +1,2 @@
1
+ from setdoc.core import *
2
+ from setdoc.tests import *
@@ -0,0 +1,15 @@
1
+ import dataclasses
2
+ from typing import *
3
+
4
+ __all__ = ["setdoc"]
5
+
6
+
7
+ @dataclasses.dataclass
8
+ class setdoc:
9
+ "A class to set doc strings."
10
+ doc: Any
11
+
12
+ def __call__(self, target: Any) -> Any:
13
+ "Set the doc string of the passed target " "to the value stored in the doc field " "of the setdoc object."
14
+ target.__doc__ = self.doc
15
+ return target
@@ -0,0 +1,112 @@
1
+ import unittest
2
+ from typing import *
3
+
4
+ from setdoc.core import setdoc
5
+
6
+
7
+ class TestSetDocDecorator(unittest.TestCase):
8
+
9
+ def test_setdoc_on_function(self):
10
+ # Test the decorator on a standalone function
11
+ @setdoc("This is a test function")
12
+ def test_func():
13
+ pass
14
+
15
+ self.assertEqual(test_func.__doc__, "This is a test function")
16
+
17
+ def test_setdoc_on_class(self):
18
+ # Test the decorator on a class
19
+ @setdoc("This is a test class")
20
+ class TestClass:
21
+ pass
22
+
23
+ self.assertEqual(TestClass.__doc__, "This is a test class")
24
+
25
+ def test_setdoc_on_class_method(self):
26
+ # Test the decorator on a class method
27
+ class MyClass:
28
+ @setdoc("This is a test method")
29
+ def my_method(self):
30
+ pass
31
+
32
+ instance = MyClass()
33
+ self.assertEqual(instance.my_method.__doc__, "This is a test method")
34
+
35
+ def test_setdoc_on_static_method(self):
36
+ # Test the decorator on a static method
37
+ class MyClass:
38
+ @staticmethod
39
+ @setdoc("This is a static method")
40
+ def my_static_method():
41
+ pass
42
+
43
+ self.assertEqual(MyClass.my_static_method.__doc__, "This is a static method")
44
+
45
+ def test_setdoc_on_class_with_init(self):
46
+ # Test the decorator on a class that has an __init__ method
47
+ @setdoc("This is a class with __init__")
48
+ class InitClass:
49
+ def __init__(self, x):
50
+ self.x = x
51
+
52
+ instance = InitClass(5)
53
+ self.assertEqual(InitClass.__doc__, "This is a class with __init__")
54
+ self.assertEqual(instance.__doc__, "This is a class with __init__")
55
+
56
+ def test_setdoc_with_none_doc(self):
57
+ # Test with None to see if it handles absence of documentation
58
+ @setdoc(None)
59
+ def none_doc_func():
60
+ pass
61
+
62
+ self.assertIsNone(none_doc_func.__doc__)
63
+
64
+ def test_setdoc_on_class_property(self):
65
+ # Test the decorator on a property
66
+ class PropertyClass:
67
+ def __init__(self, value):
68
+ self._value = value
69
+
70
+ @property
71
+ @setdoc("This is a property")
72
+ def value(self):
73
+ return self._value
74
+
75
+ instance = PropertyClass(10)
76
+ self.assertEqual(PropertyClass.value.__doc__, "This is a property")
77
+ self.assertEqual(instance.value, 10)
78
+
79
+ def test_setdoc_on_classmethod(self):
80
+ # Test the decorator on a class method
81
+ class MyClass:
82
+ @classmethod
83
+ @setdoc("This is a class method")
84
+ def my_class_method(cls):
85
+ pass
86
+
87
+ self.assertEqual(MyClass.my_class_method.__doc__, "This is a class method")
88
+
89
+ def test_setdoc_on_nested_function(self):
90
+ # Test the decorator on a nested function
91
+ def outer_func():
92
+ @setdoc("This is a nested function")
93
+ def inner_func():
94
+ pass
95
+
96
+ return inner_func
97
+
98
+ nested_func = outer_func()
99
+ self.assertEqual(nested_func.__doc__, "This is a nested function")
100
+
101
+ def test_setdoc_on_function_with_existing_doc(self):
102
+ # Test if decorator replaces an existing docstring
103
+ @setdoc("New docstring")
104
+ def pre_doc_func():
105
+ """Old docstring"""
106
+ pass
107
+
108
+ self.assertEqual(pre_doc_func.__doc__, "New docstring")
109
+
110
+
111
+ if __name__ == "__main__":
112
+ unittest.main()
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: setdoc
3
- Version: 0.0.0.dev0
4
- Summary: setdoc
3
+ Version: 0.1.1
4
+ Summary: Set the doc string.
5
5
  Author-email: Johannes <johannes-programming@mailfence.com>
6
6
  License: The MIT License (MIT)
7
7
 
@@ -23,12 +23,13 @@ License: The MIT License (MIT)
23
23
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
24
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
26
+ SOFTWARE.
28
27
  Project-URL: Documentation, https://pypi.org/project/setdoc
29
28
  Project-URL: Download, https://pypi.org/project/setdoc/#files
30
- Project-URL: Source, https://github.com/johannes-programming/setdoc
31
- Classifier: Development Status :: 1 - Planning
29
+ Project-URL: Index, https://pypi.org/project/setdoc/
30
+ Project-URL: Source, https://github.com/johannes-programming/setdoc/
31
+ Project-URL: Website, https://setdoc.johannes-programming.online/
32
+ Classifier: Development Status :: 3 - Alpha
32
33
  Classifier: License :: OSI Approved :: MIT License
33
34
  Classifier: Programming Language :: Python
34
35
  Classifier: Programming Language :: Python :: 3
@@ -41,36 +42,4 @@ License-File: LICENSE.txt
41
42
  setdoc
42
43
  ======
43
44
 
44
- Overview
45
- --------
46
-
47
- setdoc
48
-
49
- Installation
50
- ------------
51
-
52
- To install ``setdoc``, you can use ``pip``. Open your terminal and run:
53
-
54
- .. code-block:: bash
55
-
56
- pip install setdoc
57
-
58
- License
59
- -------
60
-
61
- This project is licensed under the MIT License.
62
-
63
- Links
64
- -----
65
-
66
- * `Documentation <https://pypi.org/project/setdoc>`_
67
- * `Download <https://pypi.org/project/setdoc/#files>`_
68
- * `Source <https://github.com/johannes-programming/setdoc>`_
69
-
70
- Credits
71
- -------
72
-
73
- * Author: Johannes
74
- * Email: `johannes-programming@mailfence.com <mailto:johannes-programming@mailfence.com>`_
75
-
76
- Thank you for using ``setdoc``!
45
+ Visit the website `http://setdoc.johannes-programming.online <http://setdoc.johannes-programming.online>`_ for more information.
@@ -4,10 +4,11 @@ README.rst
4
4
  pyproject.toml
5
5
  setup.cfg
6
6
  src/setdoc/__init__.py
7
- src/setdoc/__main__.py
7
+ src/setdoc/core.py
8
8
  src/setdoc.egg-info/PKG-INFO
9
9
  src/setdoc.egg-info/SOURCES.txt
10
10
  src/setdoc.egg-info/dependency_links.txt
11
11
  src/setdoc.egg-info/top_level.txt
12
12
  src/setdoc/tests/__init__.py
13
- src/setdoc/tests/test_1984.py
13
+ src/setdoc/tests/test_1984.py
14
+ src/setdoc/tests/test_core.py
@@ -1,37 +0,0 @@
1
- ======
2
- setdoc
3
- ======
4
-
5
- Overview
6
- --------
7
-
8
- setdoc
9
-
10
- Installation
11
- ------------
12
-
13
- To install ``setdoc``, you can use ``pip``. Open your terminal and run:
14
-
15
- .. code-block:: bash
16
-
17
- pip install setdoc
18
-
19
- License
20
- -------
21
-
22
- This project is licensed under the MIT License.
23
-
24
- Links
25
- -----
26
-
27
- * `Documentation <https://pypi.org/project/setdoc>`_
28
- * `Download <https://pypi.org/project/setdoc/#files>`_
29
- * `Source <https://github.com/johannes-programming/setdoc>`_
30
-
31
- Credits
32
- -------
33
-
34
- * Author: Johannes
35
- * Email: `johannes-programming@mailfence.com <mailto:johannes-programming@mailfence.com>`_
36
-
37
- Thank you for using ``setdoc``!
@@ -1,6 +0,0 @@
1
- def main(args=None):
2
- print("Hello World!")
3
-
4
-
5
- if __name__ == "__main__":
6
- main()
@@ -1,4 +0,0 @@
1
- from setdoc import main
2
-
3
- if __name__ == "__main__":
4
- main()
File without changes
File without changes