Skip to content

Commit 3ceaf8b

Browse files
committed
special case for namedtuple fields
1 parent 15d322f commit 3ceaf8b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pdoc/html_helpers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,15 @@ def format_git_link(template: str, dobj: pdoc.Doc):
566566
commit = _git_head_commit()
567567
obj = dobj.obj
568568

569-
# special handlers for properties and cached_properties
569+
# special handlers for properties, cached_properties, and tuples
570570
if isinstance(obj, property):
571571
obj = obj.fget
572572
elif isinstance(obj, cached_property):
573573
obj = obj.func
574+
elif hasattr(obj, '__class__') and obj.__class__.__name__ == '_tuplegetter':
575+
# This is a NamedTuple field
576+
class_name = dobj.qualname.rsplit('.', 1)[0]
577+
obj = getattr(dobj.module.obj, class_name)
574578

575579
abs_path = inspect.getfile(inspect.unwrap(obj))
576580
path = _project_relative_path(abs_path)

0 commit comments

Comments
 (0)