Skip to content

Commit b832209

Browse files
committed
BUG: Fix types regression introduced in 148237b
Fixes #114
1 parent a42d273 commit b832209

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

pdoc/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,11 @@ def safe_default_value(p: inspect.Parameter):
11041104
elif ' at 0x' in repr(p.default):
11051105
replacement = re.sub(r' at 0x\w+', '', repr(p.default))
11061106

1107+
nonlocal link
1108+
if link and ('<' in repr(p.default) or '>' in repr(p.default)):
1109+
import html
1110+
replacement = html.escape(replacement or p.default)
1111+
11071112
if replacement:
11081113
class mock:
11091114
def __repr__(self):

pdoc/templates/html.mako

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
if returns:
105105
returns = ' ->\N{NBSP}' + returns
106106
%>
107-
<span>${f.funcdef()} ${ident(f.name)}</span>(<span>${params | h})${returns | h}</span>
107+
<span>${f.funcdef()} ${ident(f.name)}</span>(<span>${params})${returns}</span>
108108
</code></dt>
109109
<dd>${show_desc(f)}</dd>
110110
</%def>

pdoc/test/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ def test_Function_params(self):
639639
func = pdoc.Function('f', mod, lambda a=object(): None)
640640
self.assertEqual(func.params(), ['a=<object object>'])
641641

642+
func = pdoc.Function('f', mod, lambda a=object(): None)
643+
self.assertEqual(func.params(link=lambda x: ''), ['a=&lt;object object&gt;'])
644+
642645
# typed
643646
def f(a: int, *b, c: typing.List[pdoc.Doc] = []): pass
644647
func = pdoc.Function('f', mod, f)

0 commit comments

Comments
 (0)