Skip to content

Docstring models¤

Main API¤

Docstring ¤

Docstring(
    value: str,
    *,
    lineno: int | None = None,
    endlineno: int | None = None,
    parent: Object | None = None,
    parser: DocstringStyle | Parser | None = None,
    parser_options: DocstringOptions | None = None,
)

This class represents docstrings.

Parameters:

  • value ¤

    (str) –

    The docstring value.

  • lineno ¤

    (int | None, default: None ) –

    The starting line number.

  • endlineno ¤

    (int | None, default: None ) –

    The ending line number.

  • parent ¤

    (Object | None, default: None ) –

    The parent object on which this docstring is attached.

  • parser ¤

    (DocstringStyle | Parser | None, default: None ) –

    The docstring parser to use. By default, no parsing is done.

  • parser_options ¤

    (DocstringOptions | None, default: None ) –

    Additional docstring parsing options.

Methods:

  • as_dict

    Return this docstring's data as a dictionary.

  • parse

    Parse the docstring into structured data.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/models.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
def __init__(
    self,
    value: str,
    *,
    lineno: int | None = None,
    endlineno: int | None = None,
    parent: Object | None = None,
    parser: DocstringStyle | Parser | None = None,
    parser_options: DocstringOptions | None = None,
) -> None:
    """Initialize the docstring.

    Parameters:
        value: The docstring value.
        lineno: The starting line number.
        endlineno: The ending line number.
        parent: The parent object on which this docstring is attached.
        parser: The docstring parser to use. By default, no parsing is done.
        parser_options: Additional docstring parsing options.
    """
    self.value: str = inspect.cleandoc(value.rstrip())
    """The original value of the docstring, cleaned by `inspect.cleandoc`.

    See also: [`source`][griffe.Docstring.source].
    """

    self.lineno: int | None = lineno
    """The starting line number of the docstring.

    See also: [`endlineno`][griffe.Docstring.endlineno]."""

    self.endlineno: int | None = endlineno
    """The ending line number of the docstring.

    See also: [`lineno`][griffe.Docstring.lineno]."""

    self.parent: Object | None = parent
    """The object this docstring is attached to."""

    self.parser: DocstringStyle | Parser | None = parser
    """The selected docstring parser.

    See also: [`parser_options`][griffe.Docstring.parser_options],
    [`parse`][griffe.Docstring.parse].
    """

    self.parser_options: DocstringOptions = parser_options or {}
    """The configured parsing options.

    See also: [`parser`][griffe.Docstring.parser],
    [`parse`][griffe.Docstring.parse].
    """

endlineno instance-attribute ¤

endlineno: int | None = endlineno

The ending line number of the docstring.

See also: lineno.

lineno instance-attribute ¤

lineno: int | None = lineno

The starting line number of the docstring.

See also: endlineno.

lines property ¤

lines: list[str]

The lines of the docstring.

See also: source.

parent instance-attribute ¤

parent: Object | None = parent

The object this docstring is attached to.

parsed cached property ¤

The docstring sections, parsed into structured data.

parser instance-attribute ¤

parser: DocstringStyle | Parser | None = parser

parser_options instance-attribute ¤

parser_options: DocstringOptions = parser_options or {}

The configured parsing options.

See also: parser, parse.

source property ¤

source: str

The original, uncleaned value of the docstring as written in the source.

It is a simple concatenation of the source lines. These source lines will include quotes (single/double/triple) and might include leading whitespace and indentation, as well as trailing comments.

Raises:

  • ValueError

    If the original docstring cannot be retrieved (no parent, no line numbers, or attached to namespace package).

See also: value.

value instance-attribute ¤

value: str = inspect.cleandoc(value.rstrip())

The original value of the docstring, cleaned by inspect.cleandoc.

See also: source.

as_dict ¤

as_dict(
    *, full: bool = False, **kwargs: Any
) -> dict[str, Any]

Return this docstring's data as a dictionary.

Parameters:

  • full ¤

    (bool, default: False ) –

    Whether to return full info, or just base info.

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/models.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
def as_dict(
    self,
    *,
    full: bool = False,
    **kwargs: Any,  # noqa: ARG002
) -> dict[str, Any]:
    """Return this docstring's data as a dictionary.

    Parameters:
        full: Whether to return full info, or just base info.
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base: dict[str, Any] = {
        "value": self.value,
        "lineno": self.lineno,
        "endlineno": self.endlineno,
    }
    if full:
        base["parsed"] = self.parsed
    return base

parse ¤

parse(
    parser: DocstringStyle | Parser | None = None,
    **options: Any,
) -> list[DocstringSection]

Parse the docstring into structured data.

See also: parser, parser_options.

Parameters:

  • parser ¤

    (DocstringStyle | Parser | None, default: None ) –

    The docstring parser to use. In order: use the given parser, or the self parser, or no parser (return a single text section).

  • **options ¤

    (Any, default: {} ) –

    Additional docstring parsing options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/models.py
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
def parse(
    self,
    parser: DocstringStyle | Parser | None = None,
    **options: Any,
) -> list[DocstringSection]:
    """Parse the docstring into structured data.

    See also: [`parser`][griffe.Docstring.parser],
    [`parser_options`][griffe.Docstring.parser_options].

    Parameters:
        parser: The docstring parser to use.
            In order: use the given parser, or the self parser, or no parser (return a single text section).
        **options: Additional docstring parsing options.

    Returns:
        The parsed docstring as a list of sections.
    """
    return parse(self, parser or self.parser, **(options or self.parser_options))

Advanced API: Sections¤

DocstringSectionKind ¤

Bases: str, Enum


              flowchart TD
              griffe.DocstringSectionKind[DocstringSectionKind]

              

              click griffe.DocstringSectionKind href "" "griffe.DocstringSectionKind"
            

Enumeration of the possible docstring section kinds.

Attributes:

admonition class-attribute instance-attribute ¤

admonition = 'admonition'

attributes class-attribute instance-attribute ¤

attributes = 'attributes'

classes class-attribute instance-attribute ¤

classes = 'classes'

deprecated class-attribute instance-attribute ¤

deprecated = 'deprecated'

examples class-attribute instance-attribute ¤

examples = 'examples'

functions class-attribute instance-attribute ¤

functions = 'functions'

modules class-attribute instance-attribute ¤

modules = 'modules'

other_parameters class-attribute instance-attribute ¤

other_parameters = 'other parameters'

Other parameters (keyword arguments) section.

parameters class-attribute instance-attribute ¤

parameters = 'parameters'

raises class-attribute instance-attribute ¤

raises = 'raises'

receives class-attribute instance-attribute ¤

receives = 'receives'

Received value(s) (generators) section.

returns class-attribute instance-attribute ¤

returns = 'returns'

type_aliases class-attribute instance-attribute ¤

type_aliases = 'type aliases'

type_parameters class-attribute instance-attribute ¤

type_parameters = 'type parameters'

warns class-attribute instance-attribute ¤

warns = 'warns'

yields class-attribute instance-attribute ¤

yields = 'yields'

Yielded value(s) (generators) section.

DocstringSectionText ¤

DocstringSectionText(value: str, title: str | None = None)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionText[DocstringSectionText]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionText
                


              click griffe.DocstringSectionText href "" "griffe.DocstringSectionText"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a text section.

Parameters:

  • value ¤

    (str) –

    The section text.

  • title ¤

    (str | None, default: None ) –

    An optional title.

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
286
287
288
289
290
291
292
293
294
def __init__(self, value: str, title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section text.
        title: An optional title.
    """
    super().__init__(title)
    self.value: str = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

value: str = value

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionParameters ¤

DocstringSectionParameters(
    value: list[DocstringParameter],
    title: str | None = None,
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionParameters[DocstringSectionParameters]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionParameters
                


              click griffe.DocstringSectionParameters href "" "griffe.DocstringSectionParameters"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a parameters section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
302
303
304
305
306
307
308
309
310
def __init__(self, value: list[DocstringParameter], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section parameters.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringParameter] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionOtherParameters ¤

DocstringSectionOtherParameters(
    value: list[DocstringParameter],
    title: str | None = None,
)

Bases: DocstringSectionParameters


              flowchart TD
              griffe.DocstringSectionOtherParameters[DocstringSectionOtherParameters]
              griffe._internal.docstrings.models.DocstringSectionParameters[DocstringSectionParameters]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSectionParameters --> griffe.DocstringSectionOtherParameters
                                griffe._internal.docstrings.models.DocstringSection --> griffe._internal.docstrings.models.DocstringSectionParameters
                



              click griffe.DocstringSectionOtherParameters href "" "griffe.DocstringSectionOtherParameters"
              click griffe._internal.docstrings.models.DocstringSectionParameters href "" "griffe._internal.docstrings.models.DocstringSectionParameters"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents an other parameters section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
302
303
304
305
306
307
308
309
310
def __init__(self, value: list[DocstringParameter], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section parameters.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringParameter] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionTypeParameters ¤

DocstringSectionTypeParameters(
    value: list[DocstringTypeParameter],
    title: str | None = None,
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionTypeParameters[DocstringSectionTypeParameters]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionTypeParameters
                


              click griffe.DocstringSectionTypeParameters href "" "griffe.DocstringSectionTypeParameters"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a type parameters section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
324
325
326
327
328
329
330
331
332
def __init__(self, value: list[DocstringTypeParameter], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section type parameters.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringTypeParameter] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionRaises ¤

DocstringSectionRaises(
    value: list[DocstringRaise], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionRaises[DocstringSectionRaises]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionRaises
                


              click griffe.DocstringSectionRaises href "" "griffe.DocstringSectionRaises"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a raises section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
340
341
342
343
344
345
346
347
348
def __init__(self, value: list[DocstringRaise], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section exceptions.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringRaise] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionWarns ¤

DocstringSectionWarns(
    value: list[DocstringWarn], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionWarns[DocstringSectionWarns]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionWarns
                


              click griffe.DocstringSectionWarns href "" "griffe.DocstringSectionWarns"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a warns section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
356
357
358
359
360
361
362
363
364
def __init__(self, value: list[DocstringWarn], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section warnings.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringWarn] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionReturns ¤

DocstringSectionReturns(
    value: list[DocstringReturn], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionReturns[DocstringSectionReturns]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionReturns
                


              click griffe.DocstringSectionReturns href "" "griffe.DocstringSectionReturns"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a returns section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
372
373
374
375
376
377
378
379
380
def __init__(self, value: list[DocstringReturn], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section returned items.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringReturn] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionYields ¤

DocstringSectionYields(
    value: list[DocstringYield], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionYields[DocstringSectionYields]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionYields
                


              click griffe.DocstringSectionYields href "" "griffe.DocstringSectionYields"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a yields section.

Parameters:

  • value ¤

    (list[DocstringYield]) –

    The section yielded items.

  • title ¤

    (str | None, default: None ) –

    An optional title.

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
388
389
390
391
392
393
394
395
396
def __init__(self, value: list[DocstringYield], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section yielded items.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringYield] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionReceives ¤

DocstringSectionReceives(
    value: list[DocstringReceive], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionReceives[DocstringSectionReceives]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionReceives
                


              click griffe.DocstringSectionReceives href "" "griffe.DocstringSectionReceives"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a receives section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
404
405
406
407
408
409
410
411
412
def __init__(self, value: list[DocstringReceive], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section received items.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringReceive] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionExamples ¤

DocstringSectionExamples(
    value: list[tuple[Literal[text, examples], str]],
    title: str | None = None,
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionExamples[DocstringSectionExamples]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionExamples
                


              click griffe.DocstringSectionExamples href "" "griffe.DocstringSectionExamples"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents an examples section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
420
421
422
423
424
425
426
427
428
429
430
431
432
def __init__(
    self,
    value: list[tuple[Literal[DocstringSectionKind.text, DocstringSectionKind.examples], str]],
    title: str | None = None,
) -> None:
    """Initialize the section.

    Parameters:
        value: The section examples.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[tuple[Literal[DocstringSectionKind.text, DocstringSectionKind.examples], str]] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionAttributes ¤

DocstringSectionAttributes(
    value: list[DocstringAttribute],
    title: str | None = None,
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionAttributes[DocstringSectionAttributes]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionAttributes
                


              click griffe.DocstringSectionAttributes href "" "griffe.DocstringSectionAttributes"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents an attributes section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
440
441
442
443
444
445
446
447
448
def __init__(self, value: list[DocstringAttribute], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section attributes.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringAttribute] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionFunctions ¤

DocstringSectionFunctions(
    value: list[DocstringFunction], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionFunctions[DocstringSectionFunctions]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionFunctions
                


              click griffe.DocstringSectionFunctions href "" "griffe.DocstringSectionFunctions"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a functions/methods section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
456
457
458
459
460
461
462
463
464
def __init__(self, value: list[DocstringFunction], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section functions.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringFunction] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionClasses ¤

DocstringSectionClasses(
    value: list[DocstringClass], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionClasses[DocstringSectionClasses]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionClasses
                


              click griffe.DocstringSectionClasses href "" "griffe.DocstringSectionClasses"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a classes section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
472
473
474
475
476
477
478
479
480
def __init__(self, value: list[DocstringClass], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section classes.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringClass] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionTypeAliases ¤

DocstringSectionTypeAliases(
    value: list[DocstringTypeAlias],
    title: str | None = None,
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionTypeAliases[DocstringSectionTypeAliases]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionTypeAliases
                


              click griffe.DocstringSectionTypeAliases href "" "griffe.DocstringSectionTypeAliases"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a type aliases section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
488
489
490
491
492
493
494
495
496
def __init__(self, value: list[DocstringTypeAlias], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section classes.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringTypeAlias] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionModules ¤

DocstringSectionModules(
    value: list[DocstringModule], title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionModules[DocstringSectionModules]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionModules
                


              click griffe.DocstringSectionModules href "" "griffe.DocstringSectionModules"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a modules section.

Parameters:

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
504
505
506
507
508
509
510
511
512
def __init__(self, value: list[DocstringModule], title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        value: The section modules.
        title: An optional title.
    """
    super().__init__(title)
    self.value: list[DocstringModule] = value

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionDeprecated ¤

DocstringSectionDeprecated(
    version: str, text: str, title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionDeprecated[DocstringSectionDeprecated]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionDeprecated
                


              click griffe.DocstringSectionDeprecated href "" "griffe.DocstringSectionDeprecated"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents a deprecated section.

Parameters:

  • version ¤

    (str) –

    The deprecation version.

  • text ¤

    (str) –

    The deprecation text.

  • title ¤

    (str | None, default: None ) –

    An optional title.

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
520
521
522
523
524
525
526
527
528
529
def __init__(self, version: str, text: str, title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        version: The deprecation version.
        text: The deprecation text.
        title: An optional title.
    """
    super().__init__(title)
    self.value: DocstringDeprecated = DocstringDeprecated(annotation=version, description=text)

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

DocstringSectionAdmonition ¤

DocstringSectionAdmonition(
    kind: str, text: str, title: str | None = None
)

Bases: DocstringSection


              flowchart TD
              griffe.DocstringSectionAdmonition[DocstringSectionAdmonition]
              griffe._internal.docstrings.models.DocstringSection[DocstringSection]

                              griffe._internal.docstrings.models.DocstringSection --> griffe.DocstringSectionAdmonition
                


              click griffe.DocstringSectionAdmonition href "" "griffe.DocstringSectionAdmonition"
              click griffe._internal.docstrings.models.DocstringSection href "" "griffe._internal.docstrings.models.DocstringSection"
            

This class represents an admonition section.

Parameters:

  • kind ¤

    (str) –

    The admonition kind.

  • text ¤

    (str) –

    The admonition text.

  • title ¤

    (str | None, default: None ) –

    An optional title.

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
537
538
539
540
541
542
543
544
545
546
def __init__(self, kind: str, text: str, title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        kind: The admonition kind.
        text: The admonition text.
        title: An optional title.
    """
    super().__init__(title)
    self.value: DocstringAdmonition = DocstringAdmonition(annotation=kind, description=text)

kind class-attribute instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base

Advanced API: Section items¤

DocstringAdmonition ¤

DocstringAdmonition(
    *,
    description: str,
    annotation: str | Expr | None = None,
)

Bases: DocstringElement


              flowchart TD
              griffe.DocstringAdmonition[DocstringAdmonition]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringElement --> griffe.DocstringAdmonition
                


              click griffe.DocstringAdmonition href "" "griffe.DocstringAdmonition"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents an admonition.

Parameters:

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • description ¤

    (str) –

    The element description.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
37
38
39
40
41
42
43
44
45
46
47
def __init__(self, *, description: str, annotation: str | Expr | None = None) -> None:
    """Initialize the element.

    Parameters:
        annotation: The element annotation, if any.
        description: The element description.
    """
    self.description: str = description
    """The element description."""
    self.annotation: str | Expr | None = annotation
    """The element annotation."""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

contents property writable ¤

contents: str

The contents of this admonition.

description instance-attribute ¤

description: str = description

The element description.

kind property writable ¤

kind: str | Expr | None

The kind of this admonition.

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def as_dict(self, **kwargs: Any) -> dict[str, Any]:  # noqa: ARG002
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    return {
        "annotation": self.annotation,
        "description": self.description,
    }

DocstringDeprecated ¤

DocstringDeprecated(
    *,
    description: str,
    annotation: str | Expr | None = None,
)

Bases: DocstringElement


              flowchart TD
              griffe.DocstringDeprecated[DocstringDeprecated]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringElement --> griffe.DocstringDeprecated
                


              click griffe.DocstringDeprecated href "" "griffe.DocstringDeprecated"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented deprecated item.

Parameters:

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • description ¤

    (str) –

    The element description.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
37
38
39
40
41
42
43
44
45
46
47
def __init__(self, *, description: str, annotation: str | Expr | None = None) -> None:
    """Initialize the element.

    Parameters:
        annotation: The element annotation, if any.
        description: The element description.
    """
    self.description: str = description
    """The element description."""
    self.annotation: str | Expr | None = annotation
    """The element annotation."""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

version property writable ¤

version: str

The version of this deprecation.

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def as_dict(self, **kwargs: Any) -> dict[str, Any]:  # noqa: ARG002
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    return {
        "annotation": self.annotation,
        "description": self.description,
    }

DocstringRaise ¤

DocstringRaise(
    *,
    description: str,
    annotation: str | Expr | None = None,
)

Bases: DocstringElement


              flowchart TD
              griffe.DocstringRaise[DocstringRaise]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringElement --> griffe.DocstringRaise
                


              click griffe.DocstringRaise href "" "griffe.DocstringRaise"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented raise value.

Parameters:

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • description ¤

    (str) –

    The element description.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
37
38
39
40
41
42
43
44
45
46
47
def __init__(self, *, description: str, annotation: str | Expr | None = None) -> None:
    """Initialize the element.

    Parameters:
        annotation: The element annotation, if any.
        description: The element description.
    """
    self.description: str = description
    """The element description."""
    self.annotation: str | Expr | None = annotation
    """The element annotation."""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def as_dict(self, **kwargs: Any) -> dict[str, Any]:  # noqa: ARG002
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    return {
        "annotation": self.annotation,
        "description": self.description,
    }

DocstringWarn ¤

DocstringWarn(
    *,
    description: str,
    annotation: str | Expr | None = None,
)

Bases: DocstringElement


              flowchart TD
              griffe.DocstringWarn[DocstringWarn]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringElement --> griffe.DocstringWarn
                


              click griffe.DocstringWarn href "" "griffe.DocstringWarn"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented warn value.

Parameters:

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • description ¤

    (str) –

    The element description.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
37
38
39
40
41
42
43
44
45
46
47
def __init__(self, *, description: str, annotation: str | Expr | None = None) -> None:
    """Initialize the element.

    Parameters:
        annotation: The element annotation, if any.
        description: The element description.
    """
    self.description: str = description
    """The element description."""
    self.annotation: str | Expr | None = annotation
    """The element annotation."""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def as_dict(self, **kwargs: Any) -> dict[str, Any]:  # noqa: ARG002
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    return {
        "annotation": self.annotation,
        "description": self.description,
    }

DocstringReturn ¤

DocstringReturn(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringReturn[DocstringReturn]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringReturn
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringReturn href "" "griffe.DocstringReturn"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented return value.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringYield ¤

DocstringYield(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringYield[DocstringYield]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringYield
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringYield href "" "griffe.DocstringYield"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented yield value.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringReceive ¤

DocstringReceive(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringReceive[DocstringReceive]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringReceive
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringReceive href "" "griffe.DocstringReceive"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented receive value.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringParameter ¤

DocstringParameter(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringParameter[DocstringParameter]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringParameter
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringParameter href "" "griffe.DocstringParameter"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represent a documented function parameter.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

default property writable ¤

default: str | Expr | None

The default value of this parameter.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringTypeParameter ¤

DocstringTypeParameter(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringTypeParameter[DocstringTypeParameter]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringTypeParameter
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringTypeParameter href "" "griffe.DocstringTypeParameter"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represent a documented type parameter.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

bound property writable ¤

bound: str | Expr | None

The bound of this type parameter.

constraints property writable ¤

constraints: tuple[str | Expr, ...] | None

The constraints of this type parameter.

default property writable ¤

default: str | Expr | None

The default value of this type parameter.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringAttribute ¤

DocstringAttribute(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringAttribute[DocstringAttribute]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringAttribute
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringAttribute href "" "griffe.DocstringAttribute"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented module/class attribute.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringFunction ¤

DocstringFunction(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringFunction[DocstringFunction]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringFunction
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringFunction href "" "griffe.DocstringFunction"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented function.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

signature property ¤

signature: str | Expr | None

The function signature.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringClass ¤

DocstringClass(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringClass[DocstringClass]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringClass
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringClass href "" "griffe.DocstringClass"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented class.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

signature property ¤

signature: str | Expr | None

The class signature.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringTypeAlias ¤

DocstringTypeAlias(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringTypeAlias[DocstringTypeAlias]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringTypeAlias
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringTypeAlias href "" "griffe.DocstringTypeAlias"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented type alias.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringModule ¤

DocstringModule(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringNamedElement


              flowchart TD
              griffe.DocstringModule[DocstringModule]
              griffe._internal.docstrings.models.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringNamedElement --> griffe.DocstringModule
                                griffe._internal.docstrings.models.DocstringElement --> griffe._internal.docstrings.models.DocstringNamedElement
                



              click griffe.DocstringModule href "" "griffe.DocstringModule"
              click griffe._internal.docstrings.models.DocstringNamedElement href "" "griffe._internal.docstrings.models.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This class represents a documented module.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

Models base classes¤

DocstringElement ¤

DocstringElement(
    *,
    description: str,
    annotation: str | Expr | None = None,
)

This base class represents annotated, nameless elements.

Parameters:

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • description ¤

    (str) –

    The element description.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
37
38
39
40
41
42
43
44
45
46
47
def __init__(self, *, description: str, annotation: str | Expr | None = None) -> None:
    """Initialize the element.

    Parameters:
        annotation: The element annotation, if any.
        description: The element description.
    """
    self.description: str = description
    """The element description."""
    self.annotation: str | Expr | None = annotation
    """The element annotation."""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def as_dict(self, **kwargs: Any) -> dict[str, Any]:  # noqa: ARG002
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    return {
        "annotation": self.annotation,
        "description": self.description,
    }

DocstringNamedElement ¤

DocstringNamedElement(
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
)

Bases: DocstringElement


              flowchart TD
              griffe.DocstringNamedElement[DocstringNamedElement]
              griffe._internal.docstrings.models.DocstringElement[DocstringElement]

                              griffe._internal.docstrings.models.DocstringElement --> griffe.DocstringNamedElement
                


              click griffe.DocstringNamedElement href "" "griffe.DocstringNamedElement"
              click griffe._internal.docstrings.models.DocstringElement href "" "griffe._internal.docstrings.models.DocstringElement"
            

This base class represents annotated, named elements.

Parameters:

  • name ¤

    (str) –

    The element name.

  • description ¤

    (str) –

    The element description.

  • annotation ¤

    (str | Expr | None, default: None ) –

    The element annotation, if any.

  • value ¤

    (str | Expr | None, default: None ) –

    The element value, as a string.

Methods:

  • as_dict

    Return this element's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def __init__(
    self,
    name: str,
    *,
    description: str,
    annotation: str | Expr | None = None,
    value: str | Expr | None = None,
) -> None:
    """Initialize the element.

    Parameters:
        name: The element name.
        description: The element description.
        annotation: The element annotation, if any.
        value: The element value, as a string.
    """
    super().__init__(description=description, annotation=annotation)
    self.name: str = name
    """The element name."""
    self.value: str | Expr | None = value
    """The element value, if any"""

annotation instance-attribute ¤

annotation: str | Expr | None = annotation

The element annotation.

description instance-attribute ¤

description: str = description

The element description.

name instance-attribute ¤

name: str = name

The element name.

value instance-attribute ¤

value: str | Expr | None = value

The element value, if any

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this element's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this element's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    base = {"name": self.name, **super().as_dict(**kwargs)}
    if self.value is not None:
        base["value"] = self.value
    return base

DocstringSection ¤

DocstringSection(title: str | None = None)

This class represents a docstring section.

Parameters:

  • title ¤

    (str | None, default: None ) –

    An optional title.

Methods:

  • __bool__

    Whether this section has a true-ish value.

  • as_dict

    Return this section's data as a dictionary.

Attributes:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
247
248
249
250
251
252
253
254
255
256
def __init__(self, title: str | None = None) -> None:
    """Initialize the section.

    Parameters:
        title: An optional title.
    """
    self.title: str | None = title
    """The section title."""
    self.value: Any = None
    """The section value."""

kind instance-attribute ¤

The section kind.

title instance-attribute ¤

title: str | None = title

The section title.

value instance-attribute ¤

value: Any = None

The section value.

__bool__ ¤

__bool__() -> bool

Whether this section has a true-ish value.

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
258
259
260
def __bool__(self) -> bool:
    """Whether this section has a true-ish value."""
    return bool(self.value)

as_dict ¤

as_dict(**kwargs: Any) -> dict[str, Any]

Return this section's data as a dictionary.

Parameters:

  • **kwargs ¤

    (Any, default: {} ) –

    Additional serialization options.

Returns:

Source code in packages/griffelib/src/griffe/_internal/docstrings/models.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def as_dict(self, **kwargs: Any) -> dict[str, Any]:
    """Return this section's data as a dictionary.

    Parameters:
        **kwargs: Additional serialization options.

    Returns:
        A dictionary.
    """
    if hasattr(self.value, "as_dict"):  # noqa: SIM108
        serialized_value = self.value.as_dict(**kwargs)
    else:
        serialized_value = self.value
    base = {"kind": self.kind.value, "value": serialized_value}
    if self.title:
        base["title"] = self.title
    return base