-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add README for gatsby-transformer-documentationjs
- Loading branch information
1 parent
e6600ab
commit 385bc78
Showing
2 changed files
with
76 additions
and
0 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,75 @@ | ||
# gatsby-transformer-documentationjs | ||
|
||
Uses [Documentation.js](https://documentation.js.org) to extract | ||
code metadata (JSDocs is supported currently though Flow is also supported | ||
by Documentation.js and can be added to this plugin as well). | ||
|
||
It's used on gatsbyjs.org and can be seen in use on several pages | ||
there e.g. https://www.gatsbyjs.org/docs/node-apis/ | ||
|
||
## Install | ||
|
||
`npm install --save gatsby-transformer-documentationjs` | ||
|
||
## How to use | ||
|
||
Add the plugin to your `gatsby-config.js`. | ||
|
||
```javascript | ||
plugins: [ | ||
`gatsby-transformer-documentationjs`, | ||
] | ||
``` | ||
|
||
Ensure that there's an instance of `gatsby-source-filesystem` that's | ||
pointed at your source code e.g. | ||
|
||
```javascript | ||
plugins: [ | ||
`gatsby-transformer-documentationjs`, | ||
{ | ||
resolve: `gatsby-source-filesystem`, | ||
options: { | ||
name: `source`, | ||
path: `${__dirname}/../src/`, | ||
}, | ||
}, | ||
] | ||
``` | ||
|
||
Then you can write GraphQL queries pulling out JSDoc comments like: | ||
|
||
```graphql | ||
{ | ||
allDocumentationJs { | ||
edges { | ||
node { | ||
name | ||
description { | ||
childMarkdownRemark { | ||
html | ||
} | ||
} | ||
returns { | ||
title | ||
} | ||
examples { | ||
raw | ||
highlighted | ||
} | ||
params { | ||
name | ||
type { | ||
name | ||
} | ||
description { | ||
childMarkdownRemark { | ||
html | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |