Skip to content

fix(template/dotnet): switch link-prefix step to paren-aware Python walker#29

Merged
WomB0ComB0 merged 1 commit intomainfrom
fix/dotnet-template-paren-walker
May 9, 2026
Merged

fix(template/dotnet): switch link-prefix step to paren-aware Python walker#29
WomB0ComB0 merged 1 commit intomainfrom
fix/dotnet-template-paren-walker

Conversation

@WomB0ComB0
Copy link
Copy Markdown
Member

@WomB0ComB0 WomB0ComB0 commented May 9, 2026

Fixes resq-software/docs#28 (995 broken links).

DefaultDocumentation emits links with title attributes:

](ResQ.Blockchain.md 'qualified.Type')

The sed regex expected ) immediately after .md (with optional #anchor) and skipped these entirely, so 995 bare-filename links never got the ./ prefix. Mintlify rejected all of them.

Replace with a paren-balanced Python walker (same shape used elsewhere). Handles:

  • (path.md)
  • (path.md#anchor)
  • (path.md 'title') and double-quoted variants
  • method-overload filenames like Foo.Bar(string,int).md

Sync PR will reapply the same fix to dotnet-sdk:main.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Markdown link processing in generated documentation to more accurately identify and fix internal link references while preserving external links and code block content.

Review Change Stack

…alker

995 broken-link errors on #28 because the sed
regex did not match DefaultDocumentation's link forms:

  ](ResQ.Blockchain.md 'qualified.Type')

The trailing space + 'title' before `)` falls outside the
`[^)/]*` URL character class, so the regex skipped these
links entirely and they kept their bare-filename form. Mintlify
rejected all 995 of them.

Replace the sed step with a paren-balanced Python walker (same
shape used elsewhere in this template family). It correctly
handles:
  - bare `(path.md)`
  - `(path.md#anchor)`
  - `(path.md 'title')` and double-quoted variants
  - method-overload pages with parens in the filename, e.g.
    `Foo.Bar(string,int).md`

Sync PR will reapply the same fix to dotnet-sdk:main.
@WomB0ComB0 WomB0ComB0 merged commit 0c2d9d8 into main May 9, 2026
8 of 9 checks passed
@github-actions github-actions Bot added the area:content MDX/MD documentation content label May 9, 2026
@WomB0ComB0 WomB0ComB0 deleted the fix/dotnet-template-paren-walker branch May 9, 2026 16:49
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 741f338b-cf54-44d9-b6db-a3e55d9ac678

📥 Commits

Reviewing files that changed from the base of the PR and between 8ecbb66 and 59f3b92.

📒 Files selected for processing (1)
  • automation/source-repo-templates/api-docs.dotnet.yml

📝 Walkthrough

Walkthrough

The PR replaces a simplistic sed-based Markdown link rewriter in a GitHub Actions workflow with a Python script that safely handles paren-balanced link detection, skips content inside code blocks, and prefixes bare .md filenames with ./ to fix Mintlify broken-link validation.

Changes

Markdown Link Rewriting Step

Layer / File(s) Summary
Documentation & Rationale
automation/source-repo-templates/api-docs.dotnet.yml
Comments explain the new paren-balanced parsing approach and why sed cannot safely handle method-overload filenames.
Python Link Transformer Implementation
automation/source-repo-templates/api-docs.dotnet.yml
Python script replaces the find + sed loop; parses Markdown links with paren-balanced URL scanning, skips code blocks, and rewrites non-external, non-relative .md link targets.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • resq-software/docs#15: Both PRs modify the same Markdown post-processing step in automation/source-repo-templates/api-docs.dotnet.yml, with this PR replacing the previous regex/awk approach with a balanced Python-based linker.

Suggested labels

area:content

Poem

🐰 A sed-based link, once fragile and frail,
Now rests on Python's balanced tale—
Through code block fences, parsing true,
Each bare-named .md gets its ./ due! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dotnet-template-paren-walker

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the sed-based link prefixing logic in the .NET API documentation template with a Python script to better handle complex Markdown links, such as those with titles or parentheses in filenames. Feedback was provided to enhance the script by ensuring it ignores inline code spans to prevent accidental modification of links within code snippets.

Comment on lines +205 to +206
while i < n:
j = line.find("](", i)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current walker does not account for inline code spans (e.g., code-enclosed links). According to the general rules for Markdown post-processing, the logic should respect CommonMark inline code span rules—specifically by counting backtick run lengths—to avoid incorrectly modifying content inside code snippets. This ensures that examples or documentation about links are not inadvertently rewritten.

              while i < n:
                  if line[i] == chr(96):
                      r = 0
                      while i + r < n and line[i + r] == chr(96): r += 1
                      end = line.find(chr(96) * r, i + r)
                      if end != -1:
                          out.append(line[i:end + r])
                          i = end + r
                          continue
                  j = line.find("](", i)
References
  1. When processing Markdown/MDX files to escape curly braces for JSX compatibility, ensure the logic ignores content within inline code spans (backticks) to prevent breaking code snippets.

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

Labels

area:content MDX/MD documentation content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants