Skip to content

Commit 3ef5bb3

Browse files
committed
more parsing, possible problem - string might be unindeted
1 parent 6f398d3 commit 3ef5bb3

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

python/pydocstring.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,33 @@ def _whole_string(self):
9090

9191

9292
# NEW VERSION
93+
lines = []
9394
lines_it = self.env.lines_following_cursor()
9495
first_line = next(lines_it)
9596
lines.append(first_line)
9697

9798
func_indent = re.findall('^(\s*)', first_line)[0]
9899
expected_indent = ''.join([func_indent, env.python_indent])
100+
valid_sig = False
101+
sig_line = 0
99102

100103
while True:
101104
try:
102105
last_row, line = next(lines_it)
103106
except StopIteration as e:
104107
break
105-
# TODO save row_nr of the func (or class) signature
106-
if not self._is_correct_indent(line, expected_indent):
108+
109+
if valid_sig and not self._is_correct_indent(line, expected_indent):
107110
break
108-
111+
109112
lines.append(line)
113+
if not valid_sig:
114+
data = ''.join(lines)
115+
valid_sig, _ = self._is_valid(data)
116+
sig_line = last_row
110117
# TODO finish
111-
118+
data = ''.join(lines)
119+
tree = ast.parse(tree)
112120

113121
def _is_correct_indent(self, line, indent):
114122
""" Check whether given line has either given indentation (or more)

0 commit comments

Comments
 (0)