-
-
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: add extends prop to the props list
- Loading branch information
1 parent
a4e31a7
commit 6b05c12
Showing
3 changed files
with
52 additions
and
41 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 |
---|---|---|
@@ -1,48 +1,21 @@ | ||
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, | ||
name, | ||
link, | ||
}: { | ||
componentLink: string; | ||
name: string; | ||
link?: 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}> | ||
return ( | ||
<div key={name} className="extends"> | ||
<i>Extends: </i> | ||
<a key={prop.name} href={prop.link}> | ||
<a key={name} href={link}> | ||
<code> | ||
... | ||
{prop.name} | ||
{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