Skip to content

Fix duplicate doc enrichment and trailing blank-line accumulation#816

Open
ramsessanchez wants to merge 2 commits into
mainfrom
ramsessanchez/fix-duplicate-doc-enrichment
Open

Fix duplicate doc enrichment and trailing blank-line accumulation#816
ramsessanchez wants to merge 2 commits into
mainfrom
ramsessanchez/fix-duplicate-doc-enrichment

Conversation

@ramsessanchez

Copy link
Copy Markdown
Contributor

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 branch WeeklyReferenceDocsUpdate_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.ps1 inserts a **Permissions** table before ## EXAMPLES/## PARAMETERS.
  • UpdateLinks.ps1 inserts the beta/v1.0 release > [!NOTE] callout before ## SYNTAX.
  • EscapeDisallowedHtmlTags.ps1 rewrites each file via repeated Get-Content -Raw | Out-File passes (18 in Update-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.ps1TrimEnd() the content in CleanupFile (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

  • Regex strips verified on the real duplicated Get-MgApplication.md: Permissions 2→0, beta NOTE 2→0; full strip+re-insert round-trip yields exactly one clean block of each.
  • Trailing-line normalization verified on Add-MgApplicationKey.md: 45 → 1 trailing newline, last content line preserved.
  • All three scripts pass a PowerShell parse check.

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
@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit 71cfa2e:

✅ Validation status: passed

File Status Preview URL Details
scripts/EscapeDisallowedHtmlTags.ps1 ✅Succeeded
scripts/GeneratePermissionsTable.ps1 ✅Succeeded
scripts/UpdateLinks.ps1 ✅Succeeded

For more details, please refer to the build report.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

PoliCheck Scan Report

The 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 found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown
Contributor

Learn Build status updates of commit d3c7628:

✅ Validation status: passed

File Status Preview URL Details
scripts/EscapeDisallowedHtmlTags.ps1 ✅Succeeded
scripts/GeneratePermissionsTable.ps1 ✅Succeeded
scripts/UpdateLinks.ps1 ✅Succeeded

For more details, please refer to the build report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant