Skip to content

# Docstring styles

xsdata follows PEP 257 docstring conventions and offers the ability to switch between the most popular styles or disable them completely.

reStructuredText NumPy Google Accessible Blank

    class RootEnum(Enum):
        """
        :cvar A: Lorem ipsum dolor
        :cvar B: Lorem ipsum dolor '''sit''' amet, consectetur adipiscing
            elit. Morbi dapibus. My\\Ipsum
        """

        A = "A"
        B = "B"

    class RootB(Enum):
        """
        :cvar YES: This is an inner enum member documentation. Lorem ipsum
            dolor sit amet, consectetur adipiscing elit. Etiam mollis.
        :cvar NO: Lorem ipsum dolor My\\Ipsum
        """

        YES = "Yes"
        NO = "No"

    class RootD(Enum):
        TRUE = "true"
        FALSE = "false"

    @dataclass(kw_only=True)
    class Root:
        """
        This is the root type documentation. '''Lorem ipsum''' dolor sit amet,
        consectetur adipiscing elit.

        Morbi dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Donec imperdiet lacus sed sagittis scelerisque. Ut sodales metus:
        "sit", "amet", "lectus" My\\Ipsum.

        :ivar a: This is an inner type '''field''' documentation. Lorem
            ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nec.
            My\\Ipsum
        :ivar b: This is a second root type field documentation.
        :ivar c:
        :ivar d:
        """

        class Meta:
            namespace = "urn:docs"

        a: Root.A = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        b: RootB = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        c: RootEnum = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        d: RootD = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )

        @dataclass(kw_only=True)
        class A:
            """
            This is an inner type documentation.

            :ivar sub_a: This is an inner type '''field''' documentation.
                Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                Vivamus efficitur. My\\Ipsum
            """

            sub_a: str = field(
                metadata={
                    "type": "Element",
                    "namespace": "",
                }
            )

    class RootEnum(Enum):
        """
        Properties
        ----------
        A
            Lorem ipsum dolor
        B
            Lorem ipsum dolor '''sit''' amet, consectetur adipiscing elit. Morbi
            dapibus. My\\Ipsum
        """

        A = "A"
        B = "B"

    class RootB(Enum):
        """
        Properties
        ----------
        YES
            This is an inner enum member documentation. Lorem ipsum dolor sit
            amet, consectetur adipiscing elit. Etiam mollis.
        NO
            Lorem ipsum dolor My\\Ipsum
        """

        YES = "Yes"
        NO = "No"

    class RootD(Enum):
        TRUE = "true"
        FALSE = "false"

    @dataclass(kw_only=True)
    class Root:
        """
        This is the root type documentation. '''Lorem ipsum''' dolor sit amet,
        consectetur adipiscing elit.

        Morbi dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Donec imperdiet lacus sed sagittis scelerisque. Ut sodales metus:
        "sit", "amet", "lectus" My\\Ipsum.

        Parameters
        ----------
        a
            This is an inner type '''field''' documentation. Lorem ipsum dolor
            sit amet, consectetur adipiscing elit. Aliquam nec. My\\Ipsum
        b
            This is a second root type field documentation.
        c
        d
        """

        class Meta:
            namespace = "urn:docs"

        a: Root.A = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        b: RootB = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        c: RootEnum = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        d: RootD = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )

        @dataclass(kw_only=True)
        class A:
            """
            This is an inner type documentation.

            Parameters
            ----------
            sub_a
                This is an inner type '''field''' documentation. Lorem ipsum
                dolor sit amet, consectetur adipiscing elit. Vivamus efficitur.
                My\\Ipsum
            """

            sub_a: str = field(
                metadata={
                    "type": "Element",
                    "namespace": "",
                }
            )

    class RootEnum(Enum):
        """
        Attributes:
            A: Lorem ipsum dolor
            B: Lorem ipsum dolor '''sit''' amet, consectetur adipiscing
                elit. Morbi dapibus. My\\Ipsum
        """

        A = "A"
        B = "B"

    class RootB(Enum):
        """
        Attributes:
            YES: This is an inner enum member documentation. Lorem ipsum
                dolor sit amet, consectetur adipiscing elit. Etiam mollis.
            NO: Lorem ipsum dolor My\\Ipsum
        """

        YES = "Yes"
        NO = "No"

    class RootD(Enum):
        TRUE = "true"
        FALSE = "false"

    @dataclass(kw_only=True)
    class Root:
        """
        This is the root type documentation. '''Lorem ipsum''' dolor sit amet,
        consectetur adipiscing elit.

        Morbi dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Donec imperdiet lacus sed sagittis scelerisque. Ut sodales metus:
        "sit", "amet", "lectus" My\\Ipsum.

        Attributes:
            a: This is an inner type '''field''' documentation. Lorem ipsum
                dolor sit amet, consectetur adipiscing elit. Aliquam nec.
                My\\Ipsum
            b: This is a second root type field documentation.
            c:
            d:
        """

        class Meta:
            namespace = "urn:docs"

        a: Root.A = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        b: RootB = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        c: RootEnum = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        d: RootD = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )

        @dataclass(kw_only=True)
        class A:
            """
            This is an inner type documentation.

            Attributes:
                sub_a: This is an inner type '''field''' documentation.
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                    Vivamus efficitur. My\\Ipsum
            """

            sub_a: str = field(
                metadata={
                    "type": "Element",
                    "namespace": "",
                }
            )

    class RootEnum(Enum):
        A = "A"
        B = "B"

    RootEnum.A.__doc__ = "Lorem ipsum dolor"
    RootEnum.B.__doc__ = (
        "Lorem ipsum dolor '''sit''' amet, consectetur adipiscing elit. Morbi "
        "dapibus. My\\Ipsum"
    )

    class RootB(Enum):
        YES = "Yes"
        NO = "No"

    RootB.YES.__doc__ = (
        "This is an inner enum member documentation. Lorem ipsum dolor sit amet, "
        "consectetur adipiscing elit. Etiam mollis."
    )
    RootB.NO.__doc__ = "Lorem ipsum dolor\nMy\\Ipsum"

    class RootD(Enum):
        TRUE = "true"
        FALSE = "false"

    @dataclass(kw_only=True)
    class Root:
        """
        This is the root type documentation. '''Lorem ipsum''' dolor sit amet,
        consectetur adipiscing elit.

        Morbi dapibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Donec imperdiet lacus sed sagittis scelerisque. Ut sodales metus:
        "sit", "amet", "lectus" My\\Ipsum.
        """

        class Meta:
            namespace = "urn:docs"

        a: Root.A = field(
            metadata={
                "type": "Element",
                "namespace": "",
                "doc": (
                    "This is an inner type '''field''' documentation.\nLorem ipsum"
                    " dolor sit amet, consectetur adipiscing elit. Aliquam "
                    "nec.\nMy\\Ipsum"
                ),
            }
        )
        b: RootB = field(
            metadata={
                "type": "Element",
                "namespace": "",
                "doc": "This is a second root type field documentation.",
            }
        )
        c: RootEnum = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        d: RootD = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )

        @dataclass(kw_only=True)
        class A:
            """
            This is an inner type documentation.
            """

            sub_a: str = field(
                metadata={
                    "type": "Element",
                    "namespace": "",
                    "doc": (
                        "This is an inner type '''field''' documentation.\nLorem ipsum"
                        " dolor sit amet, consectetur adipiscing elit. Vivamus "
                        "efficitur.\nMy\\Ipsum"
                    ),
                }
            )

    class RootEnum(Enum):
        A = "A"
        B = "B"

    class RootB(Enum):
        YES = "Yes"
        NO = "No"

    class RootD(Enum):
        TRUE = "true"
        FALSE = "false"

    @dataclass(kw_only=True)
    class Root:
        class Meta:
            namespace = "urn:docs"

        a: Root.A = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        b: RootB = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        c: RootEnum = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )
        d: RootD = field(
            metadata={
                "type": "Element",
                "namespace": "",
            }
        )

        @dataclass(kw_only=True)
        class A:
            sub_a: str = field(
                metadata={
                    "type": "Element",
                    "namespace": "",
                }
            )