class Schema(definition: dict = None)

Container defining and handling the data schema.

method load_definition(definition: dict)

Initialize the schema object from the given definition and returns the root data type object.

Raises SchemaDefinitionError if given schema definition contains syntax errors.

definition

Dictionary containing a valid schema defintion.

method doc(fmt: str)

Create a documentation (in the requested format) of the data schema as string and returns it.

fmt

str representing the intended documentation format.

Allowed values:

  • markdown: Create a detailed markdown table of the data schema
  • yaml: Create a short but nice yaml code block of the data schema
  • none: Get a Doc object containing documentation table row elements.

method doc_sections(fmt: str, level: int = 0)

Create a dictionary of documentation sections (in the requested format) of the data schema and returns it.

keys: str; representing the data path for this documentation section values: str; documentation in the requested format

This method only makes sense, if root data type is a dictionary.

fmt

str representing the intended documentation format.

Allowed values:

  • markdown: Create a detailed markdown table of the data schema
  • yaml: Create a short but nice yaml code block of the data schema
  • none: Get a Doc object containing documentation table row elements.

level

Level int of splitting dictionaries and keys into sections. Default is 0. Thus, splitting top-level dictionary/keys only.

method structured_doc(fmt: str, structure: dict|list[str])

Get documentation snippets (in the requested format) based on given structure.

Returns a tuple:

  • First tuple element: Matching dict/keys will be returned as dictioniary with key path as key and documentation (in the requested format) as value.
  • Second tuple element: Non-matching keys or structure elements will be returned in a documentation (in the requested format).

fmt

str representing the intended documentation format.

Allowed values:

  • markdown: Create a detailed markdown table of the data schema
  • yaml: Create a short but nice yaml code block of the data schema
  • none: Get a Doc object containing documentation table row elements.

structure

Expected structure is given as a list of strings or lists of strings in a nested dictionary. Dictionaries in the structure shall map to the 'dict' data types in the schema. List of strings shall represent keys in the 'dict' data type.