kidoc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesekidoc — Engineering Documentation Skill
kidoc — 工程文档生成Skill
Generate professional engineering documentation from KiCad project files.
从KiCad项目文件生成专业工程文档。
Quick Start
快速开始
One command generates the full scaffold — analyses, diagrams, renders, and markdown are all produced automatically:
bash
python3 skills/kidoc/scripts/kidoc_scaffold.py \
--project-dir /path/to/kicad/project \
--type hdd \
--output reports/HDD.mdThis auto-detects and files, runs schematic/PCB/EMC/thermal analyses, generates block diagrams and schematic SVG renders, and produces a structured markdown scaffold with pre-filled data tables and narrative placeholders.
.kicad_sch.kicad_pcbTo produce a PDF:
bash
python3 skills/kidoc/scripts/kidoc_generate.py \
--project-dir /path/to/kicad/project \
--doc reports/HDD.md \
--format pdfCreates automatically on first run (PDF/DOCX/ODT only — HTML is zero-dep).
reports/.venv/只需一条命令即可生成完整框架——分析内容、图表、渲染图和Markdown文件均自动生成:
bash
python3 skills/kidoc/scripts/kidoc_scaffold.py \
--project-dir /path/to/kicad/project \
--type hdd \
--output reports/HDD.md该命令会自动检测和文件,运行原理图/PCB/EMC/热分析,生成框图和原理图SVG渲染图,并生成带有预填充数据表和叙述占位符的结构化Markdown框架。
.kicad_sch.kicad_pcb要生成PDF文档:
bash
python3 skills/kidoc/scripts/kidoc_generate.py \
--project-dir /path/to/kicad/project \
--doc reports/HDD.md \
--format pdf首次运行时会自动创建目录(仅PDF/DOCX/ODT格式需要——HTML格式无依赖)。
reports/.venv/Workflow
工作流程
- Generate scaffold — auto-runs all available analyses, renders schematics, generates diagrams, and writes the markdown scaffold.
kidoc_scaffold.py - Fill narratives — The agent reads the scaffold and writes engineering prose for each placeholder. The engineer reviews and edits.
<!-- NARRATIVE: section_name --> - Regenerate — On re-run, data sections between markers update from fresh analysis; user-written narrative content is preserved.
<!-- GENERATED: section_id --> - Render output — produces PDF, HTML, DOCX, or ODT.
kidoc_generate.py
- 生成框架 — 会自动运行所有可用分析、渲染原理图、生成图表,并写入Markdown框架。
kidoc_scaffold.py - 填充叙述内容 — Agent会读取框架并为每个占位符编写工程文案。工程师可进行审核和编辑。
<!-- NARRATIVE: section_name --> - 重新生成 — 再次运行时,标记之间的数据部分会根据最新分析结果更新;用户编写的叙述内容将被保留。
<!-- GENERATED: section_id --> - 渲染输出 — 可生成PDF、HTML、DOCX或ODT格式文件。
kidoc_generate.py
Document Types
文档类型
| Type | Name | Key Sections |
|---|---|---|
| Hardware Design Description | System overview, power, signals, analog, thermal, EMC, PCB, mechanical, BOM, test, compliance |
| CE Technical File | Product ID, essential requirements, harmonized standards, risk assessment, Declaration of Conformity |
| Design Review Package | Review summary (cross-analyzer scores), findings, action items |
| Interface Control Document | Interface list, per-connector pinout details, electrical characteristics |
| Manufacturing Transfer Package | Assembly overview, PCB fab notes, assembly instructions, test procedures |
| Schematic Review Report | System overview, power, signals, analog, BOM, schematic appendix |
| Power Analysis Report | Power design, thermal, EMC, BOM |
| EMC Pre-Compliance Report | EMC analysis, compliance, schematic appendix |
| 类型 | 名称 | 核心章节 |
|---|---|---|
| 硬件设计说明(HDD) | 系统概述、电源、信号、模拟电路、热设计、EMC、PCB、机械结构、物料清单(BOM)、测试、合规性 |
| CE技术文件 | 产品ID、基本要求、协调标准、风险评估、符合性声明 |
| 设计评审包 | 评审总结(跨分析器评分)、发现问题、行动项 |
| 接口控制文档(ICD) | 接口列表、每个连接器的引脚细节、电气特性 |
| 制造转移包 | 装配概述、PCB制造说明、装配指导、测试流程 |
| 原理图评审报告 | 系统概述、电源、信号、模拟电路、BOM、原理图附录 |
| 电源分析报告 | 电源设计、热设计、EMC、BOM |
| EMC预合规报告 | EMC分析、合规性、原理图附录 |
Custom Reports
自定义报告
Use to generate reports with arbitrary section ordering:
--specbash
python3 skills/kidoc/scripts/kidoc_scaffold.py \
--project-dir . --spec my-report.json --output reports/custom.mdSpec format (JSON):
json
{
"type": "custom",
"title": "USB Interface Analysis",
"sections": [
{"id": "front_matter", "type": "front_matter"},
{"id": "signal_interfaces", "type": "signal_interfaces"},
{"id": "bom", "type": "bom_summary"}
]
}Each section's must match a known section type (same names used in the document types table above). The field is a unique key for that section instance.
typeidTo see the full default spec for any built-in type:
bash
python3 skills/kidoc/scripts/kidoc_spec.py --expand hdd
python3 skills/kidoc/scripts/kidoc_spec.py --listThe flag also works with (uses the spec title as fallback project name).
--speckidoc_generate.py使用参数可生成任意章节顺序的报告:
--specbash
python3 skills/kidoc/scripts/kidoc_scaffold.py \
--project-dir . --spec my-report.json --output reports/custom.md配置文件格式(JSON):
json
{
"type": "custom",
"title": "USB Interface Analysis",
"sections": [
{"id": "front_matter", "type": "front_matter"},
{"id": "signal_interfaces", "type": "signal_interfaces"},
{"id": "bom", "type": "bom_summary"}
]
}每个章节的必须匹配已知章节类型(与上述文档类型表格中使用的名称一致)。字段是该章节实例的唯一标识。
typeid要查看任何内置类型的完整默认配置:
bash
python3 skills/kidoc/scripts/kidoc_spec.py --expand hdd
python3 skills/kidoc/scripts/kidoc_spec.py --list--speckidoc_generate.pySchematic and PCB Rendering
原理图与PCB渲染
Rendering is integrated into the figure generation engine. The orchestrator and scaffold automatically render schematics and PCB views as part of document generation:
bash
undefined渲染功能已集成到图表生成引擎中。编排器和框架会在文档生成过程中自动渲染原理图和PCB视图:
bash
undefinedGenerate all figures (diagrams + schematic/PCB renders) from analysis JSON
Generate all figures (diagrams + schematic/PCB renders) from analysis JSON
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --output reports/figures/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --output reports/figures/
Full orchestration with spec, analysis, and project files
Full orchestration with spec, analysis, and project files
python3 skills/kidoc/scripts/kidoc_orchestrator.py --analysis schematic.json
--project-dir . --output reports/figures/
--project-dir . --output reports/figures/
The figure generators support: full-sheet rendering (root + all sub-sheets), subsystem cropping (`focus_refs` in spec sections), net highlighting, pin-level net annotation, and all PCB layer presets. These options are configured in the document spec or passed through the analysis dict.
Rendering features available through the generator framework:
- **Crop**: Focus on a subsystem bounding box around specific component refs
- **Focus/dim**: Show focused components at full opacity, dim the rest to 15%
- **Highlight nets**: Color-trace specific nets via BFS
- **Pin nets**: Annotate pin-level net names at pin tips
For direct programmatic access, use `figures.renderers`:
```python
from figures.renderers import render_schematic, render_pcb
render_schematic('design.kicad_sch', 'output/', crop_refs=['R1', 'R2'], highlight_nets=['VCC'])
render_pcb('board.kicad_pcb', 'output/', preset_name='assembly-front')Layer presets:
| Preset | Shows |
|---|---|
| Front silk, fab, pads, outline |
| Back silk, fab, pads, outline (mirrored) |
| Front copper, pads, vias, outline |
| Back copper, pads, vias, outline |
| All copper layers, pads, vias, zones |
| Power planes, vias, zone outlines |
Additional options: , , , , (callout boxes with leader lines).
--highlight-nets--crop-refs--crop x,y,w,h--mirror--overlay annotations.jsonpython3 skills/kidoc/scripts/kidoc_orchestrator.py --analysis schematic.json
--project-dir . --output reports/figures/
--project-dir . --output reports/figures/
图表生成器支持:全页渲染(根页及所有子页)、子系统裁剪(配置文件章节中的`focus_refs`)、网络高亮、引脚级网络标注,以及所有PCB层预设。这些选项可在文档配置文件中设置,或通过分析字典传递。
通过生成器框架可使用以下渲染特性:
- **裁剪**:聚焦于特定组件参考编号周围的子系统边界框
- **焦点/调暗**:以完全不透明度显示聚焦组件,其余组件调暗至15%
- **网络高亮**:通过广度优先搜索(BFS)为特定网络添加颜色追踪
- **引脚网络**:在引脚末端标注引脚级网络名称
如需直接通过编程访问,可使用`figures.renderers`:
```python
from figures.renderers import render_schematic, render_pcb
render_schematic('design.kicad_sch', 'output/', crop_refs=['R1', 'R2'], highlight_nets=['VCC'])
render_pcb('board.kicad_pcb', 'output/', preset_name='assembly-front')Block Diagrams
层预设
bash
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --all --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --power-tree --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --bus-topology --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --architecture --output diagrams/Generated from schematic analysis JSON. Power trees show regulator topology with inductor values, capacitor summaries, and output voltages.
| 预设名称 | 显示内容 |
|---|---|
| 正面丝印、制造层、焊盘、轮廓 |
| 背面丝印、制造层、焊盘、轮廓(镜像) |
| 正面铜层、焊盘、过孔、轮廓 |
| 背面铜层、焊盘、过孔、轮廓 |
| 所有铜层、焊盘、过孔、敷铜区 |
| 电源层、过孔、敷铜区轮廓 |
附加选项:、、、、(带引线的标注框)。
--highlight-nets--crop-refs--crop x,y,w,h--mirror--overlay annotations.jsonOutput Formats
框图
| Format | SVG Handling | Dependencies |
|---|---|---|
| Markdown | Image references | Zero-dep |
| HTML | Inlined as vector | Zero-dep |
| Vector via svglib, custom converter fallback, raster fallback | Venv ( | |
| DOCX | Rasterized to 300 DPI PNG | Venv |
| ODT | Rasterized to 300 DPI PNG | Venv |
PDF output includes a styled cover page, table of contents, formatted tables with alternating rows, and vector SVG diagrams.
bash
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --all --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --power-tree --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --bus-topology --output diagrams/
python3 skills/kidoc/scripts/kidoc_diagrams.py --analysis schematic.json --architecture --output diagrams/基于原理图分析JSON生成。电源树显示稳压器拓扑结构,包含电感值、电容汇总和输出电压。
Configuration
输出格式
Report settings live in under the key. Config files cascade: (user-level defaults, e.g. company branding) merges with project-level config.
.kicad-happy.json"reports"~/.kicad-happy.jsonjsonc
{
"project": {
"name": "Widget Board",
"number": "HW-2024-042",
"revision": "1.2",
"company": "Acme Electronics",
"author": "Jane Smith",
"market": "eu"
},
"reports": {
"classification": "Company Confidential",
"documents": [
{"type": "hdd", "output": "HDD-{project}-{rev}", "formats": ["pdf", "docx"]}
],
"branding": {
"logo": "templates/logo.png",
"header_left": "{company}",
"header_right": "{number} Rev {rev}"
}
}
}| 格式 | SVG处理方式 | 依赖项 |
|---|---|---|
| Markdown | 图片引用 | 无依赖 |
| HTML | 内联为矢量 | 无依赖 |
| 通过svglib实现矢量嵌入,自定义转换器备选,光栅化备选 | 虚拟环境( | |
| DOCX | 光栅化为300 DPI PNG | 虚拟环境 |
| ODT | 光栅化为300 DPI PNG | 虚拟环境 |
PDF输出包含样式化封面、目录、带交替行的格式化表格,以及矢量SVG图表。
Writing Narratives
配置
After generating a scaffold, fill the narrative placeholder sections with engineering prose.
报告设置存储在文件的键下。配置文件会级联合并:(用户级默认配置,如公司品牌)会与项目级配置合并。
.kicad-happy.json"reports"~/.kicad-happy.jsonjsonc
{
"project": {
"name": "Widget Board",
"number": "HW-2024-042",
"revision": "1.2",
"company": "Acme Electronics",
"author": "Jane Smith",
"market": "eu"
},
"reports": {
"classification": "Company Confidential",
"documents": [
{"type": "hdd", "output": "HDD-{project}-{rev}", "formats": ["pdf", "docx"]}
],
"branding": {
"logo": "templates/logo.png",
"header_left": "{company}",
"header_right": "{number} Rev {rev}"
}
}
}Workflow
编写叙述内容
-
Run the context builder to get focused data for each section:bash
python3 skills/kidoc/scripts/kidoc_narrative.py \ --analysis analysis/schematic.json \ --section power_designOr build contexts for all narrative sections at once:bashpython3 skills/kidoc/scripts/kidoc_narrative.py \ --analysis analysis/schematic.json \ --report reports/HDD.md -
For each section, read the context and write prose that:
- Explains why, not just what — engineering rationale, tradeoffs
- References specific component values and part numbers
- Uses quantitative language ("2.3ms hold-up time" not "adequate capacitance")
- Flags deviations from datasheet recommendations
- References SPICE validation results when available
-
Replace the italic placeholderin the markdown with real prose.
*[...]* -
On regeneration, data tables update automatically. Review narratives for consistency with any changed data.
生成框架后,为叙述占位符章节填充工程文案。
Style Guide
工作流程
Write as a senior EE explaining to a peer:
- Lead with the key finding or decision
- Support with specific numbers from the analysis
- Note any risks or deviations
- Keep paragraphs to 3-5 sentences
- Don't repeat data that's already in tables
-
运行上下文构建器,获取每个章节的聚焦数据:bash
python3 skills/kidoc/scripts/kidoc_narrative.py \ --analysis analysis/schematic.json \ --section power_design或者一次性为所有叙述章节构建上下文:bashpython3 skills/kidoc/scripts/kidoc_narrative.py \ --analysis analysis/schematic.json \ --report reports/HDD.md -
针对每个章节,阅读上下文并编写文案,需:
- 解释原因,而非仅说明内容——包括工程原理、权衡取舍
- 引用特定组件值和零件编号
- 使用量化表述(如“2.3ms保持时间”而非“足够的电容”)
- 标记与 datasheet 推荐的偏差
- 如有可用,引用SPICE验证结果
-
将Markdown中的斜体占位符替换为真实文案。
*[...]* -
重新生成时,数据表会自动更新。需检查叙述内容与更新后数据的一致性。
Requirements
风格指南
- Python 3.9+ with (for PDF/DOCX/ODT generation)
python3-venv - KiCad schematic file (, KiCad 6+) — for SVG rendering
.kicad_sch - Optional: Analysis JSONs are auto-generated from /
.kicad_sch; pre-generated JSONs in.kicad_pcb(or the path configured inanalysis/) are used if present. Generated figures (diagrams, schematic SVGs) are placed in.kicad-happy.jsonfor git trackingreports/figures/
以资深电子工程师向同行讲解的口吻撰写:
- 开篇点明核心结论或决策
- 用分析得出的具体数据支撑内容
- 标注任何风险或偏差
- 段落控制在3-5句话
- 不要重复表格中已有的数据
Limitations
要求
- Schematic and PCB renderers support KiCad 6+ formats only (,
.kicad_sch).kicad_pcb - Narrative sections require the agent or manual authoring — the scaffold provides structure and data, not prose
- SPICE simulation results require manual simulation setup (not auto-run by scaffold)
- PDF vector SVG embedding uses svglib when available; falls back to raster if svglib cannot parse a particular SVG
- Python 3.9+ 并安装(用于PDF/DOCX/ODT生成)
python3-venv - KiCad原理图文件(,KiCad 6及以上版本)——用于SVG渲染
.kicad_sch - 可选:分析JSON会从/
.kicad_sch自动生成;如果.kicad_pcb目录(或analysis/中配置的路径)存在预先生成的JSON,则会使用这些文件。生成的图表(框图、原理图SVG)会放在.kicad-happy.json目录中,以便进行Git版本跟踪reports/figures/
Related Skills
局限性
| Skill | Relationship |
|---|---|
| Produces schematic/PCB/thermal analysis JSON consumed by scaffolds |
| Produces EMC analysis JSON for EMC sections |
| SPICE simulation results appear in analog design sections |
| BOM data appears in BOM summary sections |
Run the skill's analyzers first, then and if available. The scaffold auto-runs and analyses when source files are present, so manual pre-analysis is only needed for SPICE.
kicademcspicekicademc- 原理图和PCB渲染器仅支持KiCad 6及以上版本格式(、
.kicad_sch).kicad_pcb - 叙述章节需要Agent或人工编写——框架仅提供结构和数据,不生成文案
- SPICE仿真结果需要手动设置仿真(框架不会自动运行)
- PDF矢量SVG嵌入在svglib可用时使用;如果svglib无法解析特定SVG,则会回退到光栅化
—
相关Skill
—
| Skill | 关联关系 |
|---|---|
| 生成框架所使用的原理图/PCB/热分析JSON |
| 生成EMC章节所用的EMC分析JSON |
| SPICE仿真结果会出现在模拟设计章节中 |
| BOM数据会出现在BOM汇总章节中 |
先运行Skill的分析器,如有需要再运行和。当源文件存在时,框架会自动运行和分析,因此仅SPICE需要手动预分析。
kicademcspicekicademc