-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: correct extends link annotation
- Loading branch information
1 parent
fb3f65f
commit a4e31a7
Showing
3 changed files
with
53 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
|
||
// @ts-ignore | ||
// eslint-disable-next-line import/no-unresolved | ||
import useDoc from '@site/component-docs-plugin/useDocs'; | ||
|
||
const ANNOTATION_EXTENDS = '@extends'; | ||
|
||
export default function ExtendsLink({ | ||
componentLink, | ||
}: { | ||
componentLink: string; | ||
}) { | ||
const doc = useDoc(componentLink); | ||
|
||
const extendsAttributes: { name: string; link?: string }[] = []; | ||
doc?.description | ||
.split('\n') | ||
.filter((line: string) => { | ||
if (line.startsWith(ANNOTATION_EXTENDS)) { | ||
const parts = line.split(' ').slice(1); | ||
const link = parts.pop(); | ||
extendsAttributes.push({ | ||
name: parts.join(' '), | ||
link, | ||
}); | ||
return false; | ||
} | ||
return true; | ||
}) | ||
.join('\n'); | ||
|
||
if (extendsAttributes.length === 0) { | ||
return null; | ||
} | ||
|
||
return extendsAttributes.map((prop) => ( | ||
<div key={prop.name}> | ||
<i>Extends: </i> | ||
<a key={prop.name} href={prop.link}> | ||
<code> | ||
... | ||
{prop.name} | ||
</code> | ||
</a> | ||
</div> | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters