Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support nested parameters lists #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docstring_to_markdown/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ def flush_buffer():

# lists handling: items detection
# this one does NOT allow spaces on the left hand side (to avoid false positive matches)
match = re.match(r'^(?P<argument>[^:\s]+) : (?P<type>.+)$', trimmed_line)
match = re.match(r'^(?P<indent>\s*)(?P<argument>[^:\s]+) : (?P<type>.+)$', line)
if match:
line = '- `' + match.group('argument') + '`: ' + match.group('type') + ''
line = match.group('indent') + '- `' + match.group('argument') + '`: ' + match.group('type') + ''
else:
if most_recent_section in SECTION_DIRECTIVES:
for section_directive in SECTION_DIRECTIVES[most_recent_section]:
Expand Down
44 changes: 44 additions & 0 deletions tests/test_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,46 @@ def func(): pass
will be represented by a ``cv_results_`` dict
"""


NESTED_PARAMETERS = """
Parameters
----------
transformers : list of tuples
List of (name, transformer, columns) tuples.
name : str
Like in Pipeline and FeatureUnion, this allows the transformer and
search.
transformer : {'drop', 'passthrough'} or estimator
Estimator must support :term:`fit` and :term:`transform`.
columns : str, array-like of str, int, array-like of int, \
array-like of bool, slice or callable
Indexes the data on its second axis. Integers are interpreted as
above. To select multiple columns by name or dtype, you can use
:obj:`make_column_selector`.
remainder : {'drop', 'passthrough'} or estimator, default='drop'
By default, only the specified columns in `transformers` are
"""

NESTED_PARAMETERS_MARKDOWN = """
#### Parameters

- `transformers`: list of tuples
List of (name, transformer, columns) tuples.
- `name`: str
Like in Pipeline and FeatureUnion, this allows the transformer and
search.
- `transformer`: {'drop', 'passthrough'} or estimator
Estimator must support `fit` and `transform`.
- `columns`: str, array-like of str, int, array-like of int, \
array-like of bool, slice or callable
Indexes the data on its second axis. Integers are interpreted as
above. To select multiple columns by name or dtype, you can use
`make_column_selector`.
- `remainder`: {'drop', 'passthrough'} or estimator, default='drop'
By default, only the specified columns in `transformers` are
"""


INTEGRATION = """
Return a fixed frequency DatetimeIndex.

Expand Down Expand Up @@ -702,6 +742,10 @@ def func(): pass
'converts indented grid table': {
'rst': GRID_TABLE_IN_SKLEARN,
'md': GRID_TABLE_IN_SKLEARN_MARKDOWN
},
'converts nested parameter lists': {
'rst': NESTED_PARAMETERS,
'md': NESTED_PARAMETERS_MARKDOWN
}
}

Expand Down