Overview
The Legacy JSON generator produces the legacy version of the API documentation in JSON format. This generator maintains backward compatibility with existing tools while newer JSON schemas are being developed.Metadata
Generator identifier
Generator version
Requires metadata generator output as input
Supports parallel processing for improved performance
Configuration
Git reference (branch/tag) for source links
Enable JSON minification (removes whitespace)
Output directory path for generated JSON files
Output Format
The generator produces:- JSON files: One per API module (e.g.,
http.json,fs.json) - Format: Legacy schema structure for backward compatibility
- Indentation: 2 spaces (unless minified)
Usage
Dependency Chain
- ast - Parses Markdown to AST
- metadata - Extracts API metadata
- legacy-json - Converts to legacy JSON format
Implementation Details
The generator:- Groups nodes by module using
groupNodesByModule - Filters for depth-1 heading nodes (top-level modules)
- Processes chunks in parallel using worker threads
- Builds JSON sections using
buildSectionutility - Converts to legacy JSON format via
legacyToJSON - Streams results as they complete
Parallel Processing
TheprocessChunk function runs in worker threads:
- Takes pre-grouped module entries to avoid redundant processing
- Builds sections for assigned modules
- Returns JSON-ready objects
Performance Optimization
The generator optimizes performance by:- Pre-grouping entries to avoid sending all ~4900+ entries to each worker
- Streaming chunks as they complete for immediate file writing
- Using worker threads for CPU-intensive JSON building
src/generators/legacy-json/