Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 1.14 KB

GENERATION.md

File metadata and controls

27 lines (18 loc) · 1.14 KB

Generation process

The generator has three main phases:

  • ingest
  • merge
  • stringify

The data-model classes represent a bridge between the webidl files and the final output: their shape and structure serve to facilitate the ingest phase and the stringify phase.

Ingest

This phase parses the .webidl/.idl files using the webidl parser. The output this phase produces is the instances of the data-model dataclasses; these classes represent webidl entities and attributes in a more convenient way for further manipulation in the following phases.

Merge

Webidl can declare entities like 'partial interface', so it is possible to have multiple instances of the data-model related to the same type. This phase merges multiple instances of the same type into a single instance.

Stringify

This phase takes data-model instances and turns them into pieces of Python source code strings. This is the Python code that will be written to the .pyi file. Note that stringify is implemented on the data-model dataclass (through the method to_python), which is why the ingest tests also contain the stringify tests.