feat: add options for generated header and generation stats by Jamie-Fairweather · Pull Request #19 · sheldonj/zenstack-docs-plugin · GitHub
Skip to content

feat: add options for generated header and generation stats#19

Open
Jamie-Fairweather wants to merge 2 commits into
sheldonj:mainfrom
Jamie-Fairweather:issue/18
Open

feat: add options for generated header and generation stats#19
Jamie-Fairweather wants to merge 2 commits into
sheldonj:mainfrom
Jamie-Fairweather:issue/18

Conversation

@Jamie-Fairweather

@Jamie-Fairweather Jamie-Fairweather commented Apr 11, 2026

Copy link
Copy Markdown
  • 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.

#18

Summary by CodeRabbit

  • New Features

    • Two new config flags: includeGeneratedHeader (controls top-of-file banner) and includeGenerationStats (controls collapsible generation stats); both enabled by default.
  • Documentation

    • README updated with examples, descriptions, and defaults for the new options.
  • Tests

    • New tests verify the banner and stats can be disabled; snapshots now normalize generated timestamps for stability.

- 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.
@coderabbitai

coderabbitai Bot commented Apr 11, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/types.ts (1)

137-148: Centralize includeGenerationStats in shared render options.

includeGenerationStats is a toggleable rendering control but isn’t in RenderOptions, so its defaulting logic is currently split across code paths. Consider moving it into RenderOptions + resolveRenderOptions() for consistency with the other render toggles.

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,
   };
 }
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."
🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2044d82 and 7b991bd.

⛔ Files ignored due to path filters (1)
  • test/generator/__snapshots__/snapshot.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • README.md
  • src/extractors.ts
  • src/generator.ts
  • src/renderers/common.ts
  • src/renderers/enum-page.ts
  • src/renderers/index-page.ts
  • src/renderers/model-page.ts
  • src/renderers/procedure-page.ts
  • src/renderers/relationships-page.ts
  • src/renderers/type-page.ts
  • src/renderers/view-page.ts
  • src/types.ts
  • test/generator/common.test.ts
  • test/generator/index-page.test.ts
  • test/generator/snapshot.test.ts

Comment thread test/generator/common.test.ts Outdated
Comment thread test/generator/snapshot.test.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant