Implement a modal popup system for viewing type definitions without leaving
the current context, with browser-like back/forward navigation.
Modal UI Components:
- Full-screen overlay with centered modal dialog
- Header with title, close button, and navigation controls
- Scrollable content area for type definition
- Back (←) and forward (→) navigation buttons
- Visual disabled state for navigation at history bounds
Navigation Features:
- Click any type reference in root schema to open in modal
- Click type references within modal to navigate deeper
- Keyboard shortcuts: Alt+← (back), Alt+→ (forward), Escape (close)
- History tracking with array and index pointer
- History resets on modal close
JavaScript Implementation:
- `openTypeModal(typeName, addToHistory)`: Open/navigate to type
- `showType(typeName)`: Clone and display type definition content
- `navigateHistory(direction)`: Handle back/forward navigation
- `closeModal()`: Close modal and reset state
- `updateNavButtons()`: Enable/disable nav buttons based on position
CSS Styling (102 lines added):
- `.modal-overlay`: Fixed positioning with semi-transparent background
- `.modal`: Centered container with max dimensions and shadow
- `.modal-header`: Flex layout for nav, title, and close button
- `.modal-nav-btn`: Styled navigation buttons with disabled state
- `.modal-content`: Scrollable content with padding
Identifier Updates:
- Add modal-related IDs and classes to identifiers.rs
- New ID: `modal-overlay`
- New classes: modal, modal-active, modal-header, modal-title, modal-close,
modal-content, modal-nav, modal-nav-btn, disabled
Fix template rendering for tuples (arrays with prefixItems) that contain
non-primitive types like $ref or anyOf, which were incorrectly detected
as homogeneous tuples.
Template Logic Fix:
- Check if `item.type` and `first_type.type` are both defined before comparing
- Treat items with $ref, anyOf, or missing type as heterogeneous
- Apply fix in all three locations: render_type_badge, render_array_items_inline,
and render_array_items macros
Display Name Enhancement:
- Strip trailing digits from ALL type names, not just wrapper types
- Types like `DisplayFormat2` now display as `DisplayFormat`
- Only adds `_display_name` when it differs from original name
Create a single source of truth for all CSS class names and HTML element IDs
used throughout the generated documentation.
New Module (`src/identifiers.rs`):
- `HtmlIds` struct: Static HTML IDs for JS interaction (search, sidebar, etc.)
- `CssClasses` struct: All CSS class names organized by category
- `TypeClasses` struct: Type-specific badge classes (type-string, type-integer, etc.)
- Constants `IDS`, `CSS`, `TYPE_CLASSES` for compile-time access
- Serializable via serde for use in Tera templates
Class Categories:
- Layout: header, layout, main-content
- Sidebar: sidebar, sidebar-open, sidebar-toggle, sidebar-section
- Navigation: nav-list, nav-link, outline-list, outline-item
- Search: search-container, search-results, search-result-item
- Schema: schema-section, properties-container, property, property-header
- Badges: badge, required, deprecated, optional
- Types: type-badge, type-ref, and all type-specific classes
- Nested: nested-schema, array-items, tuple-items, variants
- Definition: definition, definition-name, highlight, usages
Template Updates:
- Replace hardcoded class strings with `{{ css.class_name }}` references
- Replace hardcoded IDs with `{{ ids.id_name }}` references
- Enables IDE navigation and refactoring support
Also adds `schema.json` test fixture (komorebi configuration schema)
Fix visual spacing issues between type badges, references, and other inline
elements in the generated documentation.
CSS Changes:
- Add `margin-left: 0.25rem` to `.badge`, `.type-badge`, and `.type-ref`
- Add `:first-child` selectors to remove left margin on first elements
- Ensures consistent spacing when multiple badges appear together
Template Fixes:
- Remove excess whitespace in Tera template conditionals
- Fix spacing around optional badges and type badges in `render_type_badge`
- Consolidate inline spacing in `render_schema` macro
- Clean up wrapper type inner badge rendering whitespace
Implement intelligent detection of "wrapper types" (anyOf patterns with map
variant and inner type) to render them more meaningfully in documentation.
Wrapper Type Detection:
- Detect anyOf patterns like `[{object with additionalProperties: T}, T]`
- Mark detected wrappers with `_wrapper_type` and `_wrapper_inner` metadata
- Display inner type directly instead of showing misleading "enum" badge
- Link wrapper types to their inner type definitions
- Add `_display_name` field for wrapper types with numeric suffixes
Float Display Improvements:
- Display "float" instead of "number" for JSON Schema number types in tuples
- Use `type-float` CSS class for consistent styling
- Homogeneous tuples now show as "float; N" for number arrays
Navigation Enhancements:
- Build navigation from prepared schema (includes wrapper display names)
- Add `display_names` map to template context for type name resolution
- Track type usages for "Usages" section in definitions
Test Coverage:
- Add comprehensive tests for wrapper type rendering
- Test tuple float/integer display formatting
- Verify wrapper types don't show "Enum variants" dropdown
- Test non-wrapper anyOf still correctly shows enum badge
Implement a complete Rust library and CLI tool for generating self-contained
HTML documentation from schemars::Schema (JSON Schema) objects.
Core Features:
- Library API with `generate_html()` function and `Options` struct
- CLI binary accepting JSON Schema input files with optional title override
- Tera-based HTML templating with base template and reusable macros
- Markdown rendering for schema descriptions via pulldown-cmark
- Dark/light theme support following system preferences
- Searchable properties with instant search functionality
- Collapsible nested structures for complex schemas
- Responsive design for mobile, tablet, and desktop
Library Components:
- `generator.rs`: Main HTML generation logic with Tera template engine
- `prepare.rs`: Schema preprocessing for template rendering (1667 lines)
- `lib.rs`: Public API with SchemaExt trait for typed schema accessors
- `main.rs`: CLI interface using clap for argument parsing
Template System:
- `base.html`: Main HTML structure with header, sidebar, and content areas
- `macros.html`: Reusable Tera macros for rendering schema components
- `style.css`: Complete CSS with CSS variables for theming (955 lines)