docformatter icon indicating copy to clipboard operation
docformatter copied to clipboard

Breaks on RST XML code blocks

Open NDevox opened this issue 4 years ago • 1 comments

Hi, thanks for this tool.

I've run across what looks like a bug.

Given the docstring:

    """
    .. code-block:: XML

        <xs:element name="regulation.group" substitutionGroup="abstract.record">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="regulation.group.id" type="RegulationGroupId"/>
                    <xs:element name="validity.start.date" type="Date"/>
                    <xs:element name="validity.end.date" type="Date" minOccurs="0"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    """

Docformatter formats this to:

    """
    .. code-block:: XML.

    <xs:element name="regulation.group" substitutionGroup="abstract.record">
    <xs:complexType>         <xs:sequence>             <xs:element
    name="regulation.group.id" type="RegulationGroupId"/>
    <xs:element name="validity.start.date" type="Date"/>             <xs:element
    name="validity.end.date" type="Date" minOccurs="0"/>         </xs:sequence>
    </xs:complexType> </xs:element>
    """

Which is obviously wrong. I don't see any issues with my documentation (https://www.sphinx-doc.org/en/1.5/markup/code.html#directive-code-block). Is there a suggested fix for this? Or does it need some work.

NDevox avatar Feb 16 '21 14:02 NDevox

This is another example of docformatter not handling Sphinx directives. See also #58 and #78.

weibullguy avatar Jul 24 '22 20:07 weibullguy

@NDevox With v1.6.2 (and possibly earlier versions), docformatter doesn't touch the code block unless passed the --force-wrap argument. Since docformatter is no longer wrapping the reST code block, I'm closing this issue. Handling Sphinx directives and different docstring syntaxes is still planned for the future.

weibullguy avatar Apr 22 '23 16:04 weibullguy