|
| 1 | +# Documentation Maintenance Guide |
| 2 | + |
| 3 | +This file describes when and how to update the hds-lib-js documentation in `docs/`. |
| 4 | + |
| 5 | +## Structure |
| 6 | + |
| 7 | +``` |
| 8 | +docs/ (source, in repo) |
| 9 | +├── _config.yml # Jekyll configuration for gh-pages |
| 10 | +├── _layouts/ |
| 11 | +│ └── default.html # Custom layout (nav bar, mermaid support) |
| 12 | +├── index.md # Home: overview, architecture, export list |
| 13 | +├── getting-started.md # Installation, setup, browser/Node usage |
| 14 | +├── settings.md # Settings module reference |
| 15 | +├── hds-model.md # HDSModel, items, streams, authorizations, event types, datasources |
| 16 | +├── app-templates.md # Detailed App Templates guide (Manager, Collector, Invite, Client) |
| 17 | +├── localization.md # Localization utilities |
| 18 | +├── toolkit.md # StreamsAutoCreate, StreamTools |
| 19 | +├── utilities.md # Duration, reminders, errors, logger |
| 20 | +└── MAINTAIN-DOC.md # This file (excluded from Jekyll build) |
| 21 | +``` |
| 22 | + |
| 23 | +On build (`npm run build`), webpack copies docs flat into `dist/` alongside |
| 24 | +the JS bundles and test files. `dist/` is the gh-pages branch root — Jekyll |
| 25 | +processes it as a single flat site. |
| 26 | + |
| 27 | +## When to update |
| 28 | + |
| 29 | +### Always update docs when: |
| 30 | + |
| 31 | +1. **Adding a new public method/property** to any exported class |
| 32 | + - Add it to the relevant section with signature, description, and example |
| 33 | + - If it's in appTemplates, update `app-templates.md` |
| 34 | + |
| 35 | +2. **Changing method signatures** (parameters, return types) |
| 36 | + - Update the method documentation and any affected code examples |
| 37 | + |
| 38 | +3. **Adding a new module or class** |
| 39 | + - Create a new page if warranted, or add a section to the most relevant existing page |
| 40 | + - Update `index.md` exports table and architecture diagram |
| 41 | + - Add to `_config.yml` nav if it's a new page |
| 42 | + |
| 43 | +4. **Changing the appTemplates flow** (new statuses, new event types, new stream suffixes) |
| 44 | + - Update the sequence diagram, state diagrams, and SVG stream structure in `app-templates.md` |
| 45 | + |
| 46 | +5. **Changing CollectorRequest structure** (new properties, new section types) |
| 47 | + - Update the data structure diagram and property tables in `app-templates.md` |
| 48 | + |
| 49 | +6. **Adding or changing event types** |
| 50 | + - Update the event types table in `app-templates.md` and/or `hds-model.md` |
| 51 | + |
| 52 | +7. **Changing the data model integration** (new HDSModel sub-modules, new item properties) |
| 53 | + - Update `hds-model.md` |
| 54 | + |
| 55 | +### No doc update needed for: |
| 56 | + |
| 57 | +- Internal refactoring that doesn't change the public API |
| 58 | +- Bug fixes that don't change behavior |
| 59 | +- Test changes |
| 60 | +- Build/CI changes |
| 61 | + |
| 62 | +## How to update |
| 63 | + |
| 64 | +### Markdown conventions |
| 65 | + |
| 66 | +- Use Jekyll front matter (`---\nlayout: default\ntitle: ...\n---`) on every page |
| 67 | +- Use GitHub-Flavored Markdown (GFM) |
| 68 | +- Use fenced code blocks with language tags (`javascript`, `typescript`, `bash`) |
| 69 | +- Use Mermaid for flow/sequence/state diagrams (```mermaid blocks) |
| 70 | + |
| 71 | +### Diagrams |
| 72 | + |
| 73 | +- **ASCII trees** — Preferred for hierarchical/nested structures (stream structures, data models). They render everywhere, stay narrow, and are easy to edit. |
| 74 | +- **Mermaid** — Use for flowcharts, sequence diagrams, state machines. Rendered by GitHub and most Jekyll themes with mermaid support. |
| 75 | +- **Avoid inline SVG** — SVG does not render in most Markdown viewers (GitHub, Jekyll). Use ASCII or Mermaid instead. |
| 76 | +- Keep diagram source editable (no rasterized images for diagrams). |
| 77 | +- **Split complex diagrams** — When an architecture or overview diagram has multiple concerns (e.g., library modules + class relationships), split into separate graphs stacked vertically rather than one dense graph. This improves readability on all screen sizes. |
| 78 | + |
| 79 | +### Code examples |
| 80 | + |
| 81 | +- Every public method should have at least one usage example |
| 82 | +- Examples should be copy-pasteable and realistic |
| 83 | +- Use `const` and `await` consistently |
| 84 | +- Show typical output in comments where helpful |
| 85 | + |
| 86 | +### Adding a new page |
| 87 | + |
| 88 | +1. Create `docs/new-page.md` with Jekyll front matter (`layout: default`, `title: ...`) |
| 89 | +2. Add a nav link in `docs/_layouts/default.html` |
| 90 | +3. Add link to the table in `docs/index.md` |
| 91 | + |
| 92 | +## Publishing (gh-pages) |
| 93 | + |
| 94 | +The `dist/` directory is a separate git checkout on the `gh-pages` branch. |
| 95 | +Docs are copied flat into `dist/` by the webpack build alongside JS bundles. |
| 96 | + |
| 97 | +**Deploy workflow:** |
| 98 | +1. `npm run build` — compiles TS, bundles JS, copies docs to `dist/` |
| 99 | +2. `npm run deploy` — commits and pushes `dist/` to gh-pages |
| 100 | + |
| 101 | +Jekyll processes the gh-pages branch root. Our custom `_layouts/default.html` |
| 102 | +provides the nav bar and mermaid rendering (no remote theme dependency). |
| 103 | + |
| 104 | +**URL structure:** `https://healthdatasafe.github.io/hds-lib-js/{page}` |
| 105 | + |
| 106 | +## Versioning |
| 107 | + |
| 108 | +When the library version changes significantly, consider noting breaking changes at the top of affected pages. The docs track the current `main` branch — there is no versioned documentation (yet). |
| 109 | + |
| 110 | +## Checklist for doc PRs |
| 111 | + |
| 112 | +- [ ] Updated all affected pages |
| 113 | +- [ ] Code examples are correct and tested |
| 114 | +- [ ] Mermaid diagrams render (check on GitHub preview) |
| 115 | +- [ ] Nav links in `_layouts/default.html` are up to date |
| 116 | +- [ ] `index.md` exports table is up to date |
| 117 | +- [ ] No broken internal links |
0 commit comments