schema_salad.codegen_base
=========================

.. py:module:: schema_salad.codegen_base

.. autoapi-nested-parse::

   Base class for the generation of loaders from schema-salad definitions.



Classes
-------

.. autoapisummary::

   schema_salad.codegen_base.TypeDef
   schema_salad.codegen_base.LazyInitDef
   schema_salad.codegen_base.CodeGenBase


Module Contents
---------------

.. py:class:: TypeDef

   Bases: :py:obj:`NamedTuple`

   .. autoapi-inheritance-diagram:: schema_salad.codegen_base.TypeDef
      :parts: 1


   Schema Salad type description.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: init
      :type:  str


   .. py:attribute:: is_uri
      :type:  bool
      :value: False



   .. py:attribute:: scoped_id
      :type:  bool
      :value: False



   .. py:attribute:: ref_scope
      :type:  int | None
      :value: 0



   .. py:attribute:: loader_type
      :type:  str | None
      :value: None



   .. py:attribute:: instance_type
      :type:  str | None
      :value: None



   .. py:attribute:: abstract
      :type:  bool
      :value: False



.. py:class:: LazyInitDef

   Bases: :py:obj:`NamedTuple`

   .. autoapi-inheritance-diagram:: schema_salad.codegen_base.LazyInitDef
      :parts: 1


   Lazy initialization logic.


   .. py:attribute:: name
      :type:  str


   .. py:attribute:: init
      :type:  str


.. py:class:: CodeGenBase

   Abstract base class for schema salad code generators.


   .. py:attribute:: collected_types
      :type:  collections.OrderedDict[str, TypeDef]


   .. py:attribute:: lazy_inits
      :type:  collections.OrderedDict[str, LazyInitDef]


   .. py:attribute:: vocab
      :type:  dict[str, str]


   .. py:method:: declare_type(declared_type)

      Add this type to our collection, if needed.



   .. py:method:: add_lazy_init(lazy_init)

      Add lazy initialization logic for a given type.



   .. py:method:: add_vocab(name, uri)

      Add the given name as an abbreviation for the given URI.



   .. py:method:: prologue()
      :abstractmethod:


      Trigger to generate the prolouge code.



   .. py:method:: safe_name(name)
      :staticmethod:

      :abstractmethod:


      Generate a safe version of the given name.



   .. py:method:: begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)
      :abstractmethod:


      Produce the header for the given class.



   .. py:method:: end_class(classname, field_names)
      :abstractmethod:


      Signal that we are done with this class.



   .. py:method:: type_loader(type_declaration, container = None, no_link_check = None)
      :abstractmethod:


      Parse the given type declaration and declare its components.



   .. py:method:: declare_field(name, fieldtype, doc, optional, subscope)
      :abstractmethod:


      Output the code to load the given field.



   .. py:method:: declare_id_field(name, fieldtype, doc, optional)
      :abstractmethod:


      Output the code to handle the given ID field.



   .. py:method:: uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check = None)
      :abstractmethod:


      Construct the TypeDef for the given URI loader.



   .. py:method:: idmap_loader(field, inner, map_subject, map_predicate)
      :abstractmethod:


      Construct the TypeDef for the given mapped ID loader.



   .. py:method:: typedsl_loader(inner, ref_scope)
      :abstractmethod:


      Construct the TypeDef for the given DSL loader.



   .. py:method:: epilogue(root_loader)
      :abstractmethod:


      Trigger to generate the epilouge code.



   .. py:method:: secondaryfilesdsl_loader(inner)
      :abstractmethod:


      Construct the TypeDef for secondary files.



