feat(docgen): initial implementation of html doc generator

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)
This commit is contained in:
LGUG2Z committed 2025-12-22 09:31:19 -08:00
commit c85edf242f
13 files changed
+5997

No files matched your search

+1204
View File
File diff suppressed because it is too large. Load diff
+379
View File
@@ -0,0 +1,379 @@
//! # schemars-docgen
//!
//! Generate HTML documentation from `schemars::Schema` objects.
//!
//! This library takes a JSON Schema (as produced by schemars) and generates
//! a self-contained HTML documentation page with:
//!
//! - Responsive design (mobile, tablet, desktop)
//! - Dark/light mode following system preference
//! - Searchable properties
//! - Collapsible nested structures
//! - Markdown rendering for descriptions
//!
//! ## Usage
//!
//! ```rust,no_run
//! use schemars::schema_for;
//! use schemars_docgen::{generate_html, Options};
//!
//! #[derive(schemars::JsonSchema)]
//! struct MyConfig {
//! /// The name of the configuration
//! name: String,
//! }
//!
//! let schema = schema_for!(MyConfig);
//! let options = Options::default();
//! let html = generate_html(&schema, &options).unwrap();
//! ```
mod generator;
mod prepare;
pub use generator::Generator;
use schemars::Schema;
use serde_json::Value;
/// Options for HTML generation
#[derive(Debug, Clone, Default)]
pub struct Options {
/// Override the schema title
pub title_override: Option<String>,
}
/// Error type for documentation generation
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Template error: {0}")]
Template(#[from] tera::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}
/// Generate HTML documentation from a schema
///
/// This is the main entry point for the library. It takes a `schemars::Schema`
/// and returns a self-contained HTML string.
pub fn generate_html(schema: &Schema, options: &Options) -> Result<String, Error> {
let generator = Generator::new()?;
generator.generate(schema, options)
}
/// Extension trait for convenient access to common schema properties
///
/// Since `schemars::Schema` is a wrapper around `serde_json::Value`,
/// this trait provides typed accessors for standard JSON Schema keywords.
pub trait SchemaExt {
/// Get the schema title
fn title(&self) -> Option<&str>;
/// Get the schema description
fn description(&self) -> Option<&str>;
/// Get the schema type (can be a string or array of strings)
fn schema_type(&self) -> Option<&Value>;
/// Get object properties
fn properties(&self) -> Option<&serde_json::Map<String, Value>>;
/// Get schema definitions ($defs)
fn definitions(&self) -> Option<&serde_json::Map<String, Value>>;
/// Get array items schema
fn items(&self) -> Option<&Value>;
/// Get anyOf schemas
fn any_of(&self) -> Option<&Vec<Value>>;
/// Get oneOf schemas
fn one_of(&self) -> Option<&Vec<Value>>;
/// Get allOf schemas
fn all_of(&self) -> Option<&Vec<Value>>;
/// Get enum values
fn enum_values(&self) -> Option<&Vec<Value>>;
/// Get $ref target
fn ref_target(&self) -> Option<&str>;
/// Get default value
fn default_value(&self) -> Option<&Value>;
/// Get required fields
fn required_fields(&self) -> Option<&Vec<Value>>;
/// Get format constraint
fn format(&self) -> Option<&str>;
/// Get pattern constraint
fn pattern(&self) -> Option<&str>;
/// Get minimum constraint
fn minimum(&self) -> Option<f64>;
/// Get maximum constraint
fn maximum(&self) -> Option<f64>;
/// Get const value
fn const_value(&self) -> Option<&Value>;
/// Get pattern properties
fn pattern_properties(&self) -> Option<&serde_json::Map<String, Value>>;
/// Get additional properties schema
fn additional_properties(&self) -> Option<&Value>;
/// Get prefix items (tuple validation)
fn prefix_items(&self) -> Option<&Vec<Value>>;
/// Get min items constraint
fn min_items(&self) -> Option<u64>;
/// Get max items constraint
fn max_items(&self) -> Option<u64>;
/// Check if deprecated
fn is_deprecated(&self) -> bool;
}
impl SchemaExt for Schema {
fn title(&self) -> Option<&str> {
self.as_object()?.get("title")?.as_str()
}
fn description(&self) -> Option<&str> {
self.as_object()?.get("description")?.as_str()
}
fn schema_type(&self) -> Option<&Value> {
self.as_object()?.get("type")
}
fn properties(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("properties")?.as_object()
}
fn definitions(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("$defs")?.as_object()
}
fn items(&self) -> Option<&Value> {
self.as_object()?.get("items")
}
fn any_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("anyOf")?.as_array()
}
fn one_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("oneOf")?.as_array()
}
fn all_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("allOf")?.as_array()
}
fn enum_values(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("enum")?.as_array()
}
fn ref_target(&self) -> Option<&str> {
self.as_object()?.get("$ref")?.as_str()
}
fn default_value(&self) -> Option<&Value> {
self.as_object()?.get("default")
}
fn required_fields(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("required")?.as_array()
}
fn format(&self) -> Option<&str> {
self.as_object()?.get("format")?.as_str()
}
fn pattern(&self) -> Option<&str> {
self.as_object()?.get("pattern")?.as_str()
}
fn minimum(&self) -> Option<f64> {
self.as_object()?.get("minimum")?.as_f64()
}
fn maximum(&self) -> Option<f64> {
self.as_object()?.get("maximum")?.as_f64()
}
fn const_value(&self) -> Option<&Value> {
self.as_object()?.get("const")
}
fn pattern_properties(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("patternProperties")?.as_object()
}
fn additional_properties(&self) -> Option<&Value> {
self.as_object()?.get("additionalProperties")
}
fn prefix_items(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("prefixItems")?.as_array()
}
fn min_items(&self) -> Option<u64> {
self.as_object()?.get("minItems")?.as_u64()
}
fn max_items(&self) -> Option<u64> {
self.as_object()?.get("maxItems")?.as_u64()
}
fn is_deprecated(&self) -> bool {
self.as_object()
.and_then(|o| o.get("deprecated"))
.and_then(|v| v.as_bool())
.unwrap_or(false)
}
}
/// Extension trait for Value to use the same accessors
impl SchemaExt for Value {
fn title(&self) -> Option<&str> {
self.as_object()?.get("title")?.as_str()
}
fn description(&self) -> Option<&str> {
self.as_object()?.get("description")?.as_str()
}
fn schema_type(&self) -> Option<&Value> {
self.as_object()?.get("type")
}
fn properties(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("properties")?.as_object()
}
fn definitions(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("$defs")?.as_object()
}
fn items(&self) -> Option<&Value> {
self.as_object()?.get("items")
}
fn any_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("anyOf")?.as_array()
}
fn one_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("oneOf")?.as_array()
}
fn all_of(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("allOf")?.as_array()
}
fn enum_values(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("enum")?.as_array()
}
fn ref_target(&self) -> Option<&str> {
self.as_object()?.get("$ref")?.as_str()
}
fn default_value(&self) -> Option<&Value> {
self.as_object()?.get("default")
}
fn required_fields(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("required")?.as_array()
}
fn format(&self) -> Option<&str> {
self.as_object()?.get("format")?.as_str()
}
fn pattern(&self) -> Option<&str> {
self.as_object()?.get("pattern")?.as_str()
}
fn minimum(&self) -> Option<f64> {
self.as_object()?.get("minimum")?.as_f64()
}
fn maximum(&self) -> Option<f64> {
self.as_object()?.get("maximum")?.as_f64()
}
fn const_value(&self) -> Option<&Value> {
self.as_object()?.get("const")
}
fn pattern_properties(&self) -> Option<&serde_json::Map<String, Value>> {
self.as_object()?.get("patternProperties")?.as_object()
}
fn additional_properties(&self) -> Option<&Value> {
self.as_object()?.get("additionalProperties")
}
fn prefix_items(&self) -> Option<&Vec<Value>> {
self.as_object()?.get("prefixItems")?.as_array()
}
fn min_items(&self) -> Option<u64> {
self.as_object()?.get("minItems")?.as_u64()
}
fn max_items(&self) -> Option<u64> {
self.as_object()?.get("maxItems")?.as_u64()
}
fn is_deprecated(&self) -> bool {
self.as_object()
.and_then(|o| o.get("deprecated"))
.and_then(|v| v.as_bool())
.unwrap_or(false)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_schema_ext_title() {
let schema: Schema =
serde_json::from_str(r#"{"title": "Test Schema", "type": "object"}"#).unwrap();
assert_eq!(schema.title(), Some("Test Schema"));
}
#[test]
fn test_schema_ext_description() {
let schema: Schema =
serde_json::from_str(r#"{"description": "A test description"}"#).unwrap();
assert_eq!(schema.description(), Some("A test description"));
}
#[test]
fn test_schema_ext_ref() {
let schema: Schema = serde_json::from_str(r##"{"$ref": "#/$defs/MyType"}"##).unwrap();
assert_eq!(schema.ref_target(), Some("#/$defs/MyType"));
}
#[test]
fn test_schema_ext_properties() {
let schema: Schema = serde_json::from_str(
r#"{"type": "object", "properties": {"name": {"type": "string"}}}"#,
)
.unwrap();
let props = schema.properties().unwrap();
assert!(props.contains_key("name"));
}
}
+44
View File
@@ -0,0 +1,44 @@
use clap::Parser;
use schemars_docgen::Options;
use schemars_docgen::generate_html;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "schemars-docgen")]
#[command(about = "Generate HTML documentation from JSON Schema")]
struct Cli {
/// Input JSON Schema file
input: PathBuf,
/// Output HTML file
#[arg(short, long)]
output: Option<PathBuf>,
/// Schema title (overrides schema title from the schema)
#[arg(short, long)]
title: Option<String>,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
let schema_json = std::fs::read_to_string(&cli.input)?;
let schema: schemars::Schema = serde_json::from_str(&schema_json)?;
let options = Options {
title_override: cli.title,
};
let html = generate_html(&schema, &options)?;
let output_path = cli.output.unwrap_or_else(|| {
let mut path = cli.input.clone();
path.set_extension("html");
path
});
std::fs::write(&output_path, html)?;
println!("Generated documentation: {}", output_path.display());
Ok(())
}
+1667
View File
File diff suppressed because it is too large. Load diff
+144
View File
@@ -0,0 +1,144 @@
{%- import "macros.html" as macros -%}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ title | default(value="Schema Documentation") }}</title>
<style>
{% include "style.css" %}
</style>
</head>
<body>
<header class="header">
<div class="header-content">
<h1>
{{ title_html | default(value="Schema Documentation") | safe
}}
</h1>
<div class="search-container">
<input
type="search"
id="search"
placeholder="Search properties and types..."
autocomplete="off"
/>
<div id="search-results" class="search-results"></div>
</div>
</div>
</header>
<div class="layout">
<nav class="sidebar" id="sidebar">
<div class="sidebar-header">
<h2>Navigation</h2>
<button
class="sidebar-toggle"
id="sidebar-toggle"
aria-label="Toggle sidebar"
>
<span></span>
</button>
</div>
{%- if navigation.outline | length > 0 -%}
<div class="sidebar-section">
<h3 class="sidebar-section-title">Outline</h3>
<ul class="nav-list outline-list">
{%- for entry in navigation.outline -%} {{
macros::render_outline_item(entry=entry, depth=0) }} {%-
endfor -%}
</ul>
</div>
{%- endif -%} {%- if navigation.definitions | length > 0 -%}
<div class="sidebar-section">
<h3 class="sidebar-section-title">Types</h3>
<ul class="nav-list">
{%- for def in navigation.definitions -%}
<li>
<a
href="#{{ def.anchor }}"
class="nav-link"
data-search-name="{{ def.name | lower }}"
>{{ def.name }}</a
>
</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}
</nav>
<main class="main-content">
<section id="root-schema" class="schema-section">
<h2>Configuration</h2>
{%- if schema.properties -%}
<div class="properties-container">
{%- for prop_name, prop in schema.properties -%} {%- set
is_required = prop_name in required_set -%} {{
macros::render_property(name=prop_name, node=prop,
required=is_required, depth=0, path=prop_name) }} {%-
endfor -%}
</div>
{%- endif -%}
</section>
{%- if schema["$defs"] -%}
<section id="definitions" class="schema-section">
<h2>Type Definitions</h2>
{%- for def_name, def in schema["$defs"] -%}
<article
id="{{ def_name | lower }}"
class="definition"
data-search-name="{{ def_name | lower }}"
>
<h3 class="definition-name">{{ def_name }}</h3>
{%- if def.description_html %}
<div class="description">
{{ def.description_html | safe }}
</div>
{% endif -%} {{ macros::render_schema(node=def, depth=0,
path=def_name) }} {# Usages section at bottom #} {%- set
type_usages = usages[def_name] -%} {%- if type_usages
and (type_usages.config_usages | length > 0 or
type_usages.type_references | length > 0) -%}
<div class="usages">
{%- if type_usages.config_usages | length > 0 -%}
<div class="usage-section">
<h4>Configuration Usage</h4>
<ul class="usage-list">
{%- for usage in type_usages.config_usages
-%}
<li>
<a href="#{{ usage.anchor }}"
><code>{{ usage.path }}</code></a
>
</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%} {%- if type_usages.type_references |
length > 0 -%}
<div class="usage-section">
<h4>Referenced by</h4>
<ul class="usage-list">
{%- for ref in type_usages.type_references
-%}
<li>
<a href="#{{ ref.anchor }}"
>{{ ref.type_name }}</a
>
</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}
</div>
{%- endif -%}
</article>
{%- endfor -%}
</section>
{%- endif -%}
</main>
</div>
<script>
(function(){const searchInput=document.getElementById('search');const searchResults=document.getElementById('search-results');const searchIndex={{ search_index | json_encode() | safe }};searchInput.addEventListener('input',function(e){const query=e.target.value.toLowerCase().trim();if(!query){searchResults.innerHTML='';searchResults.classList.remove('active');return;}const matches=searchIndex.filter(item=>item.name.toLowerCase().includes(query)||item.path.toLowerCase().includes(query)).slice(0,10);if(matches.length===0){searchResults.innerHTML='<div class="search-result-item no-results">No results found</div>';}else{searchResults.innerHTML=matches.map(item=>`<a href="#${item.anchor}" class="search-result-item"><span class="result-name">${item.name}</span><span class="result-path">${item.path}</span><span class="result-type">${item.entry_type}</span></a>`).join('');}searchResults.classList.add('active');});document.addEventListener('click',function(e){if(!searchInput.contains(e.target)&&!searchResults.contains(e.target)){searchResults.classList.remove('active');}});searchInput.addEventListener('keydown',function(e){if(e.key==='Escape'){searchResults.classList.remove('active');searchInput.blur();}});const sidebarToggle=document.getElementById('sidebar-toggle');const sidebar=document.getElementById('sidebar');if(sidebarToggle&&sidebar){sidebarToggle.addEventListener('click',function(){sidebar.classList.toggle('open');});}document.querySelectorAll('a[href^="#"]').forEach(anchor=>{anchor.addEventListener('click',function(e){const targetId=this.getAttribute('href').slice(1);const target=document.getElementById(targetId);if(target){target.classList.add('highlight');setTimeout(()=>target.classList.remove('highlight'),2000);}if(sidebar){sidebar.classList.remove('open');}searchResults.classList.remove('active');});});})();
</script>
</body>
</html>
+348
View File
@@ -0,0 +1,348 @@
{# Render a hierarchical outline item with collapsible children #}
{% macro render_outline_item(entry, depth) %}
{%- if entry.children | length > 0 -%}
<li class="outline-item depth-{{ depth }}">
<details>
<summary>
<a href="#{{ entry.anchor }}" class="nav-link" data-search-name="{{ entry.name | lower }}">{{ entry.name }}</a>
</summary>
<ul class="outline-children">
{%- for child in entry.children -%}
{{ self::render_outline_item(entry=child, depth=depth + 1) }}
{%- endfor -%}
</ul>
</details>
</li>
{%- else -%}
<li class="outline-item depth-{{ depth }}">
<a href="#{{ entry.anchor }}" class="nav-link" data-search-name="{{ entry.name | lower }}">{{ entry.name }}</a>
</li>
{%- endif -%}
{% endmacro render_outline_item %}
{# Render a property with its name and schema #}
{# Note: Using 'node' instead of 'schema' to avoid conflict with global context #}
{% macro render_property(name, node, required, depth, path) %}
{%- if depth < 10 -%}
<div class="property depth-{{ depth }}" id="{{ path | lower | replace(from=".", to="-") }}" data-search-name="{{ name | lower }}">
<div class="property-header">
<code class="property-name">{{ name }}</code>
{%- if required %}<span class="badge required">required</span>{% endif -%}
{%- if node.deprecated %}<span class="badge deprecated">deprecated</span>{% endif -%}
{{ self::render_type_badge(node=node) }}
</div>
{%- if node.description_html %}<div class="description">{{ node.description_html | safe }}</div>{% endif -%}
{{ self::render_constraints(node=node) }}
{%- if node.default %}<div class="default-value"><span class="label">Default:</span> <code>{{ node.default | json_encode() }}</code></div>{% endif -%}
{{ self::render_schema_body(node=node, depth=depth, path=path) }}
</div>
{%- else -%}
<div class="property depth-{{ depth }}"><span class="too-deep">Schema nested too deeply. See type definition.</span></div>
{%- endif -%}
{% endmacro render_property %}
{# Render the type badge for a schema #}
{% macro render_type_badge(node) %}
{%- if node["$ref"] -%}
{%- set ref_name = node["$ref"] | replace(from="#/$defs/", to="") -%}
<a href="#{{ ref_name | lower }}" class="type-ref">{{ ref_name }}</a>
{%- elif node.type -%}
{%- if node.type is string -%}
{%- if node.type == "array" and node.prefixItems -%}
{# Check if all prefixItems have the same type (homogeneous tuple) #}
{%- set first_type = node.prefixItems | first -%}
{%- set_global is_homogeneous = true -%}
{%- for item in node.prefixItems -%}
{%- if item.type != first_type.type -%}
{%- set_global is_homogeneous = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_homogeneous and first_type.type -%}
<span class="type-badge type-array">array</span> <span class="type-badge type-{{ first_type.type }}">{{ first_type.type }}; {{ node.prefixItems | length }}</span>
{%- else -%}
<span class="type-badge type-array">array</span> <span class="type-badge type-array">tuple</span>
{%- endif -%}
{%- elif node.type == "array" and node.items -%}
{# Show array with item type as separate badge #}
<span class="type-badge type-array">array</span> {{ self::render_type_badge(node=node.items) }}
{%- else -%}
<span class="type-badge type-{{ node.type }}">{{ node.type }}</span>
{%- endif -%}
{%- else -%}
{# Check for Option<T> pattern: type array with exactly 2 types where one is null #}
{%- if node.type | length == 2 and "null" in node.type -%}
<span class="badge optional">optional</span>
{%- for t in node.type -%}
{%- if t != "null" -%}
{%- if t == "array" and node.items -%}
<span class="type-badge type-array">array</span> {{ self::render_type_badge(node=node.items) }}
{%- else -%}
<span class="type-badge type-{{ t }}">{{ t }}</span>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for t in node.type -%}<span class="type-badge type-{{ t }}">{{ t }}</span>{% endfor -%}
{%- endif -%}
{%- endif -%}
{%- elif node.anyOf -%}
{# Check for Option<T> pattern: anyOf with exactly 2 variants where one is null #}
{%- if node.anyOf | length == 2 -%}
{%- set first = node.anyOf | first -%}
{%- set second = node.anyOf | last -%}
{%- if second.type and second.type == "null" -%}
<span class="badge optional">optional</span>{{ self::render_type_badge(node=first) }}
{%- elif first.type and first.type == "null" -%}
<span class="badge optional">optional</span>{{ self::render_type_badge(node=second) }}
{%- else -%}
{# Check if all variants are string const (enum pattern) #}
{%- set_global is_string_enum = true -%}
{%- for variant in node.anyOf -%}
{%- if variant.type and variant.type == "string" and variant.const -%}
{# valid string const #}
{%- else -%}
{%- set_global is_string_enum = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_string_enum -%}
<span class="type-badge type-string">string</span> <span class="type-badge type-enum">enum</span>
{%- else -%}
<span class="type-badge type-enum">enum</span>
{%- endif -%}
{%- endif -%}
{%- else -%}
{# Check if all variants are string const (enum pattern) #}
{%- set_global is_string_enum = true -%}
{%- for variant in node.anyOf -%}
{%- if variant.type and variant.type == "string" and variant.const -%}
{# valid string const #}
{%- else -%}
{%- set_global is_string_enum = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_string_enum -%}
<span class="type-badge type-string">string</span> <span class="type-badge type-enum">enum</span>
{%- else -%}
<span class="type-badge type-enum">enum</span>
{%- endif -%}
{%- endif -%}
{%- elif node.oneOf -%}
{# Check if all variants are string const (enum pattern from schemars with doc comments) #}
{%- set_global is_string_enum = true -%}
{%- for variant in node.oneOf -%}
{%- if variant.type and variant.type == "string" and variant.const -%}
{# This variant is a string const, keep is_string_enum true #}
{%- else -%}
{%- set_global is_string_enum = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_string_enum -%}
<span class="type-badge type-string">string</span> <span class="type-badge type-enum">enum</span>
{%- else -%}
<span class="type-badge type-enum">enum</span>
{%- endif -%}
{%- elif node.allOf -%}
<span class="type-badge type-union">allOf</span>
{%- elif node.const -%}
<span class="type-badge type-const">const</span>
{%- elif node.enum -%}
<span class="type-badge type-enum">enum</span>
{%- endif -%}
{% endmacro render_type_badge %}
{# Render constraints like min, max, pattern, format #}
{% macro render_constraints(node) %}
{# Check if this is a homogeneous tuple - skip minItems/maxItems if so #}
{%- set_global skip_item_constraints = false -%}
{%- if node.prefixItems -%}
{%- set first_type = node.prefixItems | first -%}
{%- set_global is_homogeneous = true -%}
{%- for item in node.prefixItems -%}
{%- if item.type != first_type.type -%}
{%- set_global is_homogeneous = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_homogeneous and first_type.type -%}
{%- set_global skip_item_constraints = true -%}
{%- endif -%}
{%- endif -%}
{%- if node.format or node.pattern or node.minimum is defined or node.maximum is defined or node.minLength is defined or node.maxLength is defined or (node.minItems is defined and not skip_item_constraints) or (node.maxItems is defined and not skip_item_constraints) -%}
<div class="constraints">
{%- if node.format %}<span class="constraint"><span class="label">Format:</span> <code>{{ node.format }}</code></span>{% endif -%}
{%- if node.pattern %}<span class="constraint"><span class="label">Pattern:</span> <code>{{ node.pattern }}</code></span>{% endif -%}
{%- if node.minimum is defined %}<span class="constraint"><span class="label">Min:</span> {{ node.minimum }}</span>{% endif -%}
{%- if node.maximum is defined %}<span class="constraint"><span class="label">Max:</span> {{ node.maximum }}</span>{% endif -%}
{%- if node.minLength is defined %}<span class="constraint"><span class="label">Min length:</span> {{ node.minLength }}</span>{% endif -%}
{%- if node.maxLength is defined %}<span class="constraint"><span class="label">Max length:</span> {{ node.maxLength }}</span>{% endif -%}
{%- if node.minItems is defined and not skip_item_constraints %}<span class="constraint"><span class="label">Min items:</span> {{ node.minItems }}</span>{% endif -%}
{%- if node.maxItems is defined and not skip_item_constraints %}<span class="constraint"><span class="label">Max items:</span> {{ node.maxItems }}</span>{% endif -%}
</div>
{%- endif -%}
{% endmacro render_constraints %}
{# Render the body of a schema (properties, items, variants, etc.) #}
{% macro render_schema_body(node, depth, path) %}
{%- if depth < 10 -%}
{%- if node["$ref"] -%}
{# Reference only, already shown as type badge #}
{%- elif node.properties -%}
{%- set required_arr = node.required | default(value=[]) -%}
<details class="nested-schema" open>
<summary>Properties ({{ node.properties | length }})</summary>
<div class="properties-container">
{%- for prop_name, prop in node.properties -%}
{%- set is_required = prop_name in required_arr -%}
{{ self::render_property(name=prop_name, node=prop, required=is_required, depth=depth + 1, path=path ~ "." ~ prop_name) }}
{%- endfor -%}
</div>
</details>
{%- elif node.patternProperties -%}
<div class="properties-container map-entries">
{%- for pattern, prop in node.patternProperties -%}
<div class="property depth-{{ depth + 1 }}">
<div class="property-header">
{# Convert known patterns to friendly type names - show as quoted string to indicate JSON string key #}
{# Note: patterns use single backslash in the parsed JSON value #}
{%- if pattern == "^\d+$" or pattern == "^[0-9]+$" or pattern == "^-?\d+$" or pattern == "^-?[0-9]+$" -%}
<span class="map-key">"&lt;<span class="key-type">integer</span>&gt;"</span>
{%- elif pattern == ".*" or pattern == "^.*$" -%}
<span class="map-key">"&lt;<span class="key-type">string</span>&gt;"</span>
{%- else -%}
<code class="property-name pattern">{{ pattern }}</code>
<span class="badge pattern">pattern</span>
{%- endif -%}
<span class="map-arrow">→</span>
{{ self::render_type_badge(node=prop) }}
</div>
{%- if prop.description_html %}<div class="description">{{ prop.description_html | safe }}</div>{% endif -%}
{{ self::render_schema_body(node=prop, depth=depth + 1, path=path ~ ".[key]") }}
</div>
{%- endfor -%}
</div>
{%- elif node.items -%}
{%- if node.items["$ref"] -%}
{# Already shown in type badge, no dropdown needed #}
{%- elif node.items.type and node.items.type is string -%}
{# Simple type (string, number, integer, boolean) - already shown in type badge #}
{%- else -%}
{# Complex item type needs dropdown #}
<details class="nested-schema" open>
<summary>Array Items</summary>
<div class="array-items">{{ self::render_schema(node=node.items, depth=depth + 1, path=path ~ "[]") }}</div>
</details>
{%- endif -%}
{%- elif node.prefixItems -%}
{# Check if homogeneous tuple - already shown as [T; N] in badge #}
{%- set first_type = node.prefixItems | first -%}
{%- set_global is_homogeneous = true -%}
{%- for item in node.prefixItems -%}
{%- if item.type != first_type.type -%}
{%- set_global is_homogeneous = false -%}
{%- endif -%}
{%- endfor -%}
{%- if is_homogeneous and first_type.type -%}
{# Homogeneous tuple - already shown as [T; N] in badge, no dropdown needed #}
{%- else -%}
{# Heterogeneous tuple - show dropdown #}
<details class="nested-schema" open>
<summary>Tuple Items ({{ node.prefixItems | length }})</summary>
<div class="tuple-items">
{%- for item in node.prefixItems -%}
<div class="tuple-item"><span class="tuple-index">[{{ loop.index0 }}]</span>{{ self::render_schema(node=item, depth=depth + 1, path=path ~ "[" ~ loop.index0 ~ "]") }}</div>
{%- endfor -%}
</div>
</details>
{%- endif -%}
{%- elif node.anyOf -%}
{# Check for Option<T> pattern: anyOf with exactly 2 variants where one is null #}
{%- if node.anyOf | length == 2 -%}
{%- set first = node.anyOf | first -%}
{%- set second = node.anyOf | last -%}
{%- if second.type and second.type == "null" -%}
{# Option<T> - just render the non-null variant's body #}
{{ self::render_schema_body(node=first, depth=depth, path=path) }}
{%- elif first.type and first.type == "null" -%}
{# Option<T> with null first - just render the non-null variant's body #}
{{ self::render_schema_body(node=second, depth=depth, path=path) }}
{%- else -%}
{# Check if all variants are string const (enum pattern) #}
{%- set_global is_string_enum = true -%}
{%- for variant in node.anyOf -%}
{%- if variant.type and variant.type == "string" and variant.const -%}
{# valid string const #}
{%- else -%}
{%- set_global is_string_enum = false -%}
{%- endif -%}
{%- endfor -%}
{# Render all anyOf variants using full schema rendering #}
<details class="nested-schema enum-details" open>
<summary>Enum variants ({{ node.anyOf | length }})</summary>
<div class="variants">
{%- for variant in node.anyOf -%}
<div class="variant">{{ self::render_schema(node=variant, depth=depth + 1, path=path ~ ".anyOf[" ~ loop.index0 ~ "]") }}</div>
{%- endfor -%}
</div>
</details>
{%- endif -%}
{%- else -%}
{# Render all anyOf variants using full schema rendering #}
<details class="nested-schema enum-details" open>
<summary>Enum variants ({{ node.anyOf | length }})</summary>
<div class="variants">
{%- for variant in node.anyOf -%}
<div class="variant">{{ self::render_schema(node=variant, depth=depth + 1, path=path ~ ".anyOf[" ~ loop.index0 ~ "]") }}</div>
{%- endfor -%}
</div>
</details>
{%- endif -%}
{%- elif node.oneOf -%}
{# Render all oneOf variants using full schema rendering #}
<details class="nested-schema enum-details" open>
<summary>Enum variants ({{ node.oneOf | length }})</summary>
<div class="variants">
{%- for variant in node.oneOf -%}
<div class="variant">{{ self::render_schema(node=variant, depth=depth + 1, path=path ~ ".oneOf[" ~ loop.index0 ~ "]") }}</div>
{%- endfor -%}
</div>
</details>
{%- elif node.allOf -%}
<details class="nested-schema" open>
<summary>All of ({{ node.allOf | length }} schemas)</summary>
<div class="variants">
{%- for variant in node.allOf -%}
<div class="variant">{{ self::render_schema(node=variant, depth=depth + 1, path=path ~ ".allOf[" ~ loop.index0 ~ "]") }}</div>
{%- endfor -%}
</div>
</details>
{%- elif node.enum -%}
{%- set enum_count = node.enum | length -%}
<details class="nested-schema enum-details" open>
<summary>Enum variants ({{ enum_count }})</summary>
<ul class="enum-values">
{%- for value in node.enum -%}<li><code>{{ value | json_encode() }}</code></li>{%- endfor -%}
</ul>
</details>
{%- elif node.const -%}
<div class="const-value"><span class="label">Value:</span> <code>{{ node.const | json_encode() }}</code></div>
{%- endif -%}
{%- if node.additionalProperties and node.additionalProperties is object -%}
<details class="nested-schema" open>
<summary>Additional Properties</summary>
{{ self::render_schema(node=node.additionalProperties, depth=depth + 1, path=path ~ ".[*]") }}
</details>
{%- endif -%}
{%- endif -%}
{% endmacro render_schema_body %}
{# Render a schema without property wrapper #}
{% macro render_schema(node, depth, path) %}
{%- if depth < 10 -%}
<div class="schema-inline">
{{ self::render_type_badge(node=node) }}
{%- if node.description_html %}<div class="description">{{ node.description_html | safe }}</div>{% endif -%}
{{ self::render_constraints(node=node) }}
{%- if node.default %}<div class="default-value"><span class="label">Default:</span> <code>{{ node.default | json_encode() }}</code></div>{% endif -%}
{{ self::render_schema_body(node=node, depth=depth, path=path) }}
</div>
{%- endif -%}
{% endmacro render_schema %}
+955
View File
@@ -0,0 +1,955 @@
/* CSS Custom Properties for theming */
:root {
--bg-primary: #ffffff;
--bg-secondary: #f8f9fa;
--bg-tertiary: #e9ecef;
--text-primary: #212529;
--text-secondary: #6c757d;
--text-muted: #adb5bd;
--accent: #0d6efd;
--accent-hover: #0b5ed7;
--border: #dee2e6;
--border-light: #e9ecef;
--code-bg: #f1f3f5;
--code-text: #e83e8c;
--description-bg: #f8f9fa;
--description-border: #0d6efd;
--success: #198754;
--warning: #ffc107;
--danger: #dc3545;
--highlight: #fff3cd;
--shadow: rgba(0, 0, 0, 0.1);
--font-sans:
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
Arial, sans-serif;
--font-mono:
SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
"Courier New", monospace;
}
/* Dark mode - follows system preference */
@media (prefers-color-scheme: dark) {
:root {
--bg-primary: #1a1d21;
--bg-secondary: #22262b;
--bg-tertiary: #2c3137;
--text-primary: #e9ecef;
--text-secondary: #adb5bd;
--text-muted: #6c757d;
--accent: #6ea8fe;
--accent-hover: #8bb9fe;
--border: #3d4349;
--border-light: #2c3137;
--code-bg: #2c3137;
--code-text: #f8a4c4;
--description-bg: #22262b;
--description-border: #6ea8fe;
--highlight: #3d3520;
--shadow: rgba(0, 0, 0, 0.3);
}
}
/* Reset and base styles */
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
font-size: 16px;
}
body {
margin: 0;
padding: 0;
font-family: var(--font-sans);
font-size: 1rem;
line-height: 1.6;
color: var(--text-primary);
background-color: var(--bg-primary);
}
/* Header */
.header {
position: sticky;
top: 0;
z-index: 100;
background-color: var(--bg-secondary);
border-bottom: 1px solid var(--border);
padding: 1rem;
box-shadow: 0 2px 4px var(--shadow);
}
.header-content {
max-width: 1400px;
margin: 0 auto;
}
.header h1 {
margin: 0 0 0.5rem 0;
font-size: 1.5rem;
font-weight: 600;
}
.header .schema-description {
color: var(--text-secondary);
margin-bottom: 1rem;
}
.header .schema-description p {
margin: 0;
}
/* Search */
.search-container {
position: relative;
max-width: 400px;
}
#search {
width: 100%;
padding: 0.5rem 1rem;
font-size: 0.9rem;
border: 1px solid var(--border);
border-radius: 6px;
background-color: var(--bg-primary);
color: var(--text-primary);
outline: none;
transition:
border-color 0.15s,
box-shadow 0.15s;
}
#search:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}
#search::placeholder {
color: var(--text-muted);
}
.search-results {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: var(--bg-primary);
border: 1px solid var(--border);
border-radius: 6px;
margin-top: 4px;
max-height: 300px;
overflow-y: auto;
box-shadow: 0 4px 12px var(--shadow);
z-index: 1000;
}
.search-results.active {
display: block;
}
.search-result-item {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
text-decoration: none;
color: var(--text-primary);
border-bottom: 1px solid var(--border-light);
transition: background-color 0.15s;
}
.search-result-item:last-child {
border-bottom: none;
}
.search-result-item:hover {
background-color: var(--bg-secondary);
}
.search-result-item.no-results {
color: var(--text-secondary);
font-style: italic;
}
.result-name {
font-weight: 500;
}
.result-path {
color: var(--text-secondary);
font-size: 0.85rem;
flex: 1;
}
.result-type {
font-size: 0.75rem;
padding: 0.125rem 0.375rem;
background: var(--bg-tertiary);
border-radius: 3px;
color: var(--text-secondary);
}
/* Layout */
.layout {
display: grid;
grid-template-columns: 1fr;
min-height: calc(100vh - 120px);
}
@media (min-width: 768px) {
.layout {
grid-template-columns: 260px 1fr;
}
}
@media (min-width: 1200px) {
.layout {
grid-template-columns: 280px 1fr;
}
}
/* Sidebar */
.sidebar {
background-color: var(--bg-secondary);
border-right: 1px solid var(--border);
padding: 1rem;
overflow-y: auto;
display: none;
}
@media (min-width: 768px) {
.sidebar {
display: block;
position: sticky;
top: 80px;
height: calc(100vh - 80px);
}
}
.sidebar.open {
display: block;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 200;
padding-top: 60px;
}
.sidebar-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.sidebar-header h2 {
margin: 0;
font-size: 1rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-secondary);
}
.sidebar-toggle {
display: block;
padding: 0.5rem;
background: none;
border: none;
cursor: pointer;
}
@media (min-width: 768px) {
.sidebar-toggle {
display: none;
}
}
.sidebar-toggle span {
display: block;
width: 20px;
height: 2px;
background: var(--text-primary);
margin: 4px 0;
}
.nav-list {
list-style: none;
margin: 0;
padding: 0;
}
.nav-link {
display: block;
padding: 0.375rem 0.5rem;
color: var(--text-primary);
text-decoration: none;
border-radius: 4px;
font-size: 0.9rem;
transition: background-color 0.15s;
}
.nav-link:hover {
background-color: var(--bg-tertiary);
}
/* Sidebar sections */
.sidebar-section {
margin-bottom: 1.5rem;
}
.sidebar-section-title {
font-size: 0.7rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-muted);
margin: 0 0 0.5rem 0.5rem;
}
.outline-list {
border-bottom: 1px solid var(--border);
padding-bottom: 1rem;
margin-bottom: 0.5rem;
}
/* Hierarchical outline tree */
.outline-item {
position: relative;
}
.outline-children {
list-style: none;
margin: 0;
padding-left: 0.75rem;
border-left: 1px solid var(--border-light);
margin-left: 0.5rem;
}
.outline-item.depth-1 > a.nav-link,
.outline-item.depth-1 > details > summary .nav-link {
font-size: 0.8rem;
color: var(--text-secondary);
}
.outline-item.depth-2 > a.nav-link,
.outline-item.depth-2 > details > summary .nav-link {
font-size: 0.75rem;
color: var(--text-muted);
}
/* Collapsible outline items */
.outline-item details {
margin: 0;
}
.outline-item details > summary {
list-style: none;
cursor: pointer;
display: flex;
align-items: center;
gap: 0.25rem;
}
.outline-item details > summary::-webkit-details-marker {
display: none;
}
/* Custom expand/collapse indicator */
.outline-item details > summary::before {
content: "▶";
font-size: 0.5rem;
color: var(--text-muted);
transition: transform 0.15s ease;
flex-shrink: 0;
width: 0.75rem;
}
.outline-item details[open] > summary::before {
transform: rotate(90deg);
}
/* Ensure link inside summary works correctly */
.outline-item details > summary .nav-link {
flex: 1;
}
/* Leaf items (no children) - add spacer to match expand icon width */
.outline-item > a.nav-link {
display: flex;
align-items: center;
gap: 0.25rem; /* Same gap as expandable items */
}
.outline-item > a.nav-link::before {
content: "";
width: 0.75rem; /* Same width as expand icon */
flex-shrink: 0;
}
/* Mobile sidebar toggle button in header */
@media (max-width: 767px) {
.header-content {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 1rem;
}
.header h1 {
flex: 1;
}
.search-container {
order: 3;
width: 100%;
max-width: none;
}
}
/* Main content */
.main-content {
padding: 1.5rem;
max-width: 900px;
}
@media (min-width: 1200px) {
.main-content {
padding: 2rem;
}
}
.schema-section {
margin-bottom: 3rem;
}
.schema-section > h2 {
font-size: 1.5rem;
font-weight: 600;
margin: 0 0 1.5rem 0;
padding-bottom: 0.5rem;
border-bottom: 2px solid var(--accent);
}
/* Definition */
.definition {
margin-bottom: 2rem;
padding: 1.5rem;
background-color: var(--bg-secondary);
border-radius: 8px;
border: 1px solid var(--border);
scroll-margin-top: 100px;
transition: box-shadow 0.3s;
}
.definition.highlight {
box-shadow: 0 0 0 3px var(--accent);
}
.definition-name {
margin: 0 0 0.75rem 0;
font-size: 1.25rem;
font-weight: 600;
color: var(--accent);
}
/* Property */
.property {
padding: 1rem 0;
border-bottom: 1px solid var(--border-light);
scroll-margin-top: 100px;
}
.property:last-child {
border-bottom: none;
}
.property.highlight {
background-color: var(--highlight);
margin: 0 -1rem;
padding: 1rem;
border-radius: 4px;
}
.property-header {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
}
.property-name {
font-family: var(--font-mono);
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
background: none;
padding: 0;
}
.property-name.pattern {
color: var(--code-text);
}
/* Badges */
.badge {
display: inline-block;
padding: 0.125rem 0.5rem;
font-size: 0.7rem;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.025em;
border-radius: 3px;
}
.badge.required {
background-color: var(--danger);
color: white;
}
.badge.deprecated {
background-color: var(--warning);
color: #000;
}
.badge.pattern {
background-color: var(--accent);
color: white;
}
/* Map key styling for patternProperties */
.map-key {
font-family: var(--font-mono);
font-size: 0.95rem;
color: var(--text-primary);
}
.map-key .key-type {
color: var(--accent);
font-weight: 500;
}
.map-arrow {
color: var(--text-muted);
margin: 0 0.5rem;
}
.badge.optional {
background-color: #6c757d;
color: white;
}
/* Type badges */
.type-badge {
display: inline-block;
padding: 0.125rem 0.5rem;
font-size: 0.75rem;
font-weight: 500;
border-radius: 3px;
background-color: var(--bg-tertiary);
color: var(--text-secondary);
}
/* Primitive types */
.type-badge.type-string {
background-color: #198754;
color: white;
}
.type-badge.type-number {
background-color: #0d6efd;
color: white;
}
.type-badge.type-integer {
background-color: #0a58ca;
color: white;
}
.type-badge.type-boolean {
background-color: #fd7e14;
color: white;
}
.type-badge.type-null {
background-color: #6c757d;
color: white;
}
/* Complex types */
.type-badge.type-object {
background-color: #6f42c1;
color: white;
}
.type-badge.type-array {
background-color: #0891b2;
color: white;
}
/* Composition types */
.type-badge.type-enum {
background-color: #d63384;
color: white;
}
.type-badge.type-union {
background-color: #6610f2;
color: white;
}
.type-badge.type-const {
background-color: #495057;
color: white;
}
.type-ref {
display: inline-block;
padding: 0.125rem 0.5rem;
font-size: 0.75rem;
font-weight: 500;
border-radius: 3px;
background-color: #6f42c1;
color: white;
text-decoration: none;
transition: background-color 0.15s;
}
.type-ref:hover {
background-color: #5a32a3;
}
/* Description - PROMINENT styling */
.description {
background-color: var(--description-bg);
border-left: 3px solid var(--description-border);
padding: 0.75rem 1rem;
margin: 0.75rem 0;
border-radius: 0 4px 4px 0;
}
.description p {
margin: 0 0 0.5rem 0;
}
.description p:last-child {
margin-bottom: 0;
}
.description code {
background-color: var(--code-bg);
padding: 0.125rem 0.375rem;
border-radius: 3px;
font-family: var(--font-mono);
font-size: 0.875em;
color: var(--code-text);
}
.description a {
color: var(--accent);
}
/* Constraints */
.constraints {
display: flex;
flex-wrap: wrap;
gap: 0.5rem 1rem;
margin: 0.5rem 0;
font-size: 0.875rem;
}
.constraint {
color: var(--text-secondary);
}
.constraint .label {
font-weight: 500;
}
.constraint code {
background-color: var(--code-bg);
padding: 0.125rem 0.375rem;
border-radius: 3px;
font-family: var(--font-mono);
font-size: 0.875em;
}
/* Default and const values - unified styling */
.default-value,
.const-value {
margin: 0.5rem 0;
font-size: 0.875rem;
color: var(--text-secondary);
}
.default-value .label,
.const-value .label {
font-weight: 500;
}
.default-value code,
.const-value code {
background-color: var(--code-bg);
padding: 0.125rem 0.375rem;
border-radius: 3px;
font-family: var(--font-mono);
font-size: 0.875em;
color: var(--code-text);
}
/* Nested schemas (details/summary) */
.nested-schema {
margin: 0.75rem 0;
border: 1px solid var(--border-light);
border-radius: 6px;
overflow: hidden;
}
.nested-schema > summary {
padding: 0.5rem 1rem;
background-color: var(--bg-tertiary);
cursor: pointer;
font-weight: 500;
font-size: 0.9rem;
user-select: none;
list-style: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.nested-schema > summary::-webkit-details-marker {
display: none;
}
.nested-schema > summary::before {
content: "▶";
font-size: 0.7rem;
transition: transform 0.15s;
}
.nested-schema[open] > summary::before {
transform: rotate(90deg);
}
.nested-schema > summary:hover {
background-color: var(--border-light);
}
.properties-container,
.array-items,
.tuple-items,
.variants {
padding: 0.5rem 1rem;
}
/* Depth-based indentation */
.depth-1 {
margin-left: 0.5rem;
}
.depth-2 {
margin-left: 1rem;
}
.depth-3 {
margin-left: 1.5rem;
}
.depth-4 {
margin-left: 2rem;
}
.depth-5 {
margin-left: 2.5rem;
}
@media (max-width: 767px) {
.depth-1,
.depth-2,
.depth-3,
.depth-4,
.depth-5 {
margin-left: 0;
}
}
/* Variants */
.variant {
padding: 0.75rem 0;
border-bottom: 1px solid var(--border-light);
}
.variant:last-child {
border-bottom: none;
}
/* Tuple items */
.tuple-item {
padding: 0.5rem 0;
border-bottom: 1px solid var(--border-light);
}
.tuple-item:last-child {
border-bottom: none;
}
.tuple-index {
display: inline-block;
font-family: var(--font-mono);
font-size: 0.875rem;
font-weight: 500;
color: var(--text-secondary);
margin-right: 0.5rem;
}
/* Enum values */
.enum-values {
list-style: none;
margin: 0;
padding: 0.5rem 1rem;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.enum-values li {
margin: 0;
}
.enum-values code {
display: inline-block;
padding: 0.25rem 0.5rem;
background-color: var(--code-bg);
border-radius: 3px;
font-family: var(--font-mono);
font-size: 0.875rem;
}
/* Large enum - show as list */
.enum-details .enum-values {
max-height: 300px;
overflow-y: auto;
flex-direction: column;
gap: 0.25rem;
}
/* Usages section */
.usages {
margin: 1rem 0;
padding: 0.75rem 1rem;
background-color: var(--bg-secondary);
border-radius: 6px;
border-left: 3px solid var(--accent);
}
.usage-section {
margin-bottom: 0.75rem;
}
.usage-section:last-child {
margin-bottom: 0;
}
.usage-section h4 {
margin: 0 0 0.25rem 0;
font-size: 0.8rem;
font-weight: 600;
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}
.usage-list {
margin: 0;
padding: 0;
list-style: none;
}
.usage-list li {
padding: 0.25rem 0;
}
.usage-list code {
font-size: 0.8125rem;
background-color: var(--code-bg);
padding: 0.125rem 0.375rem;
border-radius: 3px;
}
.usage-list a {
color: var(--accent);
text-decoration: none;
}
.usage-list a:hover {
text-decoration: underline;
}
/* Schema inline (for nested schemas without property wrapper) */
.schema-inline {
margin: 0.5rem 0;
}
/* Code blocks in descriptions */
.description pre {
background-color: var(--code-bg);
padding: 1rem;
border-radius: 6px;
overflow-x: auto;
margin: 0.75rem 0;
}
.description pre code {
background: none;
padding: 0;
color: var(--text-primary);
}
/* Scrollbar styling for dark mode */
@media (prefers-color-scheme: dark) {
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
}
}
/* Print styles */
@media print {
.header {
position: static;
}
.sidebar {
display: none;
}
.layout {
grid-template-columns: 1fr;
}
.search-container {
display: none;
}
details {
display: block !important;
}
details > summary {
display: none;
}
details > *:not(summary) {
display: block !important;
}
}