Skip to content

fix: prevent broken doc links from bare URLs in flag descriptions#870

Merged
dangrondahl merged 4 commits into
mainfrom
fix-backtick-docs-output
May 8, 2026
Merged

fix: prevent broken doc links from bare URLs in flag descriptions#870
dangrondahl merged 4 commits into
mainfrom
fix-backtick-docs-output

Conversation

@dangrondahl
Copy link
Copy Markdown
Contributor

Summary

  • Revert fix: backtick http-proxy example URL to prevent broken doc links #857's backtick approach — pflag.UnquoteUsage treats backticks as value placeholder names, which broke --http-proxy (showed URL as type, stripped backticks from description)
  • Add singleQuotedURLPattern to the Mintlify doc generator: single-quoted URLs in flag descriptions are rendered as backtick-wrapped inline code in markdown output
  • Standardize URL convention in flag descriptions:
    • Example URLs → single-quote them: 'http://proxy-server-ip:proxy-port' (generator wraps in backticks)
    • Real links → markdown syntax: [Bitbucket auth](https://...) (clickable in docs)
    • docs.kosli.com → bare (auto-linkified by existing linkifyKosliDocsURLs)
  • Convert bbPasswordFlag, bbAccessTokenFlag, excludeRegexFlag to markdown links
  • Convert azureOrgUrlFlag from double-quotes to single-quotes

Closes kosli-dev/docs#105

Test plan

  • make docs CMD="assert pullrequest bitbucket" — Bitbucket URLs render as clickable markdown links
  • make docs CMD="attest snyk"--http-proxy shows string type and URL in backticks
  • make docs CMD="snapshot lambda" — RE2 syntax URL renders as clickable link
  • make docs CMD="assert pullrequest azure" — Azure example URL in backticks
  • All internal/docgen and cmd/kosli docs tests pass

Reverts the backtick approach from #857 because pflag.UnquoteUsage
treats backticks as value placeholder names, which caused --http-proxy
to show the URL as its type and stripped backticks from the description.

Instead, keep single quotes in the pflag usage string (for --help
terminal output) and convert single-quoted URLs to backtick-wrapped
inline code in the Mintlify doc generator. This prevents Mintlify from
rendering the URL as a broken clickable link.
Reverts the backtick approach from #857 because pflag.UnquoteUsage
treats backticks as value placeholder names, which caused --http-proxy
to show the URL as its type and stripped backticks from the description.

Instead, keep single quotes in the pflag usage string (for --help
terminal output) and convert single-quoted URLs to backtick-wrapped
inline code in the Mintlify doc generator. This prevents Mintlify from
rendering the URL as a broken clickable link.

Also standardize URL handling in flag descriptions:
- Example URLs: single-quote them (doc generator wraps in backticks)
- Real links: use markdown [text](url) syntax (rendered as clickable)
- docs.kosli.com URLs: bare (auto-linkified by existing generator)
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 8, 2026

Claude finished @dangrondahl's task in 2m 0s —— View job


PR Review: fix: prevent broken doc links from bare URLs in flag descriptions

  • Run static analysis (build, vet, mod tidy)
  • Review changed files
  • Post review feedback

Static Analysis

All clear — go build, go vet, and go mod tidy all pass with no issues.

Review

Overall: Clean, well-structured fix. The approach of using single quotes as a convention for example URLs (converted to backtick inline code by the doc generator) is a good design choice — it avoids the pflag.UnquoteUsage backtick issue while keeping flag descriptions readable in both CLI --help and generated Mintlify docs.

Positives:

  • The singleQuotedURLPattern regex is correctly scoped to only match http:// and https:// URLs inside single quotes, leaving other single-quoted text untouched (verified by the "non-URL single quotes left alone" test case)
  • Good test coverage with three test cases: http URL, https URL with path, and negative case
  • The URL convention is well-documented in the PR description and the code comments
  • Code fence awareness is preserved — escapeProseFragment is only called on prose sections, so no double-escaping risk
  • The ci-defaultsintegrations/ci_cd URL migration is complete (zero ci-defaults references remain)

One observation (non-blocking):

Re: the reviewer thread on root.go:147 about single quotes in CLI terminal output — I agree with @mbevc1's suggestion. The single quotes around example URLs like 'https://dev.azure.com/myOrg' will show literally in kosli <cmd> --help terminal output (e.g. E.g. 'https://dev.azure.com/myOrg'). This is actually fine for CLI usage — single-quoting example URLs is a common shell convention — but double quotes would be equally valid. The current approach is consistent across all example URLs in the file, which is the important thing.

No bugs, security issues, or correctness problems found. This is a solid fix that correctly addresses the pflag.UnquoteUsage backtick issue.


Comment thread cmd/kosli/root.go
@dangrondahl dangrondahl enabled auto-merge (squash) May 8, 2026 12:16
@dangrondahl dangrondahl merged commit 60ff5d1 into main May 8, 2026
20 checks passed
@dangrondahl dangrondahl deleted the fix-backtick-docs-output branch May 8, 2026 13:13
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.

fix: broken proxy-server-ip:proxy-port example links in CLI reference docs

2 participants