Skip to content

Conversation

@rambleraptor
Copy link
Member

This change refactors how linter rule pages are generated:

Before:

  • Generate script consolidated individual linter rules into markdown files
  • Rules were grouped by AEP number and wrapped in
    Details elements
  • Output was written to src/content/docs/tooling/*/rules/{aep}.md

After:

  • Generate script writes individual rules as JSON to generated/linter-rules/
  • New Astro component (LinterRules.astro) handles rendering rules
  • Dynamic route pages ([aep].astro) read JSON and pass to component
  • Produces identical HTML output using Starlight's layout

Benefits:

  • Cleaner separation of concerns (data extraction vs. rendering)
  • Easier to modify rule presentation without regenerating content
  • Leverages Astro's component system and build process
  • Maintains site structure generation for navigation

Files Changed:

  • scripts/generate.ts: Use writeLinterRulesJSON() instead of consolidation
  • scripts/src/linter.ts: Add writeLinterRulesJSON() and getUniqueAeps()
  • src/components/LinterRules.astro: Component to render rule list
  • src/pages/tooling/linter/rules/[aep].astro: Protobuf linter dynamic route
  • src/pages/tooling/openapi-linter/rules/[aep].astro: OpenAPI linter dynamic route

This change refactors how linter rule pages are generated:

**Before:**
- Generate script consolidated individual linter rules into markdown files
- Rules were grouped by AEP number and wrapped in <details> elements
- Output was written to src/content/docs/tooling/*/rules/{aep}.md

**After:**
- Generate script writes individual rules as JSON to generated/linter-rules/
- New Astro component (LinterRules.astro) handles rendering rules
- Dynamic route pages ([aep].astro) read JSON and pass to component
- Produces identical HTML output using Starlight's layout

**Benefits:**
- Cleaner separation of concerns (data extraction vs. rendering)
- Easier to modify rule presentation without regenerating content
- Leverages Astro's component system and build process
- Maintains site structure generation for navigation

**Files Changed:**
- scripts/generate.ts: Use writeLinterRulesJSON() instead of consolidation
- scripts/src/linter.ts: Add writeLinterRulesJSON() and getUniqueAeps()
- src/components/LinterRules.astro: Component to render rule list
- src/pages/tooling/linter/rules/[aep].astro: Protobuf linter dynamic route
- src/pages/tooling/openapi-linter/rules/[aep].astro: OpenAPI linter dynamic route
Changed approach from JSON intermediary files to direct content collection queries:

**Before:**
- Generate script wrote individual rules to JSON files
- Astro pages read JSON and passed data to component

**After:**
- Generate script writes individual rule markdown files to content/docs
- Astro pages use getCollection() to read and consolidate rules
- Component handles rendering at build time

**Benefits:**
- No intermediate JSON files to manage
- Uses Astro's native content collection API
- Cleaner separation: generate extracts, Astro consolidates
- Leverages Astro's markdown rendering pipeline

**Changes:**
- scripts/generate.ts: Use writeIndividualRules() instead of JSON
- scripts/src/linter.ts: Replace writeLinterRulesJSON() with writeIndividualRules()
- src/pages/*/rules/[aep].astro: Use getCollection() and group by AEP
- src/components/LinterRules.astro: Accept Content components instead of HTML strings
…s SiteStructure

The generate script now only scans linter repos to determine which AEPs have rules
and updates the SiteStructure accordingly. All rule reading, processing, and
consolidation happens in Astro at build time.

**Generate Script Changes:**
- Removed writeIndividualRules() calls
- Only calls assembleLinterRules() to scan for AEP numbers
- Updates SiteStructure with rule metadata for navigation

**Astro Pages Changes:**
- Read directly from external repos using environment variables
- Import assembleLinterRules() and assembleOpenAPILinterRules()
- Process markdown to HTML at build time using marked
- Group and consolidate rules by AEP number

**Benefits:**
- Generate script is minimal - only maintains SiteStructure
- No intermediate files written (no JSON, no copied markdown)
- Astro handles all presentation logic
- External repos accessed via env vars during both generate and build

**Requirements:**
- AEP_LINTER_LOC and AEP_OPENAPI_LINTER_LOC must be set during Astro build
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.

3 participants