chore(build): update tsDocGen.js with support for enum parsing #148
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.
Closes patternfly/patternfly-org#4756
What Changed
Adds enum value extraction to tsDocGen.js.
Modified
cli/tsDocGen.jsto extract enum values from TypeScript union types into clean arrays, making the generated JSON more consumable for LLMs towards the effort to support JSON schemas. This change is essential for patternfly/patternfly-org#4705.Why This Matters
LLMs currently struggle with union type strings and can generate invalid prop values with our existing approach to parsing. This change provides clean, structured data that will enable accurate code generation via JSON schemas that will support this improvement to our parsing logic for our existing TS components. Clean arrays are fully machine-readable and unambiguous for any AI system.
Current problem: LLM sees
"'primary' | 'secondary'"and might generatevariant="main"With this fix: LLM sees
["primary", "secondary"]and generatesvariant="primary"Before:
"type": "'primary' | 'secondary' | 'tertiary'"After:
"type": "'primary' | 'secondary' | 'tertiary'", "enumValues": ["primary", "secondary", "tertiary"]Files Changed
cli/tsDocGen.js- Added one function (extractEnumValues) and 4 lines to addenumValuesfieldTesting Instructions
Full Test (2 minutes)
What to look for:
"enumValues": ["primary", "secondary", ...]arrays in the JSONtypefield unchanged