Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip origin in more places #1067

Merged
merged 1 commit into from
Dec 24, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3072,7 +3072,7 @@ sandbox?: Array<

<div class="ts-block-property-bullets">

- <span class="tag deprecated">deprecated</span>
- <span class="tag deprecated">deprecated</span>

</div>

Expand All @@ -3089,7 +3089,7 @@ sandbox?: Array<

<div class="ts-block-property-bullets">

- <span class="tag deprecated">deprecated</span>
- <span class="tag deprecated">deprecated</span>

</div>

Expand All @@ -3106,7 +3106,7 @@ sandbox?: Array<

<div class="ts-block-property-bullets">

- <span class="tag deprecated">deprecated</span>
- <span class="tag deprecated">deprecated</span>

</div>

Expand All @@ -3133,7 +3133,7 @@ referrer?: Array<

<div class="ts-block-property-bullets">

- <span class="tag deprecated">deprecated</span>
- <span class="tag deprecated">deprecated</span>

</div>

Expand Down
6 changes: 3 additions & 3 deletions apps/svelte.dev/scripts/sync-docs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ export async function get_types(code: string, statements: ts.NodeArray<ts.Statem
// `@link` JSDoc tags (and maybe others?) turn this property into an array, which we need to join manually
if (Array.isArray(jsDoc.comment)) {
comment = (jsDoc.comment as any[])
.map(({ name, text }) => (name ? `\`${name.escapedText}\`` : text))
.map(({ name, text }) => strip_origin(name ? `\`${name.escapedText}\`` : text))
.join('');
} else {
comment = jsDoc.comment;
comment = strip_origin(jsDoc.comment);
}

if (jsDoc.tags) {
Expand Down Expand Up @@ -280,7 +280,7 @@ function munge_type_element(member: ts.TypeElement, depth = 1): TypeElement | un
}

function cleanup_comment(comment: string = '') {
return comment
return strip_origin(comment)
.replace(/\/\/\/ type: (.+)/g, '/** @type {$1} */')
.replace(/\/\/\/ errors: (.+)/g, '// @errors: $1') // see read_d_ts_file
.replace(/^( )+/gm, (match: string, spaces: string) => {
Expand Down
Loading