Skip to content

Commit fd17de5

Browse files
raph-amiardpmderodat
authored andcommitted
Minor: better handling of empty docstrings in the properties DSL
1 parent a3b5946 commit fd17de5

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

langkit/astdoc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ def trim_docstring_lines(docstring):
3131
# Remove leading newline if needed
3232
docstring = docstring.lstrip('\n')
3333

34+
if not docstring.strip():
35+
return ""
36+
3437
# Compute the offset
3538
offset = len(docstring) - len(docstring.lstrip(' '))
3639

langkit/documentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def format_c(text, column):
814814
:param int column: Indentation level for the result.
815815
:rtype str:
816816
"""
817-
if not text:
817+
if not text.strip():
818818
return ''
819819

820820
available_width = get_available_width(column)
@@ -848,7 +848,7 @@ def format_python(text, column, rtype=None):
848848
"""
849849
from langkit.compile_context import get_context
850850

851-
if text == '' and rtype is None:
851+
if text.strip() == '' and rtype is None:
852852
return ''
853853

854854
available_width = get_available_width(column)

0 commit comments

Comments
 (0)