# Documentation System [← Script Management](Script-Management.md) | [Home](Home.md) | [Team Workflows →](Team-Workflows.md) --- ## Table of Contents - [Overview](#overview) - [Inline Documentation](#inline-documentation) - [Markdown Documentation](#markdown-documentation) - [Documentation Commands](#documentation-commands) - [Best Practices](#best-practices) - [Examples](#examples) - [Next Steps](#next-steps) ## Overview DotRun features a comprehensive documentation system: - **Inline Docs**: Embedded documentation in scripts using `### DOC` blocks - **Markdown Files**: Standalone documentation in the `docs/` directory - **Auto-rendering**: View formatted docs with `dr help` command - **Cross-references**: Link between scripts and documentation ## Inline Documentation ### Basic Structure Every script should include a `### DOC` block: ```bash #!/usr/bin/env bash ### DOC # Script Name - Brief Description # # Detailed description of what this script does, # why it exists, and when to use it. # # Usage: dr scriptname [options] [arguments] # # Options: # -h, --help Show this help message # -v, --verbose Enable verbose output # # Arguments: # arg1 Description of first argument # arg2 Optional second argument # # Examples: # dr scriptname arg1 # dr scriptname -v arg1 arg2 ### DOC # Script implementation... ``` ### Documentation Sections #### Required Sections 1. **Script name and brief description** 2. **Usage syntax** 3. **At least one example** #### Recommended Sections ```bash ### DOC # Script Name - Brief description # # Description: # Detailed explanation of the script's purpose # # Usage: dr scriptname [options] arguments # # Options: # -h, --help Show help # -f, --force Force operation # -n, --dry-run Preview changes # # Arguments: # input Input file or directory # output Output location (optional) # # Examples: # dr scriptname input.txt # dr scriptname -f input.txt output.txt # dr scriptname --dry-run directory/ # # Environment Variables: # CONFIG_PATH Path to configuration (default: ~/.config) # API_KEY Required API key for external service # # Dependencies: # - curl: For API requests # - jq: For JSON processing # # Exit Codes: # 0 Success # 1 General error # 2 Invalid arguments # 3 Missing dependencies # # Notes: # - Requires internet connection # - Creates backup before processing # # See Also: # - dr related-script # - Documentation: docs/detailed-guide.md ### DOC ``` ### Advanced Documentation #### Categorization ```bash ### DOC # Category: deployment # Subcategory: kubernetes # Tags: k8s, deploy, production # # Deploy to Kubernetes - Production deployment script # ... ### DOC ``` #### Version Information ```bash ### DOC # Script: deploy-production # Version: 2.1.0 # Author: Team Name # Last Modified: 2024-01-15 # # Changelog: # 2.1.0 - Add multi-region support # 2.0.0 - Breaking: New config format # 1.0.0 - Initial release # ... ### DOC ``` #### Complex Examples ```bash ### DOC # Examples: # # Basic usage: # dr deploy-app myapp # # With environment: # ENV=staging dr deploy-app myapp # # Full options: # dr deploy-app \ # --environment production \ # --region us-east-1 \ # --version 1.2.3 \ # --rollback-on-failure \ # myapp # # Using config file: # dr deploy-app --config deploy.yml myapp ### DOC ``` ## Markdown Documentation ### Creating Documentation ```bash # Create new documentation dr doc create getting-started # Create with category dr doc create guides/deployment # Create from template dr doc create api-guide --template=api-doc ``` ### Documentation Structure ``` ~/.config/dotrun/docs/ ├── README.md # Main documentation index ├── getting-started.md # Quick start guide ├── guides/ # Categorized guides │ ├── deployment.md │ ├── testing.md │ └── troubleshooting.md ├── references/ # Reference documentation │ ├── api.md │ └── configuration.md └── examples/ # Example documentation ├── basic-workflows.md └── advanced-usage.md ``` ### Markdown Templates Create a documentation template: ````markdown # {{TITLE}} ## Overview Brief description of the topic. ## Table of Contents - [Prerequisites](#prerequisites) - [Getting Started](#getting-started) - [Configuration](#configuration) - [Usage](#usage) - [Examples](#examples) - [Troubleshooting](#troubleshooting) - [Related Documentation](#related-documentation) ## Prerequisites What you need before starting. ## Getting Started Step-by-step introduction. ## Configuration Configuration options and setup. ## Usage Detailed usage instructions. ## Examples ### Example 1: Basic Usage ```bash # Example command dr example-script ``` ```` ### Example 2: Advanced Usage ```bash # Advanced example dr example-script --option value ``` ## Troubleshooting Common issues and solutions. ## Related Documentation - [Related Guide](related-guide.md) - Script: `dr help scriptname` ```` ### Linking Scripts and Docs Reference documentation from scripts: ```bash ### DOC # Script Name # # Brief description # # For detailed information, see: # dr doc view deployment-guide # # Related documentation: # - docs/guides/deployment.md # - docs/troubleshooting.md ### DOC ```` Reference scripts from documentation: ```markdown ## Related Scripts - `dr deploy-staging` - Deploy to staging environment - `dr deploy-production` - Deploy to production - `dr rollback` - Rollback deployment Run `dr help