gws.spec.generator.base

Generator state, a data class and the generator logger.

Source code: gws.spec.generator.base

Module Contents

gws.spec.generator.base.c
class gws.spec.generator.base.Data(**kwargs)

Simple data object. Missing attributes return None.

get(k, default=None)

Get an attribute value.

Parameters:
  • k – Attribute name.

  • default – Value to return if the attribute is not set.

Returns:

The attribute value or the default.

gws.spec.generator.base.Error
class gws.spec.generator.base.Generator

Generator state, shared by all generator steps.

aliases

Maps alias names (from imports and global names) to target names.

chunks

Source code chunks.

meta

Build-time metadata.

typeDict

All types, keyed by uid.

serverTypes

Types extracted for the server.

specData

The resulting spec data.

configRef

Configuration references in Markdown, keyed by language.

strings

Documentation strings, keyed by language and type uid.

manifestPath

Path to the application manifest.

outDir

Output directory.

rootDir

Application root directory (app).

selfDir

Directory of the spec package.

typescript

Generated TypeScript API.

debug

If True, dump the state after each step.

aliases: dict[str, str]
chunks: list[gws.spec.core.Chunk] = []
configRef
debug = False
manifestPath = ''
meta: dict
outDir = ''
rootDir = ''
selfDir = ''
serverTypes: list[Type] = []
specData: gws.spec.core.SpecData
strings
typeDict: dict[str, Type]
typescript = ''
add_type(**kwargs)

Create a type and add it to the type dictionary.

Named types use the name as uid. Other types get an automatic uid made of the type kind and the uids of the types they refer to, so that equal types share the uid.

Parameters:

**kwargs – Type attributes.

Returns:

The new type.

Raises:

GeneratorError – If no automatic uid can be created for the type kind.

dump(tag)

Write the generator state to <outDir>/<tag>.debug.json in debug mode.

Parameters:

tag – File name tag.

get_type(uid) → Type | None

Get a type by uid.

Parameters:

uid – Type uid.

Returns:

The type or None if not found.

require_type(uid) → Type

Get a type by uid, failing if it does not exist.

Parameters:

uid – Type uid.

Returns:

The type.

Raises:

GeneratorError – If the type is not found.

gws.spec.generator.base.GeneratorError
gws.spec.generator.base.LoadError
gws.spec.generator.base.log
gws.spec.generator.base.ReadError
gws.spec.generator.base.Type
gws.spec.generator.base.v