|
| 1 | +--- |
| 2 | +name: new-doc |
| 3 | +description: Scaffold a new document for an existing software product, creating all required directories, boilerplate files, page registrations, and header nav entries. |
| 4 | +--- |
| 5 | + |
| 6 | +# New Doc |
| 7 | + |
| 8 | +Interactively scaffold a new document within an existing software product on the RMC documentation site. |
| 9 | + |
| 10 | +**Arguments:** `$ARGUMENTS` — optional. If provided, use as hints for the prompts below (e.g., a document title or path). Still confirm each value with the user before proceeding. |
| 11 | + |
| 12 | +## Step 1: Gather Information via Interactive Prompts |
| 13 | + |
| 14 | +Prompt the user for each of the following values, one at a time. Show sensible defaults where possible. Do NOT proceed until all values are confirmed. |
| 15 | + |
| 16 | +### 1a — Category |
| 17 | + |
| 18 | +Ask: "Which category does this document belong to?" |
| 19 | + |
| 20 | +Present these options: |
| 21 | +1. **Desktop Applications** (`desktop-applications/`) |
| 22 | +2. **Toolbox Technical Manuals** (`toolbox-technical-manuals/`) |
| 23 | +3. **Web Applications** (`web-applications/`) |
| 24 | +4. **Developer Resources** (`dev/`) |
| 25 | + |
| 26 | +### 1b — Software Product |
| 27 | + |
| 28 | +Based on the selected category, list the existing software products by scanning the `docs/{category}/` directory for subdirectories. For toolbox documents, this is a two-level selection: first the suite (e.g., `internal-erosion-suite`), then the toolbox within it. |
| 29 | + |
| 30 | +For dev documents, scan `docs/dev/` for existing groupings (e.g., `dst`, `documentation-guide`, or top-level dev docs). |
| 31 | + |
| 32 | +Ask: "Which existing software product should this document belong to?" |
| 33 | + |
| 34 | +Present the available options. The user may also type a path if they know it. |
| 35 | + |
| 36 | +### 1c — Document Title |
| 37 | + |
| 38 | +Ask: "What is the title of the new document?" |
| 39 | + |
| 40 | +Example: "User's Guide", "Validation Studies", "Applications Guide", "Developer Guide", "Database Schema Reference" |
| 41 | + |
| 42 | +### 1d — Document Slug |
| 43 | + |
| 44 | +Auto-generate a kebab-case slug from the title (e.g., "User's Guide" → `users-guide`, "Validation Studies" → `validation-studies`). |
| 45 | + |
| 46 | +Ask: "I'll use the slug `{slug}` for directory names. Is that correct, or would you like a different slug?" |
| 47 | + |
| 48 | +### 1e — Version (non-dev only) |
| 49 | + |
| 50 | +If the category is NOT `dev/`: |
| 51 | +- Default to `v1.0` |
| 52 | +- Ask: "What version should this document start at? (default: v1.0)" |
| 53 | + |
| 54 | +If the category IS `dev/`: |
| 55 | +- Ask: "Should this document be versioned? Dev docs are typically unversioned. (default: no)" |
| 56 | +- If yes, ask for the version number (default `v1.0`) |
| 57 | +- If no, the files will live directly in the document directory (no version subfolder) |
| 58 | + |
| 59 | +### 1f — Active / Draft Status |
| 60 | + |
| 61 | +Ask: "Should this document be active (visible and clickable) or inactive (shows 'Coming Soon' badge)? (default: active)" |
| 62 | + |
| 63 | +Record both `active` (true/false) and `draft` (inverse of active) values. |
| 64 | + |
| 65 | +### 1g — File Structure (dev only) |
| 66 | + |
| 67 | +If the category is `dev/`: |
| 68 | +- Ask: "Dev documents often have custom structures. Would you like the standard structure (00-introduction.mdx as first chapter) or a custom structure? If custom, list the filenames you want created (e.g., 'prerequisites-and-ide-setup, project-structure, common-tasks')." |
| 69 | + |
| 70 | +### 1h — Header Nav |
| 71 | + |
| 72 | +Ask: "Should this document appear in the site header navigation? (default: yes for non-dev, no for dev)" |
| 73 | + |
| 74 | +### 1i — Confirmation |
| 75 | + |
| 76 | +Display a summary of all gathered values: |
| 77 | + |
| 78 | +``` |
| 79 | +Category: {category} |
| 80 | +Software: {software product} |
| 81 | +Document Title: {title} |
| 82 | +Document Slug: {slug} |
| 83 | +Version: {version or "unversioned"} |
| 84 | +Status: {active/inactive} |
| 85 | +Header Nav: {yes/no} |
| 86 | +Doc path: docs/{full/path} |
| 87 | +Figures path: static/figures/{full/path} |
| 88 | +Bibliography: static/bibliographies/{full/path}/bib.json |
| 89 | +``` |
| 90 | + |
| 91 | +Ask: "Does this look correct? (yes/no)" |
| 92 | + |
| 93 | +If no, ask which value to change and loop back to that prompt. |
| 94 | + |
| 95 | +## Step 2: Create Directory Structure |
| 96 | + |
| 97 | +### For non-dev versioned documents: |
| 98 | + |
| 99 | +Create these directories: |
| 100 | +``` |
| 101 | +docs/{category}/{software}/{slug}/v{version}/ |
| 102 | +static/figures/{category}/{software}/{slug}/v{version}/figures/ |
| 103 | +static/bibliographies/{category}/{software}/{slug}/v{version}/ |
| 104 | +``` |
| 105 | + |
| 106 | +For desktop-applications, also create an `inline-images/` directory alongside figures: |
| 107 | +``` |
| 108 | +static/figures/{category}/{software}/{slug}/v{version}/inline-images/ |
| 109 | +``` |
| 110 | + |
| 111 | +### For dev unversioned documents: |
| 112 | + |
| 113 | +Create these directories: |
| 114 | +``` |
| 115 | +docs/dev/{software}/{slug}/ |
| 116 | +``` |
| 117 | + |
| 118 | +Figures and bibliography directories are optional for dev docs — only create them if the user indicated they need figures or references. |
| 119 | + |
| 120 | +### For dev versioned documents: |
| 121 | + |
| 122 | +Same as non-dev but under the `dev/` path: |
| 123 | +``` |
| 124 | +docs/dev/{software}/{slug}/v{version}/ |
| 125 | +static/figures/dev/{software}/{slug}/v{version}/figures/ |
| 126 | +static/bibliographies/dev/{software}/{slug}/v{version}/ |
| 127 | +``` |
| 128 | + |
| 129 | +## Step 3: Create Boilerplate MDX Files |
| 130 | + |
| 131 | +### For non-dev documents, create these files: |
| 132 | + |
| 133 | +**`00-document-info.mdx`:** |
| 134 | +```mdx |
| 135 | +--- |
| 136 | +title: Document Info |
| 137 | +reportDate: {current month and year, e.g., "March 2026"} |
| 138 | +reportType: Computer Program Document |
| 139 | +reportTitle: {document title} |
| 140 | +reportSubTitle: {software product display name} |
| 141 | +reportAuthors: ['Enter author name, Risk Management Center'] |
| 142 | +reportAbstract: Enter report abstract. |
| 143 | +reportSubjectTerms: ['Term 1', 'Term 2'] |
| 144 | +responsiblePersonName: Enter name of responsible person |
| 145 | +responsiblePersonNumber: Enter phone number (xxx-xxx-xxxx) |
| 146 | +citationGuide: 'F. M. Last, <i>{document title}</i>, Lakewood, CO: U.S. Army Corps of Engineers, Risk Management Center, {current year}. Accessed on <i>\{enter current date here\}</i>.' |
| 147 | +--- |
| 148 | + |
| 149 | +import Link from '@docusaurus/Link'; |
| 150 | +import addBaseUrl from '@docusaurus/useBaseUrl'; |
| 151 | +import DocumentMetadata from '@site/src/components/DocumentMetadata'; |
| 152 | +import NavContainer from '@site/src/components/NavContainer'; |
| 153 | + |
| 154 | +<NavContainer |
| 155 | + link="{navContainerLink}" |
| 156 | + linkTitle="{navContainerLinkTitle}" |
| 157 | + document="{navContainerDocument}" |
| 158 | +/> |
| 159 | + |
| 160 | +# Document Information |
| 161 | + |
| 162 | +<DocumentMetadata metadata={frontMatter} /> |
| 163 | +``` |
| 164 | + |
| 165 | +Where: |
| 166 | +- `{navContainerLink}` is the software landing page path: |
| 167 | + - Desktop: `/desktop-applications/{software}` |
| 168 | + - Toolbox: `/toolboxes/{suite}` |
| 169 | + - Web: `/web-applications/{software}` |
| 170 | +- `{navContainerLinkTitle}` is the display name of the software product (e.g., "LifeSim", "Internal Erosion Suite") |
| 171 | +- `{navContainerDocument}` is the document path without version: `{category}/{software}/{slug}` |
| 172 | + |
| 173 | +**`00-version-history.mdx`:** |
| 174 | +```mdx |
| 175 | +--- |
| 176 | +title: Version History |
| 177 | +--- |
| 178 | + |
| 179 | +import Link from '@docusaurus/Link'; |
| 180 | +import NavContainer from '@site/src/components/NavContainer'; |
| 181 | +import TableVersionHistory from '@site/src/components/TableVersionHistory'; |
| 182 | + |
| 183 | +<NavContainer |
| 184 | + link="{navContainerLink}" |
| 185 | + linkTitle="{navContainerLinkTitle}" |
| 186 | + document="{navContainerDocument}" |
| 187 | +/> |
| 188 | + |
| 189 | +# Version History |
| 190 | + |
| 191 | +<TableVersionHistory |
| 192 | + versions={['{version number without v prefix, e.g., 1.0}']} |
| 193 | + dates={['{current month and year}']} |
| 194 | + descriptions={['Initial release as an online document.']} |
| 195 | + modifiedBy={['-']} |
| 196 | + reviewedBy={['-']} |
| 197 | + approvedBy={['-']} |
| 198 | +/> |
| 199 | +``` |
| 200 | + |
| 201 | +**`01-preface.mdx`:** |
| 202 | +```mdx |
| 203 | +--- |
| 204 | +title: 'Preface' |
| 205 | +--- |
| 206 | + |
| 207 | +import Link from '@docusaurus/Link'; |
| 208 | +import addBaseUrl from '@docusaurus/useBaseUrl'; |
| 209 | +import CitationFootnote from '@site/src/components/CitationFootnote'; |
| 210 | +import NavContainer from '@site/src/components/NavContainer'; |
| 211 | +import VersionSelector from '@site/src/components/VersionSelector'; |
| 212 | + |
| 213 | +<NavContainer |
| 214 | + link="{navContainerLink}" |
| 215 | + linkTitle="{navContainerLinkTitle}" |
| 216 | + document="{navContainerDocument}" |
| 217 | +/> |
| 218 | + |
| 219 | +# Preface |
| 220 | + |
| 221 | +{Placeholder: describe the purpose of this document and the software it covers.} |
| 222 | + |
| 223 | +## Contact Us |
| 224 | + |
| 225 | +For questions or concerns, please email [RMC.Software@usace.army.mil](mailto:RMC.Software@usace.army.mil). |
| 226 | + |
| 227 | +<CitationFootnote /> |
| 228 | +``` |
| 229 | + |
| 230 | +### For dev unversioned documents: |
| 231 | + |
| 232 | +If the user chose the standard structure, create: |
| 233 | + |
| 234 | +**`00-introduction.mdx`:** |
| 235 | +```mdx |
| 236 | +--- |
| 237 | +title: Introduction |
| 238 | +--- |
| 239 | + |
| 240 | +import NavContainer from '@site/src/components/NavContainer'; |
| 241 | + |
| 242 | +<NavContainer link="/dev" linkTitle="Developer Resources" /> |
| 243 | + |
| 244 | +# {Document Title} |
| 245 | + |
| 246 | +{Placeholder: introduce the purpose of this document.} |
| 247 | +``` |
| 248 | + |
| 249 | +If the user chose a custom structure, create each file they listed with the same pattern: |
| 250 | +- Sequential numbering starting at `01-` (since there's no `00-introduction.mdx` unless they listed one) |
| 251 | +- Each file gets minimal frontmatter (`title` only) and a `NavContainer` pointing to `/dev` |
| 252 | + |
| 253 | +### For dev versioned documents: |
| 254 | + |
| 255 | +Use the same templates as non-dev but with: |
| 256 | +- `navContainerLink`: `/dev` |
| 257 | +- `navContainerLinkTitle`: `Developer Resources` |
| 258 | +- `navContainerDocument`: `dev/{software}/{slug}` |
| 259 | + |
| 260 | +## Step 4: Create Empty Bibliography File |
| 261 | + |
| 262 | +For non-dev documents (and dev versioned documents that need one), create: |
| 263 | + |
| 264 | +**`static/bibliographies/{category}/{software}/{slug}/v{version}/bib.json`:** |
| 265 | +```json |
| 266 | +[] |
| 267 | +``` |
| 268 | + |
| 269 | +## Step 5: Register Document on Software Landing Page |
| 270 | + |
| 271 | +### For desktop-applications: |
| 272 | + |
| 273 | +Edit `src/pages/desktop-applications/{software}.js`: |
| 274 | +1. Find the data array (e.g., `const lifeSimData = [...]`) |
| 275 | +2. Add a new entry at the end of the array: |
| 276 | +```javascript |
| 277 | +{ |
| 278 | + icon: 'img/{SoftwareIcon}.png', |
| 279 | + preserveIconColor: true, |
| 280 | + doc_location: '{category}/{software}/{slug}', |
| 281 | + doc_name: '{Software Display Name} {Document Title}', |
| 282 | + active: {true/false}, |
| 283 | + draft: {true/false}, |
| 284 | +}, |
| 285 | +``` |
| 286 | + |
| 287 | +Use the same `icon` value as the other entries in the array. |
| 288 | + |
| 289 | +### For toolbox-technical-manuals: |
| 290 | + |
| 291 | +Edit `src/pages/toolboxes/{suite}.js`: |
| 292 | +1. Find the data array |
| 293 | +2. Add a new entry: |
| 294 | +```javascript |
| 295 | +{ |
| 296 | + IconComponent: ToolboxIcon, |
| 297 | + doc_location: 'toolbox-technical-manuals/{suite}/{slug}', |
| 298 | + doc_name: '{Document Title} Toolbox Technical Manual', |
| 299 | + active: {true/false}, |
| 300 | + draft: {true/false}, |
| 301 | +}, |
| 302 | +``` |
| 303 | + |
| 304 | +### For web-applications: |
| 305 | + |
| 306 | +Edit `src/pages/web-applications/{software}.js`: |
| 307 | +1. Find the data array |
| 308 | +2. Add a new entry following the same pattern as existing entries in that file |
| 309 | + |
| 310 | +### For dev: |
| 311 | + |
| 312 | +Edit `src/pages/dev.js`: |
| 313 | +1. Find the appropriate `contentCardData` array within `devData` based on the software grouping |
| 314 | +2. Add a new entry: |
| 315 | +```javascript |
| 316 | +{ |
| 317 | + IconComponent: CodeIcon, |
| 318 | + title: '{Document Title}', |
| 319 | + description: '{Brief description - ask user}', |
| 320 | + href: addBaseUrl('docs/dev/{software}/{slug}/{first-page-slug}'), |
| 321 | + active: {true/false}, |
| 322 | +}, |
| 323 | +``` |
| 324 | + |
| 325 | +For dev documents, ask the user: "What short description should appear on the dev landing page card?" |
| 326 | + |
| 327 | +Also ask: "Which existing group on the dev page should this document be listed under?" and show the existing group names from `devData` (e.g., "RMC Software Documentation Website Documentation Guide", "RMC Development Resources", "RMC Web Development", "Dam Screening Tool Documents"). If none fit, offer to create a new group. |
| 328 | + |
| 329 | +**Important:** For dev documents, the `href` must point to the actual first page of the document (e.g., `introduction` or the first custom file slug), not `preface`. |
| 330 | + |
| 331 | +## Step 6: Add to Header Navigation (if applicable) |
| 332 | + |
| 333 | +If the user chose to add the document to the header nav, edit `src/theme/Layout/buildNavLinks.js`: |
| 334 | + |
| 335 | +### Add a version variable (non-dev versioned docs only): |
| 336 | + |
| 337 | +In the appropriate section (Desktop Applications, Toolbox, Web Applications), add a new `const` for the document href: |
| 338 | +```javascript |
| 339 | +const {camelCaseVarName}Href = useBaseUrl( |
| 340 | + `/docs/{category}/{software}/{slug}/${latestVersions['{category}/{software}/{slug}'] || 'v{version}'}/preface`, |
| 341 | +); |
| 342 | +``` |
| 343 | + |
| 344 | +### Add to the links return structure: |
| 345 | + |
| 346 | +Find the parent software product's `children` array and add: |
| 347 | +```javascript |
| 348 | +{ |
| 349 | + id: '{slug}', |
| 350 | + text: '{Document Title}', |
| 351 | + href: {camelCaseVarName}Href, |
| 352 | +}, |
| 353 | +``` |
| 354 | + |
| 355 | +If the parent software product does not currently have a `children` array, add one. |
| 356 | + |
| 357 | +For dev documents, header nav is not applicable (dev is not in the header menu — it's only in the footer). |
| 358 | + |
| 359 | +## Step 7: Run Generation Scripts |
| 360 | + |
| 361 | +Run the build generation scripts to pick up the new document: |
| 362 | + |
| 363 | +```bash |
| 364 | +npm run sidebars && npm run counters && npm run versions |
| 365 | +``` |
| 366 | + |
| 367 | +Verify no errors occur. If errors occur, diagnose and fix. |
| 368 | + |
| 369 | +## Step 8: Verify |
| 370 | + |
| 371 | +1. Check that all created files exist using Glob |
| 372 | +2. Verify the software landing page JS file has the new entry |
| 373 | +3. If header nav was requested, verify the buildNavLinks.js changes |
| 374 | +4. Report a summary to the user: |
| 375 | + |
| 376 | +``` |
| 377 | +Document scaffolded successfully! |
| 378 | +
|
| 379 | +Created files: |
| 380 | + - docs/{full path}/00-document-info.mdx |
| 381 | + - docs/{full path}/00-version-history.mdx |
| 382 | + - docs/{full path}/01-preface.mdx |
| 383 | + - static/figures/{full path}/figures/ (empty) |
| 384 | + - static/bibliographies/{full path}/bib.json |
| 385 | +
|
| 386 | +Registered on: |
| 387 | + - {software page path} (active: {yes/no}) |
| 388 | + - Header nav: {yes/no} |
| 389 | +
|
| 390 | +Next steps: |
| 391 | + - Edit 00-document-info.mdx to fill in report metadata |
| 392 | + - Edit 01-preface.mdx to add your preface content |
| 393 | + - Add chapter files (02-*.mdx, 03-*.mdx, etc.) |
| 394 | + - Run `npm start` to preview locally |
| 395 | +``` |
0 commit comments