refactor(docgen): remove HTML output, focus exclusively on MDX generation

BREAKING CHANGE: HTML output format has been removed. The tool now
generates MDX documentation for Astro Starlight exclusively.

This commit removes the HTML generator and all associated code,
simplifying the codebase to focus on MDX output only.

Removed

- `src/generator.rs` - HTML documentation generator (1827 lines)
- `src/identifiers.rs` - CSS/HTML identifiers (371 lines)
- `src/templates/base.html` - HTML base template
- `src/templates/macros.html` - HTML macro templates
- `src/templates/style.css` - CSS styles (1216 lines)
- `src/templates/test_index.html` - Test HTML template
- `build.rs` - CSS minification build script
- `tests/json_schema_test_suite.rs` - JSON Schema test suite (501 lines)
- `tests/fixtures/json-schema-test-suite/` - All draft2020-12 test fixtures

Removed Dependencies

- lightningcss (CSS minification)
- rayon (parallel processing)
- struct_iterable (struct iteration)
- regex, chrono (dev dependencies)

Added

- `ENUMS.md` - Comprehensive documentation of all 11 Rust enum patterns
  and their JSONSchema representations
- 12 unit tests covering all enum patterns to prevent Value duplication

Changed

CLI (src/main.rs)
- Remove `--format` flag (was html/mdx, now mdx only)
- Remove `Format` enum
- Simplify to always output MDX

Library (src/lib.rs)
- Remove `Options` struct and `generate_html()` function
- Remove `Generator`, `CSS`, `IDS`, `TYPE_CLASSES` exports
- Update module docs to reflect MDX-only output
- Update tests to use `generate_mdx()`

Templates (src/templates/mdx_macros.md)
- Add section headers organizing macros by function
- Add comprehensive comments documenting all enum patterns
- Fix duplicate Value rendering for const variants
- Add Pattern 7 detection for externally tagged enums
- Change `<details>` to `<details open>` for better visibility
- Render required properties before optional ones
- Move `$ref` handling after `type` in render_type_badge (Pattern 6 fix)

Preparation (src/prepare.rs)
- Minor formatting improvements
This commit is contained in:
LGUG2Z committed 2025-12-27 20:32:20 -08:00
1 parent f48586033d
commit 91463ff033
97 files changed
+1918 -22456

No files matched your search

+7 -34
View File
@@ -1,23 +1,10 @@
#![warn(clippy::all)]
use clap::Parser;
use clap::ValueEnum;
use schemars_docgen::MdxOptions;
use schemars_docgen::Options;
use schemars_docgen::generate_html;
use schemars_docgen::generate_mdx;
use std::path::PathBuf;
/// Output format for documentation generation
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
enum Format {
/// HTML output (self-contained single file)
#[default]
Html,
/// MDX output for Astro Starlight
Mdx,
}
#[derive(Parser)]
#[command(name = "schemars-docgen")]
#[command(about = "Generate documentation from JSON Schema")]
@@ -25,19 +12,15 @@ struct Cli {
/// Input JSON Schema file
input: PathBuf,
/// Output file (defaults to input filename with appropriate extension)
/// Output file (defaults to input filename with .mdx extension)
#[arg(short, long)]
output: Option<PathBuf>,
/// Output format
#[arg(short, long, default_value = "html")]
format: Format,
/// Schema title (overrides title from the schema)
#[arg(short, long)]
title: Option<String>,
/// Schema description (overrides description from the schema, MDX only)
/// Schema description (overrides description from the schema)
#[arg(short, long)]
description: Option<String>,
}
@@ -48,25 +31,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let schema_json = std::fs::read_to_string(&cli.input)?;
let schema: schemars::Schema = serde_json::from_str(&schema_json)?;
let (output, extension) = match cli.format {
Format::Html => {
let options = Options {
title_override: cli.title,
};
(generate_html(&schema, &options)?, "html")
}
Format::Mdx => {
let options = MdxOptions {
title_override: cli.title,
description_override: cli.description,
};
(generate_mdx(&schema, &options)?, "mdx")
}
let options = MdxOptions {
title_override: cli.title,
description_override: cli.description,
};
let output = generate_mdx(&schema, &options)?;
let output_path = cli.output.unwrap_or_else(|| {
let mut path = cli.input.clone();
path.set_extension(extension);
path.set_extension("mdx");
path
});