Introduction
mint-tsdocs transforms structured API data into beautiful Mintlify documentation through a multi-stage pipeline.
Core Libraries
The tool is built on three foundational libraries from Microsoft’s Rush Stack:ts-command-line
Command-line interface framework with typed parameters and actions
api-extractor-model
Loads
.api.json files into a traversable object model (ApiModel)tsdoc
Creates an Abstract Syntax Tree (AST) of documentation content
Component Layers
The codebase is organized into distinct layers, each with a specific responsibility:CLI Layer
Location:
src/cli/Parses user commands and initializes the documentation generation process.start.ts- Executable entry pointApiDocumenterCommandLine.ts- Main CLI parserBaseAction.ts- Common action functionalityMarkdownAction.ts- Mintlify-specific command implementation
Generation Layer
Location:
src/documenters/Orchestrates the conversion from API model to documentation pages.MarkdownDocumenter.ts- Core orchestrator (now modular)- Builds TSDoc AST for each page
- Delegates navigation to
NavigationManager - Integrates caching for performance optimization
Emission Layer
Location:
src/markdown/Serializes the TSDoc AST into Mintlify-compatible MDX.CustomMarkdownEmitter.ts- Mintlify-specific rendering with API resolution cachingMarkdownEmitter.ts- Base markdown functionality- Generates
<ParamField>and<ResponseField>components
Navigation Layer
Location:
src/navigation/Dedicated navigation management for Mintlify documentation.NavigationManager.ts- Hierarchical navigation generationdocs.jsonstructure management- Mintlify v4 compatibility
- API item categorization
Caching Layer
Location:
src/cache/Performance optimization through intelligent caching.CacheManager.ts- Centralized cache coordinationTypeAnalysisCache.ts- Caches expensive type parsing operationsApiResolutionCache.ts- Caches API model cross-reference resolution- LRU eviction with configurable sizes
Data Flow
Detailed Pipeline Flow
Detailed Pipeline Flow
1. CLI Parsing
User runsmint-tsdocs markdown ...start.tscreatesDocumenterCliinstance- CLI parser invokes
MarkdownAction.onExecuteAsync() - Parameters are validated and processed
2. API Model Building
BaseAction.buildApiModel() loads the API data:- Reads all
*.api.jsonfiles from input folder - Creates
ApiModelinstance - Loads each package into the model
- Applies
@inheritDocworkarounds
3. Document Generation
MarkdownDocumenter.generateFiles() orchestrates:- Deletes old output files
- Traverses API model recursively
- Calls
_writeApiItemPage()for each item - Builds TSDoc AST (not markdown strings!)
4. AST Construction
For each page,MarkdownDocumenter:- Creates
DocSectionroot node - Adds
DocHeadingfor titles - Creates
DocTablenodes for member lists - Builds
DocTableRowandDocTableCellfor each member - This AST represents semantic structure
5. MDX Emission
CustomMarkdownEmitter.emit() serializes the AST:- Traverses TSDoc AST recursively
- Identifies
DocTablenodes with properties/methods - Calls
DocumentationHelperfor type analysis - Generates Mintlify components
- Writes formatted MDX string
6. Navigation Update
NavigationManager.generateNavigation():- Reads existing
docs.json - Merges new page paths hierarchically
- Organizes by API item categories
- Supports Mintlify v4 tab structure
- Writes updated
docs.json
7. Cache Statistics
CacheManager.printStats() reports:- Type analysis cache performance
- API resolution cache performance
- Overall hit rates and usage
Key Components Deep Dive
MarkdownDocumenter
MarkdownDocumenter
The Central OrchestratorResponsibilities:
- File management (delete old, write new)
- API traversal (recursive iteration)
- AST construction (build document structure)
- Frontmatter generation (YAML blocks)
- Navigation management (docs.json updates)
_writeApiItemPage() - Generates a single documentation pageCustomMarkdownEmitter
CustomMarkdownEmitter
The Mintlify RendererResponsibilities:
- TSDoc AST → MDX conversion
- Custom node rendering
- Mintlify component generation
- Link resolution
- Type analysis integration
DocTable conversion to <ParamField>/<ResponseField> componentsDocumentationHelper
DocumentationHelper
The Type AnalyzerResponsibilities:
- Parse TypeScript type strings
- Extract nested object properties
- Enrich with JSDoc descriptions
- Generate property metadata
analyzeTypeProperties() - Recursively analyzes complex typesNavigationManager
NavigationManager
CacheManager
CacheManager
The Performance OptimizerResponsibilities:
- Centralized cache coordination
- Type analysis caching (30-50% performance improvement)
- API resolution caching (20-40% performance improvement)
- LRU eviction with configurable sizes
- Hit rate monitoring and statistics
ObjectTypeAnalyzer
ObjectTypeAnalyzer
The Type Parser (now with caching)Handles all TypeScript type patterns:
- Primitives (
string,number) - Arrays (
string[]) - Unions (
A | B) - Intersections (
A & B) - Generics (
Promise<T>) - Object literals (
{ a: string; b: number })
TypeAnalysis objects for processingCustom TSDoc Nodes
We extend the standard TSDoc nodes with custom types:- DocHeading
- DocTable
- DocExpandable
- DocNoteBox
Represents section headings with levels (h1-h4)
How to Contribute
Understanding the pipeline helps you contribute effectively:Change MDX Output
Modify
CustomMarkdownEmitter or DocumentationHelperChange Page Structure
Modify
MarkdownDocumenter and AST constructionAdd CLI Options
Start in
MarkdownAction, pass to MarkdownDocumenterSupport New Types
Enhance
ObjectTypeAnalyzer type detectionArchitecture Diagrams
Next Steps
CLI Layer
Understand command-line parsing
Generation Layer
Learn about document generation
Emission Layer
Explore MDX rendering
Navigation Layer
Master navigation management
Caching Layer
Optimize performance with caching
Utilities
Discover helper utilities

