Overview
OpenDocs is built on five fundamental design principles that ensure flexibility, consistency, and ease of use across different programming languages and documentation needs. These principles guide every architectural decision and implementation choice.1. Universal Abstraction (DocItem)
Every documentation element, regardless of programming language, is represented as a DocItem:- Rust:
struct,trait,impl-method - Go:
struct,interface,receiver-method - TypeScript:
class,interface,method,property - Python:
class,function,property
2. Language-Specific Flexibility (DocItem.kind)
Thekind field allows complete language-specific typing without breaking the universal model:
- Templates can handle language-specific constructs appropriately
- Language-specific metadata is preserved
- The core model remains simple and consistent
3. Hierarchical Structure (Project → DocItem → DocItem)
Purpose: Supporting Monorepos The Project concept was specifically designed to support monorepos where a single Documentation Set contains multiple projects (packages, apps, libraries). Each Project represents a distinct documentable unit with its own language, version, and dependencies, while all projects share the same documentation structure. DocItems form natural hierarchies through theitems array, with Project as the root:
- Intuitive navigation structures
- Logical documentation grouping
- Efficient template rendering
4. Documentation Standardization (DocBlock)
All documentation formats map to the same DocBlock structure, enabling:- Consistent rendering across languages
- Template compatibility regardless of source format
- Cross-format documentation migration
- Unified tooling and processing
5. Tag Flexibility (DocTag)
Support for both simple and complex tags enables:- Simple metadata (
@since,@author) - Complex structured data (
@paramwith type and name) - Custom tag extensions for project-specific needs
- Common documentation patterns are handled efficiently
- Complex parameter documentation is fully supported
- Projects can extend the system with custom tags
- Both human-readable and machine-processable documentation coexist
Benefits of These Principles
For Documentation Authors
- Consistency: Write documentation once, use it everywhere
- Flexibility: Support for language-specific features
- Future-proof: Easy to add new languages or documentation formats
For Template Authors
- Simplicity: Single model to understand and work with
- Power: Access to rich metadata and relationships
- Extensibility: Support for custom tags and patterns
For Tool Developers
- Unified API: Consistent interface regardless of source language
- Rich Metadata: Comprehensive information for advanced features
- Performance: Efficient hierarchical processing and caching
Applying These Principles
When implementing OpenDocs support for a new language or extending the system:- Map language constructs to DocItems using appropriate
kindvalues - Preserve language-specific metadata in the
metadatafield - Maintain hierarchical relationships through proper parent-child linking
- Convert documentation formats to the standard DocBlock structure
- Support both simple and complex tags for maximum flexibility
Next Steps
- Learn about the OpenDocs Models to understand the concrete implementation of these principles
- Explore implementation guides for building OpenDocs support
- See examples of these principles in action

