feat(cli): add styling.unused report to specs analyze styling#181
Open
nathanacurtis wants to merge 1 commit into
Open
feat(cli): add styling.unused report to specs analyze styling#181nathanacurtis wants to merge 1 commit into
nathanacurtis wants to merge 1 commit into
Conversation
The styling analyzer now compares the tokens referenced by generated
specs against the full token universe from fetched foundations data
and writes _analysis/styling.unused.{json|yaml} listing variables,
color styles, text styles, and effect styles no spec uses, plus a
per-category total/used/unused summary.
- AnalyzeCommand resolves {alias}.variables.json / {alias}.styles.json
from config.sources + dataDirectory and loads them via loadFoundations
- Transformer.finalize gains an optional AnalyzerFoundations parameter
(structural type, no dependency on specs-from-figma)
- Variables matched by collection-prefixed name mirroring
FigmaVariableReference.tokenPath(); styles by name; FILL/TEXT/EFFECT
categorized, GRID excluded; used-name matching is cross-category
- Report is skipped when no foundations data files exist
- Docs: analyze/styling page restructured around the three outputs
with collection logic described; byToken example corrected to the
real category-grouped shape
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
specs analyze stylingnow writes a third aggregate report,_analysis/styling.unused.{json|yaml}, listing every token in the fetched foundations data that no generated spec references — variables, color styles, text styles, and effect styles — with a per-categorysummaryof total/used/unused counts.How it works
{alias}.variables.json/{alias}.styles.jsonfromconfig.sources+dataDirectory(same pattern as GenerateCommand) and loads them via the existingloadFoundationsutility. When no data files exist, the report is skipped and the other outputs are unaffected.finalizegains an optional third parameter typed asAnalyzerFoundations— a minimal structural type inTypes/Transformer.ts, so the CLI's transformer contract does not depend onspecs-from-figmatypes.Collection name/Variable name(mirroringFigmaVariableReference.tokenPath(), including its unresolved-collection placeholder), styles by raw name. Styles categorize FILL → colorStyles, TEXT → textStyles, EFFECT → effectStyles; GRID styles are excluded since specs never reference them. A token counts as used if any scope references its name in any category, guarding against miscategorized references producing false positives.Docs
site/src/content/docs/cli/analyze/styling.mdis restructured around the three outputs as first-class sections, each describing its collection/comparison logic. ThebyTokenexample is corrected to the real category-grouped shape (the previous example showed a flat structure that doesn't match the analyzer's output). The analyze overview page lists the new file.Testing
specs-testing/workspaces/eg: category totals match an independent recount of the raw data (1394 collection-prefixed variables), zero overlap between used and unused sets, plausible results (146/1394 variables used, 52/55 text styles used, all gradient color styles and Thin/Thick background blurs reported unused).🤖 Generated with Claude Code