google / blockly

The web-based visual programming editor.
https://developers.google.com/blockly/
Apache License 2.0
12.41k stars 3.71k forks source link

Make `CodeGenerator` abstract #7401

Open BeksOmega opened 1 year ago

BeksOmega commented 1 year ago

Check for duplicates

Problem

The CodeGenerator class doesn't work as is. You either need to subclass it to define methods like quote_ and scrub_, or you need to cludge onto an instance (which we should not be encouraging).

Request

As such we should make CodeGenerator abstract.

Alternatives considered

No response

Additional context

We want to hold off on doing this until we are ready to publish the correct types for generators. (Or at least until we finish refactoring the API of CodeGenerator).

gonfunko commented 9 months ago

Note that https://blocklycodelabs.dev/codelabs/custom-generator/index.html?index=..%2F..index#2 uses the ability to directly instantiate a CodeGenerator (using the deprecated Generator alias) and should also be updated if this is done.