Skip to content

Simple docstrings are not recognized as valid RST #29

Closed
@hoefling

Description

@hoefling

A simple example to reproduce:

>>> text = """
... Spam.
...
... :param eggs: bacon.
... "
>>> import docstring_to_markdown
>>> docstring_to_markdown.looks_like_rst(text)
False

The reason is that the regex search in docstring_to_markdown.looks_like_rst() does not use the eventual flags from the directive. In the above example, the responsible directive has the multiline flag set:

Directive(
pattern=r'^\s*:({}) (?P<param>\S+):'.format('|'.join(SPHINX_PARAM)),
replacement=r'- `\g<param>`:',
flags=re.MULTILINE
),

but the function never uses it:
for directive in RST_DIRECTIVES:
if re.search(directive.pattern, value):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions