Skip to content

API: group prettyReport files by generator with fileLimit option#143

Merged
ryukzak merged 5 commits intomainfrom
feat/pretty-report-group-by-generator
Apr 22, 2026
Merged

API: group prettyReport files by generator with fileLimit option#143
ryukzak merged 5 commits intomainfrom
feat/pretty-report-group-by-generator

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Apr 21, 2026

Report structure

  • Add filesByGenerator: Record<string, string[]> to GenerationReport, populated per-generator in executeGenerators.
  • prettyReport renders one section per generator with its own file count and loc total; unattributed files fall into an other group.

New fileLimit option

  • prettyReport(report, { fileLimit }) — default 20.
  • When a generator's file list exceeds fileLimit, files are aggregated by directory (count + loc per dir) instead of listing every file, keeping the output compact for large generators.

LOC formatting precision

formatLoc no longer collapses everything >= 1000 to an integer kloc (which was up to ~33% off for small buckets).

  • < 1000N loc
  • 1000–9999N.N kloc (one decimal)
  • >= 10000N kloc

Before / after

Before:

Generated files (25 kloc):
  - generated/types/hl7-fhir-r4-core/Patient.ts (125 loc)
  - generated/types/hl7-fhir-r4-core/Observation.ts (340 loc)
  - ... (hundreds of lines)

After (small group — listed per file):

Generated files (612 files, 25 kloc):
  ir-report (3 files, 480 loc):
    - generated/README.md (120 loc)
    - generated/type-tree.json (260 loc)
    - generated/ir-report.json (100 loc)
  typescript (608 files, 24 kloc):
    - generated/types/hl7-fhir-r4-core/ (600 files, 22 kloc)
    - generated/types/hl7-fhir-r4-core/profiles/ (8 files, 1.5 kloc)
  introspection (1 files, 800 loc):
    - generated/introspection.ndjson (800 loc)

ryukzak added 5 commits April 21, 2026 16:40
- Add filesByGenerator to GenerationReport, populated per-generator in executeGenerators
- Render prettyReport as per-generator sections with file counts and loc totals
- Fall back to an "other" group for any files not attributed to a generator
- When a generator produces more than fileLimit files (default 20), aggregate by directory with file count and loc per dir instead of listing every file
- Keeps per-file listing for smaller groups
- Show one decimal for kloc below 10k (e.g. 1.5 kloc) to avoid up-to-33% rounding error on small buckets
- Drop redundant filesByGenerator field. Merge grouping into filesGenerated as Record<generator, Record<path, content>> so content and generator attribution live in one place
- prettyReport iterates the nested shape directly; no extra maps or per-path bookkeeping
- executeGenerators merges output into filesGenerated[gen.name] so repeated calls with the same generator name (e.g. two .introspection(...)) accumulate instead of overwriting
- Fix stale debug log (result.filesGenerated.length was always undefined) to count across generators
- Update docs/guides/testing-generators.md to show the new access pattern
- Access files as result.filesGenerated[<generator>] (with non-null assertion since a generator may not have run)
- Introduce a local \`files\` constant per describe block to keep assertions readable
- Update file-count for introspection TypeSchema output (45 → 44) now that the implicit ir-report README.md lives under filesGenerated["ir-report"]
- Regenerate introspection snapshots to reflect the introspection-only file list (README.md moved out)
@ryukzak ryukzak merged commit e2c1a37 into main Apr 22, 2026
37 checks passed
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