Skip to content

Commit 194c01c

Browse files
authored
Merge pull request #12 from krassowski/nested-lists
Support nested parameters lists
2 parents ab6c77d + 683f937 commit 194c01c

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

docstring_to_markdown/rst.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ def flush_buffer():
598598

599599
# lists handling: items detection
600600
# this one does NOT allow spaces on the left hand side (to avoid false positive matches)
601-
match = re.match(r'^(?P<argument>[^:\s]+) : (?P<type>.+)$', trimmed_line)
601+
match = re.match(r'^(?P<indent>\s*)(?P<argument>[^:\s]+) : (?P<type>.+)$', line)
602602
if match:
603-
line = '- `' + match.group('argument') + '`: ' + match.group('type') + ''
603+
line = match.group('indent') + '- `' + match.group('argument') + '`: ' + match.group('type') + ''
604604
else:
605605
if most_recent_section in SECTION_DIRECTIVES:
606606
for section_directive in SECTION_DIRECTIVES[most_recent_section]:

tests/test_rst.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,46 @@ def func(): pass
568568
will be represented by a ``cv_results_`` dict
569569
"""
570570

571+
572+
NESTED_PARAMETERS = """
573+
Parameters
574+
----------
575+
transformers : list of tuples
576+
List of (name, transformer, columns) tuples.
577+
name : str
578+
Like in Pipeline and FeatureUnion, this allows the transformer and
579+
search.
580+
transformer : {'drop', 'passthrough'} or estimator
581+
Estimator must support :term:`fit` and :term:`transform`.
582+
columns : str, array-like of str, int, array-like of int, \
583+
array-like of bool, slice or callable
584+
Indexes the data on its second axis. Integers are interpreted as
585+
above. To select multiple columns by name or dtype, you can use
586+
:obj:`make_column_selector`.
587+
remainder : {'drop', 'passthrough'} or estimator, default='drop'
588+
By default, only the specified columns in `transformers` are
589+
"""
590+
591+
NESTED_PARAMETERS_MARKDOWN = """
592+
#### Parameters
593+
594+
- `transformers`: list of tuples
595+
List of (name, transformer, columns) tuples.
596+
- `name`: str
597+
Like in Pipeline and FeatureUnion, this allows the transformer and
598+
search.
599+
- `transformer`: {'drop', 'passthrough'} or estimator
600+
Estimator must support `fit` and `transform`.
601+
- `columns`: str, array-like of str, int, array-like of int, \
602+
array-like of bool, slice or callable
603+
Indexes the data on its second axis. Integers are interpreted as
604+
above. To select multiple columns by name or dtype, you can use
605+
`make_column_selector`.
606+
- `remainder`: {'drop', 'passthrough'} or estimator, default='drop'
607+
By default, only the specified columns in `transformers` are
608+
"""
609+
610+
571611
INTEGRATION = """
572612
Return a fixed frequency DatetimeIndex.
573613
@@ -702,6 +742,10 @@ def func(): pass
702742
'converts indented grid table': {
703743
'rst': GRID_TABLE_IN_SKLEARN,
704744
'md': GRID_TABLE_IN_SKLEARN_MARKDOWN
745+
},
746+
'converts nested parameter lists': {
747+
'rst': NESTED_PARAMETERS,
748+
'md': NESTED_PARAMETERS_MARKDOWN
705749
}
706750
}
707751

0 commit comments

Comments
 (0)