Gathering detailed insights and metrics for remark-mdx-react-docgen-typescript
Gathering detailed insights and metrics for remark-mdx-react-docgen-typescript
Gathering detailed insights and metrics for remark-mdx-react-docgen-typescript
Gathering detailed insights and metrics for remark-mdx-react-docgen-typescript
A mdx plugin to extract a react component documentation using react-docgen-typescript
npm install remark-mdx-react-docgen-typescript
Typescript
Module System
Min. Node Version
Node Version
NPM Version
66
Supply Chain
98.7
Quality
78.8
Maintenance
100
Vulnerability
99.6
License
TypeScript (96.22%)
JavaScript (3.78%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
395,363
Last Day
137
Last Week
878
Last Month
3,781
Last Year
375,114
Apache-2.0 License
8 Commits
2 Watchers
3 Branches
34 Contributors
Updated on Mar 06, 2024
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
remark-mdx-react-docgen-typescript@1.0.1
Unpacked Size
28.10 kB
Size
9.01 kB
File Count
7
NPM Version
8.15.0
Node Version
18.7.0
Published on
Mar 14, 2024
Cumulative downloads
Total Downloads
Last Day
-17.5%
137
Compared to previous day
Last Week
-3.3%
878
Compared to previous week
Last Month
-55.6%
3,781
Compared to previous month
Last Year
1,752.5%
375,114
Compared to previous year
remark-mdx-react-docgen-typescript
📝 A mdx plugin to extract a react component documentation using react-docgen-typescript
1npm install -D remark-directive remark-mdx-react-docgen-typescript
1import remarkReactDocgen from 'remark-mdx-react-docgen-typescript'; 2// or 3// const remarkReactDocgen = require('remark-mdx-react-docgen-typescript').default;
See Using plugins for more instructions in the official documentation.
For example, given a file named example.mdx with the following contents:
1::component-docs{file="./Component.tsx"}
The following script:
1import { readFile } from 'node:fs/promises'; 2 3import { compile } from '@mdx-js/mdx'; 4import remarkDirective from 'remark-directive'; 5import remarkReactDocgen from 'remark-mdx-react-docgen-typescript'; 6 7const { contents } = await compile(await readFile('example.mdx'), { 8 jsx: true, 9 remarkPlugins: [remarkDirective, remarkReactDocgen], 10}); 11console.log(contents);
Roughly yields:
1export default function MDXContent() { 2 return <ComponentDocs 3 propsData={[{ 4 "tags": {}, 5 "filePath": "${cwd}/__fixtures__/Component.tsx", 6 "description": "", 7 "displayName": "Component", 8 "methods": [], 9 "props": {...} 10 ... 11 }]} 12 /> 13}
You may use @mdx-js/react
to define the component for ComponentDocs
tag name:
1import { MDXProvider } from '@mdx-js/react'; 2import ComponentDocs from './ComponentDocs'; 3// ^-- Assumes an integration is used to compile MDX to JS, such as 4// `@mdx-js/esbuild`, `@mdx-js/loader`, `@mdx-js/node-loader`, or 5// `@mdx-js/rollup`, and that it is configured with 6// `options.providerImportSource: '@mdx-js/react'`. 7 8/** @type {import('mdx/types.js').MDXComponents} */ 9const components = { 10 ComponentDocs, 11}; 12 13console.log( 14 <MDXProvider components={components}> 15 <Post /> 16 </MDXProvider> 17);
The file path is relative to the markdown file path. You can use <rootDir>
at the start of the path to import files relatively from the rootDir:
1::component-docs{file="<rootDir>/Component.tsx"}
You may also specify additional attributes that will be forwarded as props to ComponentDocs component:
1::component-docs{file="./Component.tsx" extraProp="value"}
componentName: string
: The name of tag/component this plugin will use in JSX. Defaults to ComponentDocs
.directiveName: string
: The directive name. Defaults to component-docs
.fileAttributeName: string
: The attribute name for file path. Defaults to file
.rootDir: string
: Change what <rootDir>
refers to. Defaults to process.cwd()
.reactDocGenOptions: object
: Options for react-docgen-typescript
.After installing dependencies with npm install
, the tests can be run with: npm test
Rippling People Center Inc. Apache 2.0
No vulnerabilities found.
No security vulnerabilities found.