Publish exported function documentation to the wiki on merge - #625
Publish exported function documentation to the wiki on merge#625Adam Rudell (arudell) wants to merge 4 commits into
Conversation
- generate-documentation.ps1 now generates a _Sidebar.md and accepts an optional -WikiPath to sync generated function docs into a wiki checkout, removing stale function pages (identified via approved PowerShell verbs) while leaving hand-authored pages like Home.md untouched. - New publish-documentation.yml workflow runs on push to main (src/** changes) and workflow_dispatch, checks out the wiki repo, regenerates docs, and pushes changes directly to the wiki. No documentation is stored in the source repo. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ae912379-0ace-40f9-bfaf-75540b4e6fa3
There was a problem hiding this comment.
Pull request overview
Adds automated generation and wiki publication of exported PowerShell function documentation.
Changes:
- Generates function pages and wiki navigation.
- Synchronizes generated pages through a new GitHub Actions workflow.
- Removes obsolete generated documentation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
.build/generate-documentation.ps1 |
Generates, synchronizes, and removes function documentation. |
.github/workflows/publish-documentation.yml |
Publishes documentation to the project wiki. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Copy generated function docs into a functions\ subfolder of the wiki checkout (matching the real SdnDiagnostics.wiki structure) instead of the wiki root. - Target the sidebar file at the wiki's actual _SideBar.md (exact casing), not a locally-generated _Sidebar.md. - Only regenerate the ## Functions section of _SideBar.md; preserve all hand-authored content above it (Documentation, How To Guides, Troubleshooting Guides, Learning sections) verbatim. - Update stale function page detection/removal to scan functions\ instead of the wiki root. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ae912379-0ace-40f9-bfaf-75540b4e6fa3
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
.github/workflows/publish-documentation.yml:19
- Concurrent pushes can start two publishers from the same wiki revision. Whichever pushes second will receive a non-fast-forward error; if that is the newer source revision, the wiki remains stale until another run. Serialize this workflow's publishing runs.
jobs:
.build/generate-documentation.ps1:60
Get-Command -Modulealso returns exported aliases. This module exportsGet-SdnEnvironmentInfoas an alias (src/SdnDiagnostics.psd1:181-184), while platyPS excludes aliases when generating module pages, so the sidebar will contain a danglingGet-SdnEnvironmentInfolink and stale-page detection will treat it as current. Restrict this list to functions.
$exportedFunctions = Get-Command -Module SdnDiagnostics | Sort-Object -Property Name
.github/workflows/publish-documentation.yml:22
- Manual dispatches can be run against any selectable branch, so this job can publish unmerged branch documentation to the production wiki while the commit message claims it came from
main. Guard the publishing job so manual runs only operate onmain.
publish-documentation:
# The type of runner that the job will run on
runs-on: windows-latest
…tection - Add concurrency group to publish-documentation workflow to serialize runs and prevent races on the wiki checkout/push; add retry-with-rebase logic around the wiki push for extra robustness against out-of-band edits. - Replace approved-verb-prefix regex matching for stale page detection with a manifest-based approach (.generated-manifest.json in wiki/functions/). Only pages previously generated by this script that are no longer exported are considered stale, guaranteeing hand-authored pages (even ones matching PowerShell verb-noun naming) are never removed. - Fix a double-nesting bug where wrapping ConvertFrom-Json output in @() collapsed the whole manifest array into a single nested element, corrupting stale-page comparisons. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ae912379-0ace-40f9-bfaf-75540b4e6fa3
…ion.ps1 Prints the full set of function articles synced to the wiki functions\ folder each run, flagging newly-added pages and naming each removed stale page, so the published article list is visible directly in the pipeline log without needing to inspect the wiki repo's commit diff. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ae912379-0ace-40f9-bfaf-75540b4e6fa3
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.build/generate-documentation.ps1:60
- The generated-file check only warns, but this same list is later used to build the manifest and sidebar. If platyPS omits a page, the workflow therefore succeeds and publishes a sidebar link for a file that was never copied. Treat any missing generated page as a fatal generation error so an incomplete wiki is not committed.
$exportedFunctions = Get-Command -Module SdnDiagnostics | Sort-Object -Property Name
.build/generate-documentation.ps1:158
- This workflow explicitly uses Windows PowerShell 5.1, where
Set-Contentdefaults to the active ANSI code page rather than UTF-8. Rewriting_SideBar.mdthis way can corrupt non-ASCII text in the preserved hand-authored prefix. Read and write the sidebar with an explicit UTF-8 encoding (including theGet-Contentcall above).
else {
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.build/generate-documentation.ps1:64
- Missing generated pages are only logged, but the later manifest and sidebar still include every exported function. If platyPS skips a command, this workflow therefore publishes a broken link and records the nonexistent page as generated. Fail generation when this check finds any missing function instead of continuing.
$exportedFunctions = Get-Command -Module SdnDiagnostics | Sort-Object -Property Name
$currentFiles = Get-ChildItem -Path $docPath\* -Include *.md
foreach($function in $exportedFunctions){
if($function.Name -inotin ($currentFiles).BaseName){
"Documentation not generated for {0}" -f $function.Name | Write-Host -ForegroundColor:Yellow
.github/workflows/publish-documentation.yml:44
actions/checkoutdefaults to the event ref, so a manual dispatch from a feature branch can publish unmerged source to the production wiki. It also leaves serialized push runs tied to their historical event SHAs rather than the currentmaintip. Explicitly check outmainfor this publishing job and derive the commit label from that checkout's HEAD.
- name: 'Checkout SdnDiagnostics'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: main
Summary
Wires up the previously unused
.build\generate-documentation.ps1script and adds a new workflow that regenerates and publishes exported function documentation directly to theSdnDiagnostics.wikirepo on every merge tomainthat touchessrc/**. No generated documentation is stored in this source repo (.documentation/remains gitignored, consistent with the change made in #52/aa47164).This finishes the design already described in
.github/contributing.md:The sync logic mirrors the actual structure of the
SdnDiagnostics.wikirepo (hand-authored top-level pages, afunctions\subfolder for generated function docs, and_SideBar.mdfor navigation).Changes
.build/generate-documentation.ps1.documentation/functions(gitignored, not committed to this repo).-WikiPathparameter. When supplied, the script syncs generated docs into that wiki checkout:<wiki>\functions\(matching the wiki's real folder layout — function pages are not stored at the wiki root).<wiki>\functions\for functions that have since been removed/renamed, identified by matching PowerShell-approved-verb prefixes — hand-authored root pages (e.g.Home.md) are never touched.<wiki>\_SideBar.md(exact casing, matching the file already tracked in the wiki repo): only the## Functionssection is regenerated (alphabetical list of- [Name](Name)links); all hand-authored content above that heading (Documentation, How To Guides, Troubleshooting Guides, Learning sections, etc.) is preserved verbatim..github/workflows/publish-documentation.yml(new)main(path-filtered tosrc/**) andworkflow_dispatch.microsoft/SdnDiagnostics.wiki.generate-documentation.ps1 -WikiPath <wiki checkout>.Testing
Ran
generate-documentation.ps1 -WikiPath <temp dir>locally end-to-end against a seeded fake wiki checkout modeled on the realSdnDiagnostics.wikistructure (rootHome.md, afunctions\subfolder, and a_SideBar.mdwith hand-authored sections above## Functionsplus one stale function entry):functions\.Home.mdand all hand-authored_SideBar.mdsections preserved untouched.Get-OldStaleFunction.mdremoved fromfunctions\(no longer exported).## Functionssection of_SideBar.mdregenerated correctly, alphabetically sorted.Workflow YAML and script syntax validated (PowerShell AST parse + YAML parse).
Notes / follow-up
SdnDiagnostics.wikirepo already exists (confirmed, just hidden from repo navigation) with at least one commit, whichactions/checkoutrequires.contents: writepermission (scoped only to this job) to push to the wiki.## Functionslist is sorted alphabetically for determinism/maintainability. This does not exactly match the current historical ordering in the wiki (which appears to reflect non-deterministicGet-Commandmodule-load ordering across nested modules) — the first run of this workflow will reorder that section.