TraitDocumenter#

class TraitDocumenter(*args, observers=None, validators=None, **kwargs)#

Bases: AttributeDocumenter

Documenter for Trait objects.

Parameters:
  • observers (abc.Sequence[ObjectMember] | None)

  • validators (abc.Sequence[ObjectMember] | None)

__init__(*args, observers=None, validators=None, **kwargs)#
Parameters:
  • observers (Sequence[ObjectMember] | None)

  • validators (Sequence[ObjectMember] | None)

property accepted_values: tuple[str, list[str]] | None#

List of accepted values in an Enum.

add_directive_header(sig)#

Add directives to the object header.

Overwrite completely implementation from AttributeDocumenter to obtain the typehint from the trait itself, and remove the value directive (default value is documented elsewhere).

Parameters:

sig (str)

Return type:

None

classmethod can_document_member(member, membername, isattr, parent)#

Can this class document this member.

‘_subsections’ attribute is not documented.

Parameters:
Return type:

bool

property configurable: tuple[str, list[str]] | None#

If trait is configurable.

property default_value: tuple[str, list[str]] | None#

Default value of trait. Nicely rendered.

property fixable: tuple[str, list[str]] | None#

If trait correspond to a fixable parameter.

ie a parameter defined in a filename pattern from filefinder.

get_doc()#

Return documentation paragraphs.

This overwrite gets the documentation from the help attribute of traits, and add metadata/information about the trait (default value, etc.).

The metadata is dictated by the properties listed in metadata_properties.

Return type:

list[list[str]]

property max_length: tuple[str, list[str]] | None#

Maximum length of a list/set, if less than sys.maxsize (default).

metadata_properties = ['default_value', 'accepted_values', 'per_key_traits', 'min_length', 'max_length', 'configurable', 'read_only', 'fixable', 'observed', 'validated']#

Metadata properties in the order they should appear in doc.

All properties should return a tuple of the name of the property, and a list of lines that document this property. It can return None if the property should be skipped. Formatting will be done elsewhere.

property min_length: tuple[str, list[str]] | None#

Minimum length of a list/set, if greater than 0 (default).

objtype = 'trait'#

name by which the directive is called (auto…) and the default generated directive name

property observed: tuple[str, list[str]] | None#

If a trait is observed.

property per_key_traits: tuple[str, list[str]] | None#

List of per key traits in a Dict.

priority = 20#

priority if multiple documenters return True from can_document_member

property read_only: tuple[str, list[str]] | None#

If trait is read-only.

property validated: tuple[str, list[str]] | None#

If a trait is custom validated.