scripts/docs-cli/README.md
This directory contains command-line tools for working with the InfluxData documentation repository.
scripts/docs-cli/
├── README.md # This file
├── docs-cli.js # Main CLI entry point
├── docs-edit.js # Edit existing documentation
├── docs-create.js # Create new documentation
├── lib/ # CLI-specific modules
│ ├── editor-resolver.js # Smart editor selection
│ ├── process-manager.js # Process spawning (detached/attached)
│ └── url-parser.js # URL parsing utilities
└── __tests__/ # Unit tests
├── editor-resolver.test.js # Editor resolution tests
├── process-manager.test.js # Process management tests
└── run-tests.sh # Test runner script
The docs command is automatically configured when you run:
yarn install
This creates a symlink in node_modules/.bin/docs pointing to docs-cli.js.
docs edit - Edit Existing DocumentationOpens documentation files in your preferred editor. Non-blocking by default (agent-friendly).
# Quick edit (exits immediately, editor in background)
docs edit <url-or-path>
docs edit https://docs.influxdata.com/influxdb3/core/admin/
docs edit /influxdb3/core/admin/
# Interactive edit (waits for editor to close)
docs edit <url-or-path> --wait
# List files without opening
docs edit <url-or-path> --list
# Use specific editor
docs edit <url-or-path> --editor nano
--list - List files without opening editor--wait - Wait for editor to close (blocking mode)--editor <command> - Use specific editor (e.g., vim, nano, code --wait)The CLI selects an editor in this priority order:
--editor flagDOCS_EDITOR environment variableVISUAL environment variableEDITOR environment variableExamples:
# Set editor for all commands
export EDITOR=vim
# Set editor specifically for docs CLI
export DOCS_EDITOR=nano
# Use VS Code with built-in wait flag
export DOCS_EDITOR="code --wait"
docs create - Create New DocumentationScaffolds new documentation pages with proper frontmatter and structure.
# Create from draft file
docs create <draft-path> --products <product-key>
# Create at specific URL location
docs create --url <url> --from-draft <draft-path>
# Create and open files in editor (non-blocking)
docs create <draft-path> --products <product-key> --open
# Create and open files, wait for editor (blocking)
docs create <draft-path> --products <product-key> --open --wait
# Use specific editor
docs create <draft-path> --products <product-key> --open --editor nano
--open - Open created files in editor after creation (non-blocking by default)--wait - Wait for editor to close (use with --open)--editor <command> - Use specific editor (e.g., vim, nano, code --wait)--products <keys> - Comma-separated product keys--url <url> - Documentation URL for new content location--dry-run - Show what would be created without creating files--yes - Skip confirmation promptSee docs create --help for full options.
The --open flag uses the same editor resolution as docs edit:
--editor flagDOCS_EDITOR environment variableVISUAL environment variableEDITOR environment variableExamples:
# Set editor for docs CLI
export DOCS_EDITOR=nano
# Create and open in one command
docs create drafts/feature.md --products influxdb3_core --open
# Create, open, and wait
docs create drafts/feature.md --products influxdb3_core --open --wait
docs placeholders - Add Placeholder SyntaxAdds placeholder syntax to code blocks for interactive examples.
docs placeholders <file-path>
bash scripts/docs-cli/__tests__/run-tests.sh
node scripts/docs-cli/__tests__/editor-resolver.test.js
node scripts/docs-cli/__tests__/process-manager.test.js
# Test non-blocking mode (should exit immediately)
time docs edit /influxdb3/core/admin/ --editor echo
# Test blocking mode (should wait)
time docs edit /influxdb3/core/admin/ --wait --editor echo
# Test list mode
docs edit /influxdb3/core/admin/ --list
The docs edit command spawns the editor as a detached process and exits immediately. This prevents AI agents and automation scripts from hanging indefinitely.
Key modules:
lib/editor-resolver.js - Resolves the editor command from multiple sourceslib/process-manager.js - Spawns processes in detached (non-blocking) or attached (blocking) modeThe CLI supports both full URLs and path-only formats:
# Both of these work:
docs edit https://docs.influxdata.com/influxdb3/core/admin/
docs edit /influxdb3/core/admin/
The lib/url-parser.js module handles URL parsing and maps documentation URLs to source files in the repository.
When a page uses shared content (via the source frontmatter field), the CLI identifies both:
Both files are opened for editing.
This directory structure was created as part of fixing issue #21, where the docs edit command caused agents to hang waiting for the editor.
Changes:
--wait flag for interactive editing--editor flag for explicit editor selectionDocumentation:
When modifying these tools:
__tests__/bash scripts/docs-cli/__tests__/run-tests.shFor command-specific help:
docs --help
docs edit --help
docs create --help
For general documentation contribution guidelines, see DOCS-CONTRIBUTING.md.