Helper functions and base classes

Both lizard_structure.items and lizard_structure.views have helper functions and base classes. We document them here to keep the view and the item definitions documentation clean.

Helper base view

class lizard_structure.views.BaseAPIView(**kwargs)[source]

Base view that provides custom docstring rendering.

You should not have to subclass from BaseAPIView yourself, it is only used as a base for the other ones. The custom docstring handling happens by overwriting the get_description() expected by Django Rest framework.


Return the description, optionally as html.

Base class for building item definitions

class lizard_structure.items.BaseItem(**kwargs)[source]

Base class for the other items.

Flexible implementation so that we only have to specify the fixed and the default values (as dictionaries).

  • Fixed values cannot be set with a keyword argument.
  • Default arguments (None is fine as value, btw) can be set using keyword arguments, otherwise they get their default values.
  • Keys with None values are omitted from the resulting dictionary returned by to_api().

Return our internal dictionary, but strip it of None values first.

Helper function for generating item definition documentation

lizard_structure.items.generate_docstring(name, bases, attrs)

Generate a docstring based on the class’s defaults/fixed attributes.

Use this function as a metaclass by adding __metaclass__ = generate_docstring to every individual subclass of BaseItem.