Skip to content

Commit

Permalink
strip origin in more places (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Dec 24, 2024
1 parent 13a22b2 commit c961a08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit c961a08

Please sign in to comment.