Fix duplicate doc enrichment and trailing blank-line accumulation#816
Fix duplicate doc enrichment and trailing blank-line accumulation#816ramsessanchez wants to merge 2 commits into
Conversation
The weekly reference-docs pipeline was producing duplicate content on docs that GenerateMarkDown.ps1 retains (unchanged raw docs or generation failures) instead of regenerating from scratch (regression from content-based regeneration, PR #790). The enrichment scripts re-inserted their blocks on top of the previous run's output. - GeneratePermissionsTable.ps1: strip any existing **Permissions** block(s) before inserting, making insertion idempotent. - UpdateLinks.ps1: strip any existing beta/v1.0 release [!NOTE] callout before inserting, making insertion idempotent. - EscapeDisallowedHtmlTags.ps1: TrimEnd content in CleanupFile so the repeated Get-Content -Raw | Out-File passes stop accumulating trailing blank lines. Self-heals the ~2,692 already-duplicated docs on the next run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: dd9612e5-eb70-49bb-8468-5e187b57e041
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 71cfa2e: ✅ Validation status: passed
For more details, please refer to the build report. |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit d3c7628: ✅ Validation status: passed
For more details, please refer to the build report. |
Problem
The weekly reference-docs pipeline is producing duplicate documentation. Affected docs show two
**Permissions**blocks and two beta/v1.0> [!NOTE]callouts, plus an ever-growing block of trailing blank lines. In branchWeeklyReferenceDocsUpdate_202607210236, ~2,692 docs carry a duplicate Permissions block.Root cause
GenerateMarkDown.ps1(content-based regeneration, #790) now keeps the previously-committed, already-enriched doc in place when the freshly generated raw doc is unchanged (or when platyPS generation fails silently). The downstream enrichment scripts are not idempotent — they re-insert their block on top of last run's output:GeneratePermissionsTable.ps1inserts a**Permissions**table before## EXAMPLES/## PARAMETERS.UpdateLinks.ps1inserts the beta/v1.0 release> [!NOTE]callout before## SYNTAX.EscapeDisallowedHtmlTags.ps1rewrites each file via repeatedGet-Content -Raw | Out-Filepasses (18 inUpdate-SpecificStrings), each appending one trailing newline — growing the end-of-file blank block ~22 lines per run on retained docs.Fix
Make the enrichment idempotent and stop trailing-line accumulation:
GeneratePermissionsTable.ps1— strip any existing**Permissions**block(s) before inserting, so exactly one is produced.UpdateLinks.ps1— strip any existing beta/v1.0 release[!NOTE]callout before inserting.EscapeDisallowedHtmlTags.ps1—TrimEnd()the content inCleanupFile(the last per-file step) so files end with exactly one trailing newline; this caps the file every run and eliminates accumulation.These changes self-heal the already-duplicated docs on the next pipeline run.
Validation
Get-MgApplication.md: Permissions 2→0, beta NOTE 2→0; full strip+re-insert round-trip yields exactly one clean block of each.Add-MgApplicationKey.md: 45 → 1 trailing newline, last content line preserved.