$npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-document-toolboxGenerates all documentation artifacts for a MATLAB toolbox: README.md, functionSignatures.json, GettingStarted.m, and publishable examples with demos.xml help integration. Follows mathworks/toolboxdesign best practices. Use when asked: "document this toolbox", "create documentati
| 1 | # matlab-document-toolbox — Toolbox Documentation Generator |
| 2 | |
| 3 | You produce all documentation artifacts needed for a well-documented MATLAB toolbox: README, function signatures, getting started guide, and examples. You follow the [mathworks/toolboxdesign](https://github.com/mathworks/toolboxdesign) conventions throughout. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - After `matlab-create-project` has set up the project structure |
| 8 | - User says "document this toolbox" or "add documentation" |
| 9 | - User says "create examples" or "generate function signatures" |
| 10 | - User says "getting started guide" or "README" |
| 11 | - Before `matlab-assess-toolbox` to satisfy documentation checks (1, 2, 10, 12, 15) |
| 12 | - User says "make this ready to share" |
| 13 | |
| 14 | ## When NOT to Use |
| 15 | |
| 16 | - Writing or fixing MATLAB code — this skill generates documentation only |
| 17 | - Building or packaging the toolbox — use `matlab-build-toolbox` |
| 18 | - Assessing readiness — use `matlab-assess-toolbox` (which may delegate here) |
| 19 | - Writing tests — tests are handled by test-generation skills, not documentation |
| 20 | |
| 21 | ## Inputs |
| 22 | |
| 23 | | Input | Required | Description | |
| 24 | |-------|----------|-------------| |
| 25 | | Project path | Yes | Absolute path to the toolbox project root | |
| 26 | | Scope | No | Which artifacts to generate: `all` (default), `readme`, `signatures`, `gettingstarted`, `examples` | |
| 27 | | Toolbox folder | No | Path to the distributable content folder (default: auto-detected — `toolbox/`, or project root if no `toolbox/` exists) | |
| 28 | |
| 29 | ## Rules |
| 30 | |
| 31 | - **NEVER overwrite existing files.** Before creating any file, check if it already exists. If it does, show what you'd change and ask the user. |
| 32 | - **Never move or rename existing files.** |
| 33 | - **Evidence-based only.** Only document functions that actually exist. Never fabricate function names, signatures, or descriptions. |
| 34 | - **Follow mathworks/toolboxdesign layout.** README at project root; `GettingStarted.m` in `toolbox/doc/` (or `doc/` if no `toolbox/` folder); examples in `toolbox/examples/` (or `examples/`); `functionSignatures.json` in `resources/` per placement rules. |
| 35 | - **Read-only until approved.** Present the full plan of what will be created, wait for user confirmation before writing anything. |
| 36 | |
| 37 | ## Workflow |
| 38 | |
| 39 | ### Step 1 — Discover Project Structure |
| 40 | |
| 41 | Scan the project to understand what exists: |
| 42 | |
| 43 | ``` |
| 44 | - Project root: README.md? license.txt? images/? |
| 45 | - Toolbox folder location: toolbox/ or project root? |
| 46 | - Existing docs: GettingStarted.m or GettingStarted.mlx? demos.xml? info.xml? |
| 47 | - Function signatures: resources/functionSignatures.json? |
| 48 | - Examples: examples/ folder? *.m or *.mlx examples? |
| 49 | - Source files: .m functions (public, private, internal, namespaced) |
| 50 | - Contents.m: authoritative function list and categories? |
| 51 | ``` |
| 52 | |
| 53 | Determine the toolbox folder: |
| 54 | 1. If `toolbox/` subfolder exists → that's the toolbox folder (design-guidelines layout) |
| 55 | 2. Otherwise → the project root IS the toolbox folder (flat layout) |
| 56 | |
| 57 | ### Step 2 — Analyze Functions |
| 58 | |
| 59 | For each `.m` file in the toolbox folder: |
| 60 | - Extract function name, signature, H1 line, input/output arguments |
| 61 | - Read `arguments` blocks for type constraints and validators |
| 62 | - Classify: public (on path), private (`private/`), internal (`internal/` or `+pkg.internal`), namespaced (`+pkg/`) |
| 63 | - Identify categories from `Contents.m`, folder structure, or function themes |
| 64 | - Note which functions are scripts vs. functions vs. classdefs |
| 65 | |
| 66 | ### Step 3 — Present Plan |
| 67 | |
| 68 | Show the user what will be generated: |
| 69 | |
| 70 | ``` |
| 71 | ## Documentation Plan — [Toolbox Name] |
| 72 | |
| 73 | ### Artifacts to Generate |
| 74 | |
| 75 | | # | Artifact | Location | Status | |
| 76 | |---|----------|----------|--------| |
| 77 | | 1 | README.md | <root>/README.md | NEW / EXISTS (skip) | |
| 78 | | 2 | functionSignatures.json | <toolbox>/resources/functionSignatures.json | NEW / EXISTS (merge?) | |
| 79 | | 3 | GettingStarted.m | <toolbox>/doc/GettingStarted.m | NEW / EXISTS (skip) / .mlx EXISTS (skip) | |
| 80 | | 4 | Examples (N scripts) | <toolbox>/examples/ | NEW | |
| 81 | | 5 | demos.xml | <toolbox>/examples/demos.xml | NEW | |
| 82 | |
| 83 | ### Functions Covered |
| 84 | |
| 85 | | Function | Category | Example? | Signature Entry? | |
| 86 | |----------|----------|----------|-----------------| |
| 87 | | add | Arithmetic | Yes | Yes | |
| 88 | | multiply | Arithmetic | Yes | Yes | |
| 89 | | helperFormat | (internal) | No | No | |
| 90 | |
| 91 | Which artifacts to generate? |
| 92 | > A) **All** — generate everything listed above |
| 93 | > B) **Select** — pick specific artifact numbers (e.g., "1, 2, 5") |
| 94 | > C) **Skip existing** — generate only NEW artifacts, skip those marked EXISTS |
| 95 | ``` |
| 96 | |
| 97 | Wait for user confirmation before generating anything. |
| 98 | |
| 99 | ## |