{{ message }}
feat: add options for generated header and generation stats#19
Open
Jamie-Fairweather wants to merge 2 commits into
Open
feat: add options for generated header and generation stats#19Jamie-Fairweather wants to merge 2 commits into
Jamie-Fairweather wants to merge 2 commits into
Conversation
- Introduced `includeGeneratedHeader` and `includeGenerationStats` options in the plugin configuration. - Updated relevant rendering functions to conditionally include the generated header and generation stats based on the new options. - Enhanced documentation in README to reflect the new configuration options. - Added tests to verify the behavior of the new options.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/types.ts (1)
137-148: CentralizeincludeGenerationStatsin shared render options.
includeGenerationStatsis a toggleable rendering control but isn’t inRenderOptions, so its defaulting logic is currently split across code paths. Consider moving it intoRenderOptions+resolveRenderOptions()for consistency with the other render toggles.Based on learnings: "When adding a new plugin option: (1) Add to `PluginOptions` in `src/types.ts`, (2) Parse in `resolvePluginOptions()` in `src/generator.ts`, (3) If controlling rendering, add to `RenderOptions` and `resolveRenderOptions()` in `src/extractors.ts`, (4) Update `README.md` configuration table, (5) Add tests."Suggested refactor
// src/types.ts export type RenderOptions = { fieldOrder: 'alphabetical' | 'declaration'; genCtx?: GenerationContext; includeGeneratedHeader: boolean; + includeGenerationStats: boolean; includeIndexes: boolean; includePolicies: boolean; includeRelationships: boolean; includeValidation: boolean; schemaDir?: string; };// src/extractors.ts export function resolveRenderOptions(options: PluginOptions): RenderOptions { return { fieldOrder: options.fieldOrder === 'alphabetical' ? 'alphabetical' : 'declaration', includeGeneratedHeader: options.includeGeneratedHeader !== false, + includeGenerationStats: options.includeGenerationStats !== false, includeIndexes: options.includeIndexes !== false, includePolicies: options.includePolicies !== false, includeRelationships: options.includeRelationships !== false, includeValidation: options.includeValidation !== false, }; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/types.ts` around lines 137 - 148, Add the missing includeGenerationStats flag to the shared RenderOptions type and centralize its defaulting in resolveRenderOptions(); also add it to PluginOptions and parse it in resolvePluginOptions() so plugin-level config flows into render options (remove any ad-hoc defaults elsewhere), update the README configuration table entry for includeGenerationStats, and add/adjust tests to cover the new option propagation and default behavior. Ensure you modify the RenderOptions type, the PluginOptions type, resolvePluginOptions(), and resolveRenderOptions() symbols so includeGenerationStats is passed through and resolved consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/generator/common.test.ts`:
- Line 73: Reformat the failing matcher call in the test so it conforms to
Prettier rules: update the expect(readDoc(noBanner, 'index.md')).toMatch(/^#
Schema Documentation\n/u); expression in test/generator/common.test.ts (the
readDoc/noBanner test) to the project's standard formatting (for example put
.toMatch on its own indented line or run the project's formatter) and run pnpm
run lint to verify the prettier error is resolved.
In `@test/generator/snapshot.test.ts`:
- Around line 6-9: Prettier is complaining about the formatting of the
.replaceAll(...) call inside stabilize() in snapshot.test.ts; reformat the
.replaceAll invocation (the /(· Generated: )\d{4}-\d{2}-\d{2}/gu regex and the
'$1<REDACTED>' replacement) to comply with Prettier rules (e.g. adjust line
breaks/spacing so the regex and replacement are styled consistently or put them
on the same line per project Prettier settings), save, and run pnpm run lint to
verify the prettier/prettier error is resolved.
---
Nitpick comments:
In `@src/types.ts`:
- Around line 137-148: Add the missing includeGenerationStats flag to the shared
RenderOptions type and centralize its defaulting in resolveRenderOptions(); also
add it to PluginOptions and parse it in resolvePluginOptions() so plugin-level
config flows into render options (remove any ad-hoc defaults elsewhere), update
the README configuration table entry for includeGenerationStats, and add/adjust
tests to cover the new option propagation and default behavior. Ensure you
modify the RenderOptions type, the PluginOptions type, resolvePluginOptions(),
and resolveRenderOptions() symbols so includeGenerationStats is passed through
and resolved consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 189fb9d9-617c-4159-8faf-2d842afbde6b
⛔ Files ignored due to path filters (1)
test/generator/__snapshots__/snapshot.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (15)
README.mdsrc/extractors.tssrc/generator.tssrc/renderers/common.tssrc/renderers/enum-page.tssrc/renderers/index-page.tssrc/renderers/model-page.tssrc/renderers/procedure-page.tssrc/renderers/relationships-page.tssrc/renderers/type-page.tssrc/renderers/view-page.tssrc/types.tstest/generator/common.test.tstest/generator/index-page.test.tstest/generator/snapshot.test.ts
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.

includeGeneratedHeaderandincludeGenerationStatsoptions in the plugin configuration.#18
Summary by CodeRabbit
New Features
Documentation
Tests