Skip to content

Commit 01ac524

Browse files
authored
feat: Add support for help_text field parameter as docstring for django model fields
Issue #127: #127 PR #129: #129
1 parent 9a3c47a commit 01ac524

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/pytkdocs/loader.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,19 @@ def get_django_field_documentation(node: ObjectNode) -> Attribute:
741741
if prop.blank:
742742
properties.append("blank")
743743

744+
# set correct docstring based on verbose_name and help_text
745+
# both should be converted to str type in case lazy translation
746+
# is being used, which is common scenario in django
747+
if prop.help_text:
748+
docstring = f"{prop.verbose_name}: {prop.help_text}"
749+
else:
750+
docstring = str(prop.verbose_name)
751+
744752
return Attribute(
745753
name=node.name,
746754
path=path,
747755
file_path=node.file_path,
748-
docstring=prop.verbose_name,
756+
docstring=docstring,
749757
attr_type=prop.__class__,
750758
properties=properties,
751759
)

0 commit comments

Comments
 (0)