From 4aa70de2221a34a3003a7e5f52a9b91965f0e359 Mon Sep 17 00:00:00 2001
From: Spencer Baugh
Date: Thu, 23 Sep 2021 09:00:25 -0400
Subject: [PATCH 01/31] TST: use explicit ClassWithNew instead of
typing.Generic
typing.Generic doesn't have a __new__ method in 3.9.
Fixes https://github.com/pdoc3/pdoc/issues/355
---
pdoc/test/__init__.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pdoc/test/__init__.py b/pdoc/test/__init__.py
index e8c3d94a..8b67ab77 100644
--- a/pdoc/test/__init__.py
+++ b/pdoc/test/__init__.py
@@ -1043,16 +1043,20 @@ class C2:
self.assertEqual(pdoc.Class('C2', mod, C2).params(), ['a', 'b', 'c=None', '*', 'd=1', 'e'])
- class G(typing.Generic[T]):
+ class ClassWithNew:
+ def __new__(self, arg):
+ pass
+
+ class G(ClassWithNew):
def __init__(self, a, b, c=100):
pass
self.assertEqual(pdoc.Class('G', mod, G).params(), ['a', 'b', 'c=100'])
- class G2(typing.Generic[T]):
+ class G2(ClassWithNew):
pass
- self.assertEqual(pdoc.Class('G2', mod, G2).params(), ['*args', '**kwds'])
+ self.assertEqual(pdoc.Class('G2', mod, G2).params(), ['arg'])
def test_url(self):
mod = pdoc.Module(EXAMPLE_MODULE)
From 2cce30a9b55eeeddc1ed826c8a2ada53777c3eea Mon Sep 17 00:00:00 2001
From: Howard Smith
Date: Thu, 3 Feb 2022 14:42:26 +0000
Subject: [PATCH 02/31] Leave trailing line break in reST directives (#385)
* Add to `pdoc.test.Docformats.test_reST_include` to catch issue.
* Add a single line-break at the end of `.. include::`ed files - except for when in a code block.
* Minor change comment
* Revert last 2 commits.
* Don't consume trailing newline from reST directives.
* [] itself a disjunctive list of characters
---
pdoc/html_helpers.py | 6 +++++-
pdoc/test/__init__.py | 17 ++++++++++++++++-
pdoc/test/example_pkg/_reST_include/table.md | 3 +++
pdoc/test/example_pkg/_reST_include/test.py | 4 ++++
4 files changed, 28 insertions(+), 2 deletions(-)
create mode 100644 pdoc/test/example_pkg/_reST_include/table.md
diff --git a/pdoc/html_helpers.py b/pdoc/html_helpers.py
index 8ba63db6..51861947 100644
--- a/pdoc/html_helpers.py
+++ b/pdoc/html_helpers.py
@@ -275,6 +275,9 @@ def _admonition(match, module=None, limit_types=None):
if limit_types and type not in limit_types:
return match.group(0)
+ if text is None:
+ text = ""
+
if type == 'include' and module:
try:
return _ToMarkdown._include_file(indent, value,
@@ -323,7 +326,8 @@ def admonitions(text, module, limit_types=None):
See: https://python-markdown.github.io/extensions/admonition/
"""
substitute = partial(re.compile(r'^(?P *)\.\. ?(\w+)::(?: *(.*))?'
- r'((?:\n(?:(?P=indent) +.*| *$))*)', re.MULTILINE).sub,
+ r'((?:\n(?:(?P=indent) +.*| *$))*[^\r\n])*',
+ re.MULTILINE).sub,
partial(_ToMarkdown._admonition, module=module,
limit_types=limit_types))
# Apply twice for nested (e.g. image inside warning)
diff --git a/pdoc/test/__init__.py b/pdoc/test/__init__.py
index 8b67ab77..c98d0c8e 100644
--- a/pdoc/test/__init__.py
+++ b/pdoc/test/__init__.py
@@ -1568,7 +1568,22 @@ def test_reST_include(self):
1
x = 2
x = 3
-x =
'''
+x =
+
+
+
+Name |
+Value |
+
+
+
+
+Hello |
+World |
+
+
+
+Remaining.
'''
mod = pdoc.Module(pdoc.import_module(
os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE, '_reST_include', 'test.py')))
html = to_html(mod.docstring, module=mod)
diff --git a/pdoc/test/example_pkg/_reST_include/table.md b/pdoc/test/example_pkg/_reST_include/table.md
new file mode 100644
index 00000000..abf0fc4f
--- /dev/null
+++ b/pdoc/test/example_pkg/_reST_include/table.md
@@ -0,0 +1,3 @@
+| Name | Value |
+| ----- | ----- |
+| Hello | World |
diff --git a/pdoc/test/example_pkg/_reST_include/test.py b/pdoc/test/example_pkg/_reST_include/test.py
index 96c25c41..acf75900 100644
--- a/pdoc/test/example_pkg/_reST_include/test.py
+++ b/pdoc/test/example_pkg/_reST_include/test.py
@@ -8,4 +8,8 @@
.. include:: foo/../_include_me.py
:start-after: =
:end-before: 4
+
+.. include:: table.md
+
+Remaining.
"""
From 60f77d2e6c033f62be8a9351c863246e5f88b4a1 Mon Sep 17 00:00:00 2001
From: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com>
Date: Fri, 19 Aug 2022 20:06:32 +0530
Subject: [PATCH 03/31] BUG: Skip `__editable__` paths during `iter_modules`
(#408)
* Skip `__editable__` paths during `iter_modules`
* Update pdoc/__init__.py
---
pdoc/__init__.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pdoc/__init__.py b/pdoc/__init__.py
index 0f05b2c0..8524291e 100644
--- a/pdoc/__init__.py
+++ b/pdoc/__init__.py
@@ -727,6 +727,9 @@ def iter_modules(paths):
"""
from os.path import isdir, join
for pth in paths:
+ if pth.startswith("__editable__."):
+ # See https://github.com/pypa/pip/issues/11380
+ continue
for file in os.listdir(pth):
if file.startswith(('.', '__pycache__', '__init__.py')):
continue
From fce8d989748fc868f215882ed2f7f2829b588ce8 Mon Sep 17 00:00:00 2001
From: Kernc
Date: Sun, 3 Apr 2022 21:27:59 +0200
Subject: [PATCH 04/31] BUG: Remove extra preceding newlines in markdown
listing
---
pdoc/templates/text.mako | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pdoc/templates/text.mako b/pdoc/templates/text.mako
index 720a59cd..35e5eeda 100644
--- a/pdoc/templates/text.mako
+++ b/pdoc/templates/text.mako
@@ -12,21 +12,21 @@
%def>
<%def name="function(func)" buffered="True">
- <%
+<%
returns = show_type_annotations and func.return_annotation() or ''
if returns:
returns = ' \N{non-breaking hyphen}> ' + returns
- %>
+%>
`${func.name}(${", ".join(func.params(annotate=show_type_annotations))})${returns}`
${func.docstring | deflist}
%def>
<%def name="variable(var)" buffered="True">
- <%
+<%
annot = show_type_annotations and var.type_annotation() or ''
if annot:
annot = ': ' + annot
- %>
+%>
`${var.name}${annot}`
${var.docstring | deflist}
%def>
From b3a56d9e8628554f24cf31554e436079e1555341 Mon Sep 17 00:00:00 2001
From: Kernc
Date: Sat, 29 Oct 2022 18:30:43 +0200
Subject: [PATCH 05/31] CI: Fix mypy warning
---
pdoc/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pdoc/__init__.py b/pdoc/__init__.py
index 8524291e..41f4fb61 100644
--- a/pdoc/__init__.py
+++ b/pdoc/__init__.py
@@ -533,7 +533,7 @@ def __init__(self, name: str, module, obj, docstring: str = None):
def __repr__(self):
return f'<{self.__class__.__name__} {self.refname!r}>'
- @property # type: ignore
+ @property
@lru_cache()
def source(self) -> str:
"""
From 80af5d40d3ca39e2701c44941c1003ae6a280799 Mon Sep 17 00:00:00 2001
From: Kernc
Date: Sat, 29 Oct 2022 18:55:46 +0200
Subject: [PATCH 06/31] CI: Bump min Python 3.7+ and update tests for Python
3.10
Fix https://github.com/pdoc3/pdoc/issues/400
Thanks @tjni
---
.github/workflows/ci.yml | 6 +++---
pdoc/__init__.py | 2 +-
pdoc/documentation.md | 2 +-
pdoc/test/__init__.py | 23 ++++++++++++++++++-----
setup.py | 6 +++---
5 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 75b394f6..238673a2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,11 +11,11 @@ jobs:
strategy:
matrix:
- python-version: [3.6, 3.7]
+ python-version: [3.7, 3.8, '3.10']
include:
- - python-version: 3.8
+ - python-version: 3.9
test-type: lint
- - python-version: 3.8
+ - python-version: 3.9
test-type: docs
steps:
diff --git a/pdoc/__init__.py b/pdoc/__init__.py
index 41f4fb61..c1e784ee 100644
--- a/pdoc/__init__.py
+++ b/pdoc/__init__.py
@@ -1275,7 +1275,7 @@ def _formatannotation(annot):
`typing.Optional`, `nptyping.NDArray` and other types.
>>> _formatannotation(NewType('MyType', str))
- 'MyType'
+ 'pdoc.MyType'
>>> _formatannotation(Optional[Tuple[Optional[int], None]])
'Optional[Tuple[Optional[int], None]]'
"""
diff --git a/pdoc/documentation.md b/pdoc/documentation.md
index 57e1a002..e6b477b3 100644
--- a/pdoc/documentation.md
+++ b/pdoc/documentation.md
@@ -353,7 +353,7 @@ modified templates into the `directories` list of the
Compatibility
-------------
-`pdoc` requires Python 3.6+.
+`pdoc` requires Python 3.7+.
The last version to support Python 2.x is [pdoc3 0.3.x].
[pdoc3 0.3.x]: https://pypi.org/project/pdoc3/0.3.13/
diff --git a/pdoc/test/__init__.py b/pdoc/test/__init__.py
index c98d0c8e..6b59f0ed 100644
--- a/pdoc/test/__init__.py
+++ b/pdoc/test/__init__.py
@@ -126,7 +126,8 @@ class CliTest(unittest.TestCase):
def setUp(self):
pdoc.reset()
- @unittest.skipIf(sys.version_info < (3, 7), 'pdoc._formatannotation fails on Py3.6')
+ @unittest.skipIf(sys.version_info < (3, 10),
+ 'HACK: _formatannotation() changed return value in Py3.10')
def test_project_doctests(self):
doctests = doctest.testmod(pdoc)
assert not doctests.failed and doctests.attempted, doctests
@@ -185,8 +186,12 @@ def test_html(self):
'