Skip to content

Commit

Permalink
fix(docs): handle missing sources
Browse files Browse the repository at this point in the history
fixes #227
  • Loading branch information
almostSouji committed Nov 10, 2024
1 parent 379e686 commit ea821cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/functions/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ function formatExample(blocks?: any[]) {
function formatItem(_item: any, _package: string, version: string, member?: string) {
const itemLink = docsLink(_item, _package, version, member);
const item = effectiveItem(_item, member);
const sourceUrl = `${item.sourceURL}#L${item.sourceLine}`;
const sourceUrl = item.sourceURL ? `${item.sourceURL}${item.sourceLine ? `#L${item.sourceLine}` : ''}` : null;

const [emojiId, emojiName] = itemKindEmoji(item.kind, version === 'main');

Expand All @@ -252,7 +252,8 @@ function formatItem(_item: any, _package: string, version: string, member?: stri
parts.push(underline(bold(hyperlink(item.displayName, itemLink))));

const head = `<:${emojiName}:${emojiId}>`;
const tail = ` ${hyperlink(inlineCode(`@${version}`), sourceUrl, 'source code')}`;
const versionString = inlineCode(`@${version}`);
const tail = sourceUrl ? ` ${hyperlink(versionString, sourceUrl, 'source code')}` : versionString;
const middlePart = item.isDeprecated ? strikethrough(parts.join(' ')) : parts.join(' ');

const lines: string[] = [[head, middlePart, tail].join(' ')];
Expand Down

0 comments on commit ea821cc

Please sign in to comment.