PowerDocs CLI Developer Guide
PowerDocs CLI (powerdocs-cli) is a high-performance, standalone command-line tool designed to automate the production of publication-ready PDF documents from structured Markdown and YAML document plans.
Built with .NET 10 and compiled as a Native AOT binary, powerdocs-cli runs headlessly without any graphical interface or display server requirements. It is ideally suited for automated workflows, such as GitHub Actions, GitLab CI/CD, batch generation scripts, and containerized build environments.
Key Highlights
- Headless & CI/CD Native: Runs in server environments without X11, Wayland, or desktop dependencies.
- Native AOT Performance: Near-instant cold start (< 10 ms) and ultra-fast generation (~100 ms for multi-page documents).
- Plan-Driven Assembly: Assembles modular Markdown chapters into a unified document with automatic cover pages, table of contents, version changelog, and dynamic headers/footers.
- Deterministic Output: Produces identical PDF results to the desktop PowerDocs application.
Command Line Usage
Syntax
PowerDocs CLI supports both positional arguments and standard UNIX-style flags:
# Positional syntax
powerdocs-cli <plan.yml> <output.pdf> [options]
# Named flags syntax
powerdocs-cli -i <plan.yml> -o <output.pdf> [options]
Arguments & Options
| Argument / Option | Short | Description | Required | Default |
|---|---|---|---|---|
<plan.yml> |
-i, --input, --plan |
Path to the YAML document plan file | Yes | — |
<output.pdf> |
-o, --output |
Destination path for the generated PDF document | Yes | — |
--help |
-h, -? |
Displays the help and usage guide | No | — |
--version |
-v |
Displays the current version of PowerDocs CLI | No | — |
Exit Codes
| Exit Code | Meaning |
|---|---|
0 |
Success: Document generated successfully. |
1 |
Error: Missing mandatory arguments, source file not found, or generation failure. |
Document Plan Structure (.yml)
The document plan is a YAML file that outlines metadata, global layout settings, and the ordered sequence of items (chapters, Markdown files, summary, etc.).
Sample Document Plan
Title: System Architecture & Integration Guide
Author: Platform Engineering Team
Company: Coho Technologies
Classification: Internal - C2
CurrentVersion: 2.4
Watermark: CONFIDENTIAL
History:
- Version: 2.4
Date: 2026-09-01
Author: J. Doe
Change: Added disaster recovery and backup specifications
- Version: 2.3
Date: 2026-06-15
Author: A. Smith
Change: Initial system integration architecture
Header:
Left: "System Architecture Guide"
Right: "%CurrentVersion%"
Footer:
Left: "%Classification%"
Right: "Page %Page% / %Pages%"
Items:
- ItemType: CoverPage
- ItemType: Summary
- ItemType: ChangeLog
- ItemType: Chapter
ItemTitle: "1. Overview & Objectives"
- ItemType: File
ItemPath: "docs/01-overview.md"
- ItemType: Chapter
ItemTitle: "2. Technical Architecture"
- ItemType: File
ItemPath: "docs/02-architecture.md"
Supported Item Types
ItemType |
Properties | Description |
|---|---|---|
CoverPage |
— | Automatically generates a title page using Title, Author, Company, Classification, and CurrentVersion. |
Summary |
— | Generates an interactive Table of Contents with section titles and page numbers. |
ChangeLog |
— | Renders a revision history table populated from the History array. |
Chapter |
ItemTitle |
Inserts a main chapter title heading and page break. |
File |
ItemPath |
Reads and embeds a Markdown (.md) file. Relative paths are resolved against the directory containing the YAML plan. |
Item Key Aliases
ItemType, ItemPath and ItemTitle are the canonical keys: they are the ones written by the PowerDocs Document Plan
Editor, and the ones used throughout this documentation. For hand-written plans, the parser also accepts the following
aliases. Keys and item type values are case-insensitive.
| Canonical key | Accepted aliases |
|---|---|
ItemType |
Type |
ItemPath |
Path, FilePath, File |
ItemTitle |
Title, Titre, ChapterTitle |
Note
A Title key indented under an item always sets that item's title. It never overrides the document Title defined at
the root of the plan.
Header & Footer Dynamic Tokens
You can use placeholder tokens inside Header and Footer fields (Left, Center, Right):
| Token | Description |
|---|---|
%CurrentVersion% |
Replaced by the document's CurrentVersion. |
%Classification% |
Replaced by the document's Classification. |
%Author% |
Replaced by the document's Author. |
%Page% |
Replaced by the current page number. |
%Pages% |
Replaced by the total number of pages. |
%Date% |
Replaced by the generation date (YYYY-MM-DD). |
CI/CD Automation Examples
GitHub Actions Workflow
Below is an example workflow (.github/workflows/generate-docs.yml) that builds documentation on every push to main and uploads the resulting PDF as a build artifact:
name: Documentation Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-pdf:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Generate PDF Documentation
run: |
./tools/powerdocs/PowerDocs.Cli \
-i docs/plan.yml \
-o build/architecture-guide.pdf
- name: Upload PDF Artifact
uses: actions/upload-artifact@v4
with:
name: architecture-guide-pdf
path: build/architecture-guide.pdf
GitLab CI/CD Pipeline
Here is an equivalent .gitlab-ci.yml pipeline configuration:
stages:
- build-docs
generate_pdf:
stage: build-docs
script:
- ./tools/cli/PowerDocs.Cli docs/plan.yml build/architecture-guide.pdf
artifacts:
paths:
- build/*.pdf
expire_in: 1 week
Troubleshooting & Diagnostics
- Missing Markdown Files: If a file specified in
ItemPathcannot be found on disk,powerdocs-cliemits a warning to the console and continues rendering remaining sections without terminating with an error. - Missing YAML Plan: If the specified input plan file does not exist,
powerdocs-clioutputs an error tostderrand exits with code1. - Output Directory: If the target directory for the PDF output file does not exist,
powerdocs-cliautomatically creates it.