Reference documentation is generated from the source and published to the GitHub wiki¶
Context and Problem Statement¶
Bylaw is public and on the PowerShell Gallery, and its reference documentation is scattered. The five exported commands have comment-based help. The 30 keywords, such as Field, Must and Modify, have comment-based help too, but they are private functions (ADR-0005), so Get-Help and PlatyPS don't see them outside a Policy block. Bylaw emits 169 diagnostic codes, and only about 100 of them are mentioned in an ADR, some only as part of a range. The maintainer's other modules publish PlatyPS help to the GitHub wiki from their build. What does Bylaw publish, where does each page come from, and how does it stay correct?
Decision Drivers¶
- Every page is generated from the repository, so the wiki can't drift from the code.
- A user who meets a diagnostic can find what it means and how to fix it.
- Pages written by hand in the wiki, such as
Home, are never overwritten. - It works like the maintainer's other modules.
- A broken help block or catalogue entry fails CI on the pull request, not the wiki update on
main.
Considered Options¶
- Generated pages pushed to the wiki by the release job
- Documentation folder committed to the repository
- Hand-written wiki pages
Decision Outcome¶
Chosen option: "Generated pages pushed to the wiki by the release job".
Pages¶
- Commands: one page per exported command (
Build-Bylaw,Policy,Initiative,Update-BylawAliasCache,Update-BylawRoleCache), generated by PlatyPS from comment-based help. PlatyPS 0.12.0 is pinned inbuild/requirements.psd1, the version the other modules use. - Keywords: one page per keyword, generated from the keyword's comment-based help, read inside the module where the private functions are visible. The page layout matches the command pages: synopsis, syntax, description, parameters and examples. Each page also says which blocks the keyword can be used in.
- Diagnostics: one page per range:
BYL1xxx(front end),BYL2xxx(aliases),BYL3xxx(validation),BYL4xxx(output),BYL5xxx(build and settings) andBYL6xxx(ConvertTo-Bylaw), and aDiagnosticspage listing the ranges. Each code has a section, so it can be linked asDiagnostics-BYL3xxx#byl3029. - Navigation: a generated
_Sidebarlinks the commands, the keywords and the diagnostics.
The diagnostics catalogue¶
docs/diagnostics/holds one PowerShell data file per range. Each entry has the code, its severity (error or warning), a title, an explanation of what it means and why Bylaw checks it, how to fix it, and optionally a Bylaw example and the ADR it comes from.- A test checks that every code
srcemits has an entry, that every entry is still emitted, and that the severities match. A new diagnostic can't ship without its documentation, and a removed one can't linger.
Links from diagnostics¶
Added 2026-11-29:
- Each diagnostic has a
HelpUri, its section on the wiki, such as.../wiki/Diagnostics-BYL2xxx#byl2005. From 0.8, it is the same section on the documentation site for the installed version, such ashttps://bylaw.cloud/0.8/reference/Diagnostics-BYL2xxx/#byl2005(ADR-0048); the wiki keeps the pages that 0.5 to 0.7 link to. It is on the diagnostic objects that-PassThruandConvertTo-Bylawreturn. - Each diagnostic is shown as a block: a header with where it is and its code,
policies/storage.bylaw.ps1:12 [Field] BYL2005, then its message andSee <link>, indented below. The file is relative to the current folder when it is under it. A failed build is "Build failed with N errors:", then a block per error, separated by blank lines; a warning is one block. Changed 2026-11-30 from one line per diagnostic, with the links in a footer: a long path and message on one line pushed the code out of sight, and a link reads better beside its error, even when a code repeats. - The blocks are written to the host, errors in red and warnings with
Write-Warning, each followed by a blank line, rather than left to PowerShell's error view, which joins the lines of an error from a script, as in CI. The error record says where to look in one line: "Build failed with 2 errors, shown above.", or forConvertTo-Bylawthe block's header and "shown above". A build ends with one line saying what it built, where, how many files it wrote and how long it took, and a conversion with how many definitions converted, as Pester ends with a summary. All of this isWrite-Host, so-InformationAction Ignoreor6>$nullhides it, and none of it is in the pipeline. - While they work, both commands show a progress bar: the files compiled, or the definitions converted and then proved. The results still come together at the end, since a build writes nothing unless every file compiles, and checks across files need them all. Added 2026-11-30.,
file:line [Keyword] CODE: message, with the full path, for logs and scripts that search them. Only what PowerShell shows is a block. The exception'sHelpLinkis the first diagnostic's link. - The ADR references in messages stay, for the reasoning. The link is for what the code means and how to fix it.
- A test checks that each catalogued code's link names a generated page and a section on it, and that the wiki is the one at the module's
ProjectUri. With the catalogue test, every codesrcemits links to a section that exists.
Publishing¶
./build/build.ps1 -Task UpdateWikigenerates the pages intoout/wiki, clones<repo>.wiki.git, replaces only the pages it generates, and pushes if anything changed. It needsGH_PAT, as in the other modules. A generated page that would replace a page the build doesn't own is an error.- The release job runs it on every push to
main, after the tests. If the wiki hasn't been created yet (it needs one page made by hand in GitHub), the task says so and fails. - On pull requests, a test generates every page into a temporary folder without publishing, and checks that each command and keyword has a page with a synopsis and an example.
Consequences¶
- Good, because the wiki is always the help that shipped, and every diagnostic is explained.
- Good, because pages written by hand stay as they are.
- Bad, because the 169 catalogue entries have to be written once, and kept up to date with each new diagnostic. The test makes that a build failure rather than a forgotten task.
- Bad, because the wiki shows
main, not the released version. Until 1.0, that is the same thing in practice.
Confirmation¶
The catalogue test and the page generation test run in CI. The first push to main after this is merged publishes the pages.
Pros and Cons of the Options¶
Generated pages pushed to the wiki by the release job¶
- Good, because it is what the other modules do, and readers find docs in the wiki.
- Bad, because the wiki is a separate repository, written with a personal access token.
Documentation folder committed to the repository¶
- Good, because the docs are versioned with the code.
- Bad, because generated files in the repository go stale between builds, and change in every pull request that touches help.
Hand-written wiki pages¶
- Good, because they need no build.
- Bad, because they drift from the code, and nothing checks that every diagnostic is documented.