API¶
Package dynadoc
¶
Docstring generation from annotations with configurable output formats.
Module dynadoc.assembly
¶
Docstring assembly and decoration.
- dynadoc.assembly.context_default: dynadoc.context.Context¶
- dynadoc.assembly.introspection_default: dynadoc.context.IntrospectionControl¶
- dynadoc.assembly.renderer_default: dynadoc.xtnsapi.Renderer¶
- dynadoc.assembly.assign_module_docstring(module, /, *fragments, context=Context(notifier=<function notify>, fragment_rectifier=<function rectify_fragment>, visibility_decider=<function is_attribute_visible>, fragments_name='_dynadoc_fragments_', introspection_limit_name='_dynadoc_introspection_limit_', invoker_globals=None, resolver_globals=None, resolver_locals=None), introspection=IntrospectionControl(enable=True, class_control=ClassIntrospectionControl(inheritance=False, introspectors=(), scan_attributes=False), module_control=ModuleIntrospectionControl(scan_attributes=False), limiters=(), targets=<IntrospectionTargets.Null: 0>), preserve=True, renderer=<function produce_fragment>, table=mappingproxy({}))¶
Assembles docstring from fragments and assigns it to module.
- Parameters:
module (str | types.ModuleType)
fragments (str | typing_extensions.Doc) –
Fragments from which to produce a docstring.
If fragment is a string, then it will be used as an index into a table of docstring fragments. If fragment is a PEP 727
Doc
object, then the value of itsdocumentation
attribute will be incorporated.context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
introspection (dynadoc.context.IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
preserve (bool) – Preserve extant docstring?
renderer (dynadoc.xtnsapi.Renderer) – Produces docstring fragment from object and information about it.
table (collections.abc.Mapping[ str, str ]) – Table from which to copy docstring fragments.
- dynadoc.assembly.with_docstring(*fragments, context=Context(notifier=<function notify>, fragment_rectifier=<function rectify_fragment>, visibility_decider=<function is_attribute_visible>, fragments_name='_dynadoc_fragments_', introspection_limit_name='_dynadoc_introspection_limit_', invoker_globals=None, resolver_globals=None, resolver_locals=None), introspection=IntrospectionControl(enable=True, class_control=ClassIntrospectionControl(inheritance=False, introspectors=(), scan_attributes=False), module_control=ModuleIntrospectionControl(scan_attributes=False), limiters=(), targets=<IntrospectionTargets.Null: 0>), preserve=True, renderer=<function produce_fragment>, table=mappingproxy({}))¶
Assembles docstring from fragments and decorates object with it.
- Parameters:
fragments (str | typing_extensions.Doc) –
Fragments from which to produce a docstring.
If fragment is a string, then it will be used as an index into a table of docstring fragments. If fragment is a PEP 727
Doc
object, then the value of itsdocumentation
attribute will be incorporated.context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
introspection (dynadoc.context.IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
preserve (bool) – Preserve extant docstring?
renderer (dynadoc.xtnsapi.Renderer) – Produces docstring fragment from object and information about it.
table (collections.abc.Mapping[ str, str ]) – Table from which to copy docstring fragments.
- Return type:
collections.abc.Callable[ [ dynadoc.nomina.D ], dynadoc.nomina.D ]
Module dynadoc.context
¶
Data transfer objects for execution context.
- type dynadoc.context.ContextArgument = dynadoc.context.Context¶
- type dynadoc.context.IntrospectionArgumentFref = IntrospectionControl¶
- type dynadoc.context.ClassIntrospectors = collections.abc.Sequence[dynadoc.context.ClassIntrospector]¶
- type dynadoc.context.IntrospectionLimiters = collections.abc.Sequence[dynadoc.context.IntrospectionLimiter]¶
- dynadoc.context.IntrospectionTargetsSansModule: dynadoc.context.IntrospectionTargets = <IntrospectionTargets.Function|Descriptor|Class: 7>¶
- dynadoc.context.IntrospectionTargetsOmni: dynadoc.context.IntrospectionTargets = <IntrospectionTargets.Module|Function|Descriptor|Class: 15>¶
- type dynadoc.context.IntrospectionArgument = dynadoc.context.IntrospectionControl¶
- class dynadoc.context.ClassIntrospectionControl(*, inheritance=False, introspectors=(), scan_attributes=False)¶
Bases:
object
Controls on class introspection behavior.
- Variables:
inheritance (bool) – Inherit annotations?
introspectors (collections.abc.Sequence[ dynadoc.context.ClassIntrospector ]) – Custom introspectors to apply.
scan_attributes (bool) – Scan attributes not covered by annotations?
- with_limit(limit)¶
Returns new control with applied limits.
- Parameters:
self
limit (dynadoc.context.ClassIntrospectionLimit) – Limits to apply to this introspection control.
- Return type:
typing_extensions.Self
- class dynadoc.context.ClassIntrospectionLimit(*, avoid_inheritance=False, ignore_attributes=False)¶
Bases:
object
Limits on class introspection behavior.
- class dynadoc.context.ClassIntrospector(*args, **kwargs)¶
Bases:
Protocol
Custom introspector for class annotations and attributes.
- static __call__(possessor, /, context, introspection, annotations, cache, table)¶
Introspects class and returns information about its members.
- Parameters:
possessor (type) – Class being documented.
context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
introspection (IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
annotations (collections.abc.Mapping[ str, typing_extensions.Any ]) – Annotations mapping for documentable object.
cache (dynadoc.interfaces.AnnotationsCache) –
Cache for storing reduced annotation forms.
Also used for cycle detection.
table (collections.abc.Mapping[ str, str ]) – Table from which to copy docstring fragments.
- Return type:
collections.abc.Sequence[ dynadoc.interfaces.InformationBase ] | None
- class dynadoc.context.Context(*, notifier: Annotated[dynadoc.interfaces.Notifier, Fname(name='notifier')], fragment_rectifier: Annotated[dynadoc.interfaces.FragmentRectifier, Fname(name='fragment rectifier')], visibility_decider: Annotated[dynadoc.interfaces.VisibilityDecider, Fname(name='visibility decider')], fragments_name: Annotated[str, Fname(name='fragments name')] = '_dynadoc_fragments_', introspection_limit_name: Annotated[str, Fname(name='introspection limit name')] = '_dynadoc_introspection_limit_', invoker_globals: Annotated[collections.abc.Mapping[str, typing_extensions.Any] | None, Fname(name='invoker globals')] = None, resolver_globals: Annotated[collections.abc.Mapping[str, typing_extensions.Any] | None, Fname(name='resolver globals')] = None, resolver_locals: Annotated[collections.abc.Mapping[str, typing_extensions.Any] | None, Fname(name='resolver locals')] = None)¶
Bases:
object
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
- Variables:
notifier (dynadoc.interfaces.Notifier) – Notifies of warnings and errors.
fragment_rectifier (dynadoc.interfaces.FragmentRectifier) – Cleans and normalizes documentation fragment.
visibility_decider (dynadoc.interfaces.VisibilityDecider) – Decides if attribute should have visible documentation.
fragments_name (str) – Name of class attribute which stores documentation fragments.
introspection_limit_name (str) – Name of class attribute which stores introspection limit.
invoker_globals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of globals from the frame of a caller.
Used by renderers for determing whether to fully-qualify a name.
resolver_globals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of globals for annotation resolution.
Used for resolving string annotations.
resolver_locals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of locals for annotation resolution.
Used for resolving string annotations.
- class dynadoc.context.IntrospectionControl(*, enable: typing.Annotated[bool, Doc(' Whether introspection is enabled at all. ')] = True, class_control: typing.Annotated[dynadoc.context.ClassIntrospectionControl, Doc(' Controls specific to class introspection. ')] = ClassIntrospectionControl(inheritance=False, introspectors=(), scan_attributes=False), module_control: typing.Annotated[dynadoc.context.ModuleIntrospectionControl, Doc(' Controls specific to module introspection. ')] = ModuleIntrospectionControl(scan_attributes=False), limiters: typing.Annotated[collections.abc.Sequence[dynadoc.context.IntrospectionLimiter], Doc(' Functions which can apply limits to introspection control. '), Doc(' Functions that can apply limits to introspection. ')] = (), targets: typing.Annotated[dynadoc.context.IntrospectionTargets, Doc(' Which types of objects to recursively document. ')] = <IntrospectionTargets.Null: 0>)¶
Bases:
object
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
- Variables:
enable (bool) – Whether introspection is enabled at all.
class_control (dynadoc.context.ClassIntrospectionControl) – Controls specific to class introspection.
module_control (dynadoc.context.ModuleIntrospectionControl) – Controls specific to module introspection.
limiters (collections.abc.Sequence[ dynadoc.context.IntrospectionLimiter ]) –
Functions which can apply limits to introspection control.
Functions that can apply limits to introspection.
targets (dynadoc.context.IntrospectionTargets) – Which types of objects to recursively document.
- evaluate_limits_for(objct)¶
Determine which introspection limits apply to object.
- Parameters:
self
objct (object) – Object to evaluate limits for.
- Return type:
- with_limit(limit)¶
Returns new control with applied limits.
- Parameters:
self
limit (dynadoc.context.IntrospectionLimit) – Limits to apply to this introspection control.
- Return type:
typing_extensions.Self
- class dynadoc.context.IntrospectionLimit(*, disable=False, class_limit=ClassIntrospectionLimit(avoid_inheritance=False, ignore_attributes=False), module_limit=ModuleIntrospectionLimit(ignore_attributes=False), targets_exclusions=<IntrospectionTargets.Null: 0>)¶
Bases:
object
Limits on introspection behavior.
- Variables:
disable (bool) – Disable introspection?
class_limit (dynadoc.context.ClassIntrospectionLimit) – Limits specific to class introspection.
module_limit (dynadoc.context.ModuleIntrospectionLimit) – Limits specific to module introspection.
targets_exclusions (dynadoc.context.IntrospectionTargets) – Target types to exclude from introspection.
- class dynadoc.context.IntrospectionLimiter(*args, **kwargs)¶
Bases:
Protocol
Can return modified introspection control for attribute.
- static __call__(objct, introspection)¶
Returns modified introspection control with limits applied.
- Parameters:
objct (object) – Object being evaluated for introspection limits.
introspection (IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
- Return type:
- class dynadoc.context.IntrospectionTargets(value)¶
Bases:
IntFlag
Kinds of objects to recursively document.
- Variables:
Descriptor (dynadoc.context.IntrospectionTargets)
Function (dynadoc.context.IntrospectionTargets)
Module (dynadoc.context.IntrospectionTargets)
- class dynadoc.context.ModuleIntrospectionControl(*, scan_attributes=False)¶
Bases:
object
Controls on module introspection behavior.
- Variables:
scan_attributes (bool) – Scan attributes not covered by annotations?
- with_limit(limit)¶
Returns new control with applied limits.
- Parameters:
self
limit (dynadoc.context.ModuleIntrospectionLimit) – Limits to apply to this introspection control.
- Return type:
typing_extensions.Self
Module dynadoc.factories
¶
Factories and registries.
- dynadoc.factories.notify(level, message)¶
Issues warning message.
- dynadoc.factories.produce_context(invoker_globals=None, resolver_globals=None, resolver_locals=None, notifier=<function notify>, fragment_rectifier=<function rectify_fragment>, visibility_decider=<function is_attribute_visible>, fragments_name='_dynadoc_fragments_', introspection_limit_name='_dynadoc_introspection_limit_')¶
Produces context data transfer object.
Reasonable defaults are used for arguments that are not supplied.
- Parameters:
invoker_globals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of globals from the frame of a caller.
Used by renderers for determing whether to fully-qualify a name.
resolver_globals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of globals for annotation resolution.
Used for resolving string annotations.
resolver_locals (collections.abc.Mapping[ str, typing_extensions.Any ] | None) –
Dictionary of locals for annotation resolution.
Used for resolving string annotations.
notifier (dynadoc.interfaces.Notifier) – Notifies of warnings and errors.
fragment_rectifier (dynadoc.interfaces.FragmentRectifier) – Cleans and normalizes documentation fragment.
visibility_decider (dynadoc.interfaces.VisibilityDecider) – Decides if attribute should have visible documentation.
fragments_name (str) – Name of class attribute which stores documentation fragments.
introspection_limit_name (str) – Name of class attribute which stores introspection limit.
- Return type:
- dynadoc.factories.rectify_fragment(fragment, source)¶
Cleans and normalizes fragment according to source.
- Parameters:
fragment (str)
source (dynadoc.interfaces.FragmentSources)
- Return type:
Module dynadoc.interfaces
¶
Rich annotations, public interfaces for cutomization functions, etc….
Note
By default, this module exports typing_extensions.Doc
, which is
based on the withdrawn PEP 727. A typing_extensions
maintainer,
who was also the sponsor of this PEP, has indicated in the PEP 727
Discourse thread
that typing_extensions
will support Doc
indefinitely. However,
if it should disappear from typing_extensions
, we provide a
compatible fallback. Unless you are using typing_extensions.Doc
for
other purposes, it is recommended that you import it from this package
instead, to ensure future availability.
- type dynadoc.interfaces.Fragment = str | typing_extensions.Doc¶
- type dynadoc.interfaces.Fragments = collections.abc.Sequence[str | typing_extensions.Doc]¶
- type dynadoc.interfaces.AnnotationsArgument = collections.abc.Mapping[str, typing_extensions.Any]¶
- type dynadoc.interfaces.FragmentsTableArgument = collections.abc.Mapping[str, str]¶
- type dynadoc.interfaces.PossessorArgument = types.ModuleType | type | collections.abc.Callable[..., typing_extensions.Any]¶
- type dynadoc.interfaces.PossessorFunctionArgument = collections.abc.Callable[..., typing_extensions.Any]¶
- type dynadoc.interfaces.PossessorModuleArgument = types.ModuleType¶
- type dynadoc.interfaces.VisibilityAnnotationArgument = typing_extensions.Any¶
- dynadoc.interfaces.absent: dynadoc.interfaces.Sentinels¶
- dynadoc.interfaces.incomplete: dynadoc.interfaces.Sentinels = <Sentinels.Incomplete: 2>¶
- type dynadoc.interfaces.Informations = collections.abc.Sequence[dynadoc.interfaces.InformationBase]¶
- type dynadoc.interfaces.AnnotationsCacheArgument = dynadoc.interfaces.AnnotationsCache¶
- type dynadoc.interfaces.InformationsArgument = collections.abc.Sequence[dynadoc.interfaces.InformationBase]¶
- class dynadoc.interfaces.AdjunctsData(*, extras=<factory>, traits=<factory>)¶
Bases:
object
Data about type-adjacent entities.
- Variables:
extras (collections.abc.MutableSequence[ typing_extensions.Any ]) – Additional annotations.
traits (collections.abc.MutableSet[ str ]) – Trait names collected during annotation processing.
- copy()¶
Creates a shallow copy of the adjuncts data.
- Parameters:
self
- Return type:
typing_extensions.Self
- class dynadoc.interfaces.AnnotationsCache(*, entries=<factory>)¶
Bases:
object
Lookup table for reduced annotations from original annotations.
Has special values for absent and incomplete entries.
- Variables:
entries (dict[ typing_extensions.Any, typing_extensions.Any ]) – Mapping from original annotations to reduced forms.
- access(original)¶
Accesses entry value, if it exists.
- Parameters:
self
original (typing_extensions.Any) – Original annotation to look up in cache.
- Returns:
Reduced annotation from cache.
Absence sentinel if not found.
- Return type:
typing_extensions.Any
- enter(original, reduction=Sentinels.Incomplete)¶
Adds reduced annotation to cache, returning it.
Cache key is original annotation. If reduction is not specified, then an incompletion sentinel is added as the value for the entry.
- Parameters:
self
original (typing_extensions.Any) – Original annotation to use as cache key.
reduction (typing_extensions.Any) – Reduced form of annotation to store as value.
- Return type:
typing_extensions.Any
- class dynadoc.interfaces.ArgumentInformation(*, annotation, description, name, paramspec, default)¶
Bases:
InformationBase
Information about a function argument.
- Variables:
annotation (typing_extensions.Any) – Type annotation associated with this entity.
description (str | None) – Human-readable description of the entity.
name (str) – Name of the function parameter.
paramspec (inspect.Parameter) – Inspection parameter object with various details.
default (dynadoc.interfaces.Default) – Configuration for how to handle default value.
- class dynadoc.interfaces.AttributeAssociations(value)¶
Bases:
Enum
Association level of an attribute with its containing entity.
- Variables:
Instance (dynadoc.interfaces.AttributeAssociations)
- class dynadoc.interfaces.AttributeInformation(*, annotation, description, name, association, default)¶
Bases:
InformationBase
Information about a class or module attribute.
- Variables:
annotation (typing_extensions.Any) – Type annotation associated with this entity.
description (str | None) – Human-readable description of the entity.
name (str) – Name of the attribute.
association (dynadoc.interfaces.AttributeAssociations) – Attribute associated with module, class, or instance?
default (dynadoc.interfaces.Default) – How to handle default value.
- class dynadoc.interfaces.Default(*, mode=ValuationModes.Accept, surrogate=Sentinels.Absent)¶
Bases:
object
How to process default value.
- Variables:
mode (dynadoc.interfaces.ValuationModes) – Method for handling default value processing.
surrogate (typing_extensions.Any) –
Alternative value to use when surrogate mode.
Usually a description string.
- class dynadoc.interfaces.ExceptionInformation(*, annotation, description)¶
Bases:
InformationBase
Information about an exception that can be raised.
- Variables:
annotation (typing_extensions.Any) – Type annotation associated with this entity.
description (str | None) – Human-readable description of the entity.
- class dynadoc.interfaces.Fname(name)¶
Bases:
object
Name of documentation fragment in table.
- Variables:
name (str) – Index to look up content in fragments table.
- class dynadoc.interfaces.FragmentRectifier(*args, **kwargs)¶
Bases:
Protocol
Cleans and normalizes documentation fragment.
- static __call__(fragment, source)¶
(Signature for fragment rectifier.)
- Parameters:
fragment (str) – Raw fragment text to be cleaned and normalized.
source (dynadoc.interfaces.FragmentSources) – Source type of fragment for context-aware processing.
- Return type:
- class dynadoc.interfaces.FragmentSources(value)¶
Bases:
Enum
Possible sources for documentation fragments.
- Variables:
Annotation (dynadoc.interfaces.FragmentSources)
Argument (dynadoc.interfaces.FragmentSources)
Attribute (dynadoc.interfaces.FragmentSources)
Docstring (dynadoc.interfaces.FragmentSources)
Renderer (dynadoc.interfaces.FragmentSources)
- class dynadoc.interfaces.InformationBase(*, annotation, description)¶
Bases:
object
Base for information on various kinds of entities.
- Variables:
annotation (typing_extensions.Any) – Type annotation associated with this entity.
description (str | None) – Human-readable description of the entity.
- class dynadoc.interfaces.Notifier(*args, **kwargs)¶
Bases:
Protocol
Notifies of warnings and errors.
- class dynadoc.interfaces.Raises(classes, description=None)¶
Bases:
object
Class and description of exception which can be raised.
Should appear in the return annotations for a function.
- Variables:
classes (type[ BaseException ] | collections.abc.Sequence[ type[ BaseException ] ]) – Exception class or classes which can be raised.
description (str | None) – When and why the exception is raised.
- class dynadoc.interfaces.ReturnInformation(*, annotation, description)¶
Bases:
InformationBase
Information about a function’s return value.
- Variables:
annotation (typing_extensions.Any) – Type annotation associated with this entity.
description (str | None) – Human-readable description of the entity.
- class dynadoc.interfaces.Sentinels(value)¶
Bases:
Enum
Sentinel values used in various parts of the package.
- Variables:
Absent (dynadoc.interfaces.Sentinels)
Incomplete (dynadoc.interfaces.Sentinels)
- class dynadoc.interfaces.ValuationModes(value)¶
Bases:
Enum
Annotation for how default value is determined.
Accept means to use assigned value. Suppress means to use no value. Surrogate means to use surrogate value.
- Variables:
Accept (dynadoc.interfaces.ValuationModes)
Suppress (dynadoc.interfaces.ValuationModes)
Surrogate (dynadoc.interfaces.ValuationModes)
- class dynadoc.interfaces.Visibilities(value)¶
Bases:
Enum
Annotation to determine visibility of attribute.
Default means to defer to visibility predicate in use. Conceal means to hide regardless of visibility predicate. Reveal means to show regardless of visibility predicate.
- Variables:
Default (dynadoc.interfaces.Visibilities)
Conceal (dynadoc.interfaces.Visibilities)
Reveal (dynadoc.interfaces.Visibilities)
- class dynadoc.interfaces.VisibilityDecider(*args, **kwargs)¶
Bases:
Protocol
Decides if attribute should have visible documentation.
- static __call__(possessor, name, annotation, description)¶
(Signature for visibility decider.)
- Parameters:
possessor (types.ModuleType | type | collections.abc.Callable[ ..., typing_extensions.Any ]) –
Object being documented.
May be a module, class, or function.
name (str) – Name of the attribute being evaluated.
annotation (typing_extensions.Any) – Type annotation of the attribute.
description (str | None) – Optional description text for the attribute.
- Return type:
Module dynadoc.introspection
¶
Introspection of argument, attribute, and return annotations.
- type dynadoc.introspection.IntrospectIntrospectionArgument = dynadoc.context.IntrospectionControl¶
- dynadoc.introspection.introspect(possessor, /, context, introspection, cache, table)¶
Introspects object to extract documentable information.
Dispatches to appropriate introspection function based on the type of the object being introspected (class, function, or module).
- Parameters:
possessor (types.ModuleType | type | collections.abc.Callable[ ..., typing_extensions.Any ]) –
Object being documented.
May be a module, class, or function.
context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
introspection (dynadoc.context.IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
cache (dynadoc.interfaces.AnnotationsCache) –
Cache for storing reduced annotation forms.
Also used for cycle detection.
table (collections.abc.Mapping[ str, str ]) – Table from which to copy docstring fragments.
- Return type:
collections.abc.Sequence[ dynadoc.interfaces.InformationBase ]
- dynadoc.introspection.introspect_special_classes(possessor, /, context, introspection, annotations, cache, table)¶
Introspects special classes in Python standard library.
E.g., enum members are collected as class variables.
- Parameters:
possessor (type) – Class being documented.
context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
introspection (dynadoc.context.IntrospectionControl) –
Controls on introspection behavior.
Is introspection enabled? Which kinds of objects to recursively document? Etc…
annotations (collections.abc.Mapping[ str, typing_extensions.Any ]) – Annotations mapping for documentable object.
cache (dynadoc.interfaces.AnnotationsCache) –
Cache for storing reduced annotation forms.
Also used for cycle detection.
table (collections.abc.Mapping[ str, str ]) – Table from which to copy docstring fragments.
- Return type:
collections.abc.Sequence[ dynadoc.interfaces.InformationBase ] | None
- dynadoc.introspection.is_attribute_visible(possessor, name, annotation, description)¶
Determines if attribute should be visible in documentation.
Default visibility predicate that considers attribute with description or public name (not starting with underscore) as visible.
If attribute possessor is module, then
__all__
is considered, if it exists.- Parameters:
possessor (types.ModuleType | type | collections.abc.Callable[ ..., typing_extensions.Any ]) –
Object being documented.
May be a module, class, or function.
name (str)
annotation (typing_extensions.Any)
description (str | None)
- Return type:
- dynadoc.introspection.reduce_annotation(annotation, context, adjuncts, cache)¶
Reduces a complex type annotation to a simpler form.
Processes type annotations, extracting metadata from Annotated types and simplifying complex generic types. Uses cache to avoid redundant processing and prevent infinite recursion from reference cycles.
- Parameters:
annotation (typing_extensions.Any)
context (dynadoc.context.Context)
adjuncts (dynadoc.interfaces.AdjunctsData)
- Return type:
typing_extensions.Any
Module dynadoc.nomina
¶
Catalog of common type aliases.
- type dynadoc.nomina.Decoratable = type | collections.abc.Callable[..., typing_extensions.Any]¶
- type dynadoc.nomina.Documentable = types.ModuleType | type | collections.abc.Callable[..., typing_extensions.Any]¶
- type dynadoc.nomina.Annotations = collections.abc.Mapping[str, typing_extensions.Any]¶
- type dynadoc.nomina.Decorator = collections.abc.Callable[[dynadoc.nomina.D], dynadoc.nomina.D]¶
- type dynadoc.nomina.FragmentsTable = collections.abc.Mapping[str, str]¶
- type dynadoc.nomina.Module = str | types.ModuleType¶
- type dynadoc.nomina.Variables = collections.abc.Mapping[str, typing_extensions.Any]¶
Module dynadoc.xtnsapi
¶
Interface for extension development.
- type dynadoc.xtnsapi.FragmentRectifierArgument = dynadoc.interfaces.FragmentRectifier¶
- type dynadoc.xtnsapi.FragmentsArgumentMultivalent = str | typing_extensions.Doc¶
- type dynadoc.xtnsapi.InvokerGlobalsArgument = collections.abc.Mapping[str, typing_extensions.Any] | None¶
- type dynadoc.xtnsapi.NotifierArgument = dynadoc.interfaces.Notifier¶
- type dynadoc.xtnsapi.ResolverGlobalsArgument = collections.abc.Mapping[str, typing_extensions.Any] | None¶
- type dynadoc.xtnsapi.ResolverLocalsArgument = collections.abc.Mapping[str, typing_extensions.Any] | None¶
- type dynadoc.xtnsapi.VisibilityDeciderArgument = dynadoc.interfaces.VisibilityDecider¶
- type dynadoc.xtnsapi.RendererArgument = dynadoc.xtnsapi.Renderer¶
- class dynadoc.xtnsapi.Renderer(*args, **kwargs)¶
Bases:
Protocol
Produces docstring fragment from object and information about it.
- static __call__(possessor, informations, context)¶
(Signature for fragment renderer.)
- Parameters:
possessor (types.ModuleType | type | collections.abc.Callable[ ..., typing_extensions.Any ]) –
Object being documented.
May be a module, class, or function.
informations (collections.abc.Sequence[ dynadoc.interfaces.InformationBase ]) –
Sequence of information blocks from object introspection.
Information may be about arguments to a function, attributes on a class or module, exceptions raised by a function, or returns from a function.
context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
- Returns:
Rendered docstring fragment.
- Return type:
Subpackage dynadoc.renderers
¶
Renderers for arguments, attributes, exceptions, and returns.
Module dynadoc.renderers.sphinxad
¶
Sphinx Autodoc reStructuredText renderers.
- type dynadoc.renderers.sphinxad.StyleArgument = dynadoc.renderers.sphinxad.Style¶
- class dynadoc.renderers.sphinxad.Style(value)¶
Bases:
Enum
Style of formatter output.
- Variables:
Legible (dynadoc.renderers.sphinxad.Style)
- dynadoc.renderers.sphinxad.produce_fragment(possessor, informations, context, style=Style.Legible)¶
Produces a reStructuredText docstring fragment.
Combines information from object introspection into a formatted docstring fragment suitable for Sphinx Autodoc.
- Parameters:
possessor (types.ModuleType | type | collections.abc.Callable[ ..., typing_extensions.Any ]) –
Object being documented.
May be a module, class, or function.
informations (collections.abc.Sequence[ dynadoc.interfaces.InformationBase ]) –
Sequence of information blocks from object introspection.
Information may be about arguments to a function, attributes on a class or module, exceptions raised by a function, or returns from a function.
context (dynadoc.context.Context) –
Data transfer object for various behaviors.
Controls how annotations are resolved and how fragments are processed and rendered.
style (dynadoc.renderers.sphinxad.Style) –
Output style for renderer.
Legible: Extra space padding inside of delimiters. Pep8: As the name implies.
- Returns:
Rendered docstring fragment.
- Return type: