schema_salad.dlang_codegen

D code generator for a given schema salad definition.

Classes

DlangCodeGen

Generation of D code for a given Schema Salad definition.

Functions

is_constant_field(field)

Return True if a given field only takes the specified string.

constant_fields_of(type_)

Return a list of constant fields name from a given record schema.

are_dispatchable(types, parent_has_idmap)

Return True if a given list of types are dispatchable.

Module Contents

class schema_salad.dlang_codegen.DlangCodeGen(base, target, examples, package, copyright_, parser_info, salad_version)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritancef362c970f6 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for schema salad code generators."]; "DlangCodeGen" [URL="#schema_salad.dlang_codegen.DlangCodeGen",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Generation of D code for a given Schema Salad definition."]; "CodeGenBase" -> "DlangCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of D code for a given Schema Salad definition.

Parameters:
  • base (str)

  • target (IO[str])

  • examples (Optional[str])

  • package (str)

  • copyright_ (Optional[str])

  • parser_info (Optional[str])

  • salad_version (str)

base_uri
examples
target
package
copyright
parser_info
salad_version
doc_root_types: List[str] = []
prologue()

Trigger to generate the prolouge code.

Return type:

None

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

to_doc_comment(doc)

Return an embedded documentation comments for a given string.

Parameters:

doc (Union[None, str, List[str]])

Return type:

str

parse_record_field_type(type_, jsonld_pred, parent_has_idmap=False, has_default=False)

Return an annotation string and a type string.

Parameters:
  • type_ (Any)

  • jsonld_pred (Union[None, str, Dict[str, Any]])

  • parent_has_idmap (bool)

  • has_default (bool)

Return type:

Tuple[str, str]

parse_record_field(field, parent_name=None)

Return a declaration string for a given record field.

Parameters:
  • field (Dict[str, Any])

  • parent_name (Optional[str])

Return type:

str

parse_record_schema(stype)

Return a declaration string for a given record schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse_enum(stype)

Return a declaration string for a given enum schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse_union(stype)

Return a declaration string for a given union schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse_map(stype)

Return a declaration string for a given map schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse(items)

Generate D code from items and write it to target.

Parameters:

items (List[Dict[str, Any]])

Return type:

None

schema_salad.dlang_codegen.is_constant_field(field)

Return True if a given field only takes the specified string.

Parameters:

field (Dict[str, Any])

Return type:

bool

schema_salad.dlang_codegen.constant_fields_of(type_)

Return a list of constant fields name from a given record schema.

Parameters:

type_ (Any)

Return type:

Set[str]

schema_salad.dlang_codegen.are_dispatchable(types, parent_has_idmap)

Return True if a given list of types are dispatchable.

Parameters:
  • types (List[Any])

  • parent_has_idmap (bool)

Return type:

bool