googlefonts / googlefonts/fontations

codegen: consider generating wrappers on format enums for shared variant methods

Open
#687 1 comment 0 reactions 0 assignees View on GitHub
codegen enhancement
Dominant language
Rust
Stars
826
Forks
75
Avg merge
22h 33m
Merged PRs (30d)
75

Description

As in, if there are multiple formats for a table, but those formats share some set of methods, we should generate a method on the enum that forwards the call to each of those variants.

We could also get fancier here and generate methods on the wrapper even when only one variant has the method, and make it return `None`? But that feels like it could get noisy. In that case, we could consider adding an annotation that would be added to specific methods on a variant which would cause us to generate a a method call on the enum (e.g. make this opt-in, in the case where not all variants have a method)

see #682 for an example of the code this would save us hand-writing.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing issue #682 to understand the hand-written wrapper methods this code generation could replace, then locate the existing format-enum code generation path. Define how methods shared by all variants should be forwarded, and resolve whether methods present on only one variant need opt-in annotations. Done means the generator produces the intended wrappers with coverage for the selected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.