Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
P
polarion_docstrings
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
3
Snippets
Groups
Projects
Show more breadcrumbs
Martin Kourim
polarion_docstrings
Commits
16b6a10f
Verified
Commit
16b6a10f
authored
5 years ago
by
Martin Kourim
Browse files
Options
Downloads
Patches
Plain Diff
fix: Fix parsing with leading blank line
parent
f1b3805e
No related branches found
No related tags found
No related merge requests found
Pipeline
#90999863
passed
5 years ago
Stage: deploy
Changes
3
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
polarion_docstrings/parser.py
+11
-3
11 additions, 3 deletions
polarion_docstrings/parser.py
tests/data/docstrings_func.py
+2
-0
2 additions, 0 deletions
tests/data/docstrings_func.py
tests/test_parser.py
+7
-7
7 additions, 7 deletions
tests/test_parser.py
with
20 additions
and
10 deletions
polarion_docstrings/parser.py
+
11
−
3
View file @
16b6a10f
...
...
@@ -77,7 +77,7 @@ class DocstringParser:
return
key
,
value
# pylint: disable=too-many-locals
def
lines_to_dict
(
self
,
lines
,
start
=
0
,
lineno_offset
=
0
,
stop
=
None
):
def
lines_to_dict
(
self
,
lines
,
start
=
0
,
lineno_offset
=
0
,
stop
=
None
):
# noqa: C901
"""
Create dictionary out of docstring lines.
Includes column and line number info for each record.
...
...
@@ -88,7 +88,7 @@ class DocstringParser:
lines
=
lines
[
start
:]
docstring_dict
=
{}
indent
=
len
(
lines
[
0
])
-
len
(
lines
[
0
].
lstrip
(
"
"
))
indent
=
0
is_multiline
=
False
prev_key
=
None
for
num
,
line
in
enumerate
(
lines
,
1
):
...
...
@@ -98,6 +98,9 @@ class DocstringParser:
curr_indent
=
len
(
line
)
-
len
(
line
.
lstrip
(
"
"
))
if
not
indent
:
indent
=
curr_indent
if
curr_indent
<
indent
:
break
...
...
@@ -160,12 +163,17 @@ class DocstringParser:
lines_list
=
[]
is_multiline
=
False
indent
=
len
(
lines
[
0
])
-
len
(
lines
[
0
].
lstrip
(
"
"
))
indent
=
0
for
num
,
line
in
enumerate
(
lines
,
1
):
line_stripped
=
line
.
strip
()
if
not
line_stripped
:
continue
curr_indent
=
len
(
line
)
-
len
(
line
.
lstrip
(
"
"
))
if
not
indent
:
indent
=
curr_indent
if
curr_indent
<
indent
:
break
...
...
This diff is collapsed.
Click to expand it.
tests/data/docstrings_func.py
+
2
−
0
View file @
16b6a10f
...
...
@@ -105,6 +105,7 @@ def test_wrong_steps_indent():
def
test_multiline
():
"""
BAR
Polarion:
assignee: mkourim
initialEstimate: 1/4h
title: >
...
...
@@ -115,6 +116,7 @@ def test_multiline():
2. >
Log something
expectedResults:
1.
2. >
<NoMethodError>: <undefined method `service_resources
"
for
...
...
This diff is collapsed.
Click to expand it.
tests/test_parser.py
+
7
−
7
View file @
16b6a10f
...
...
@@ -144,19 +144,19 @@ EXPECTED = {
lineno
=
107
,
column
=
4
,
value
=
{
"
assignee
"
:
ValueRecord
(
lineno
=
1
,
column
=
8
,
value
=
"
mkourim
"
),
"
initialEstimate
"
:
ValueRecord
(
lineno
=
2
,
column
=
8
,
value
=
"
1/4h
"
),
"
assignee
"
:
ValueRecord
(
lineno
=
2
,
column
=
8
,
value
=
"
mkourim
"
),
"
initialEstimate
"
:
ValueRecord
(
lineno
=
3
,
column
=
8
,
value
=
"
1/4h
"
),
"
title
"
:
ValueRecord
(
lineno
=
3
,
column
=
8
,
value
=
"
Test multiple tenant quotas simultaneously
"
lineno
=
4
,
column
=
8
,
value
=
"
Test multiple tenant quotas simultaneously
"
),
"
testSteps
"
:
[
ValueRecord
(
lineno
=
7
,
column
=
12
,
value
=
"
1.
"
),
ValueRecord
(
lineno
=
8
,
column
=
12
,
value
=
"
2. Log something
"
),
ValueRecord
(
lineno
=
8
,
column
=
12
,
value
=
"
1.
"
),
ValueRecord
(
lineno
=
9
,
column
=
12
,
value
=
"
2. Log something
"
),
],
"
expectedResults
"
:
[
ValueRecord
(
lineno
=
1
1
,
column
=
12
,
value
=
"
1.
"
),
ValueRecord
(
lineno
=
1
3
,
column
=
12
,
value
=
"
1.
"
),
ValueRecord
(
lineno
=
1
2
,
lineno
=
1
4
,
column
=
12
,
value
=
'
2. <NoMethodError>: <undefined method `service_resources
"
for
'
"
nil:NilClass> [----] E, [2018-01-06T11:11:20.074019 #13027:e0ffc4]
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment