Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/generate-md-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {rehypeExpandCodeTabs} from './rehype-expand-code-tabs.mjs';
const DOCS_ORIGIN = process.env.NEXT_PUBLIC_DEVELOPER_DOCS
? 'https://develop.sentry.dev'
: 'https://docs.sentry.io';
const CACHE_VERSION = 9;
const CACHE_VERSION = 10;
const CACHE_COMPRESS_LEVEL = 4;
const R2_BUCKET = process.env.NEXT_PUBLIC_DEVELOPER_DOCS
? 'sentry-develop-docs'
Expand Down Expand Up @@ -1009,6 +1009,12 @@ async function genMDFromHTML(source, {cacheDir, noCache, usedCacheFiles}) {
.use(rehypeExpandCodeTabs)
.use(rehypeRemark, {
document: false,
// Drop React's empty `<!-- -->` text-node separators, which otherwise leak into the
// markdown on component-rendered pages like the API docs. Comments dispatch by node
// type, so this must live in nodeHandlers rather than handlers.
nodeHandlers: {
comment() {},
},
handlers: {
// HACK: Extract the canonical URL during parsing
link: (_state, node) => {
Expand Down
23 changes: 23 additions & 0 deletions scripts/generate-md-exports.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ function htmlToMarkdown(html) {
.use(rehypeExpandCodeTabs)
.use(rehypeRemark, {
document: false,
nodeHandlers: {
comment() {},
},
handlers: {
button() {},
},
Expand Down Expand Up @@ -306,3 +309,23 @@ describe('rehypeExpandCodeTabs', () => {
});
});
});

describe('comment stripping', () => {
it('drops React text-node separator comments emitted on component-rendered pages', () => {
const html =
'<p><code>organization_id_or_slug</code><em> (<!-- -->string<!-- -->)</em></p>';

const md = htmlToMarkdown(html);

expect(md).not.toContain('<!--');
expect(md).toContain('string');
});

it('drops standalone HTML comments', () => {
const md = htmlToMarkdown('<p>before<!-- a real comment -->after</p>');

expect(md).not.toContain('<!--');
expect(md).toContain('before');
expect(md).toContain('after');
});
});
3 changes: 1 addition & 2 deletions src/components/apiPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ function Params({params}) {
<Fragment key={param.name}>
<dt>
<div>
<code data-index>{param.name}</code>
<code data-index>{param.name}</code>{' '}
Copy link
Copy Markdown
Contributor Author

@cvxluo cvxluo Jun 2, 2026

Choose a reason for hiding this comment

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

seems like this extra space in the <em> was getting rendered as &#x20, so moving this lets us go from:
* status*&#x20;<!-- -->(<!-- -->string<!-- -->)*
to

  • status (string)

{!!param.schema?.type && (
<em>
{' '}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unconditional trailing space when schema type is missing

Low Severity

The {' '} space after <code> is now rendered unconditionally, but it only makes sense as a separator when the <em> type annotation follows. Previously the space lived inside the conditional <em> block and was only emitted when param.schema?.type was truthy. If a parameter ever lacks a schema type at runtime (which the defensive optional chaining ?. suggests is possible), there will be a stray trailing space after the parameter name.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9d48e59. Configure here.

({param.schema.type}
{param.schema.items && `(${param.schema.items.type})`})
</em>
Expand Down
Loading