feat(docz): jsdoc integration

This commit is contained in:
Marcelo Piva
2018-09-11 03:00:37 -03:00
parent ea88841ea0
commit 0adac5bf1b
16 changed files with 951 additions and 8 deletions

5
examples/jsdoc/.babelrc Normal file
View File

@@ -0,0 +1,5 @@
{
"plugins": [
"emotion"
]
}

588
examples/jsdoc/CHANGELOG.md Normal file
View File

@@ -0,0 +1,588 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
<a name="0.11.1"></a>
## [0.11.1](https://github.com/pedronauck/docz/compare/v0.11.0...v0.11.1) (2018-09-07)
**Note:** Version bump only for package docz-example-basic
<a name="0.11.0"></a>
# [0.11.0](https://github.com/pedronauck/docz/compare/v0.10.3...v0.11.0) (2018-09-02)
### Features
* **docz:** move docz/docz-core to dev dependency on examples ([e7153a4](https://github.com/pedronauck/docz/commit/e7153a4))
<a name="0.10.3"></a>
## [0.10.3](https://github.com/pedronauck/docz/compare/v0.9.6...v0.10.3) (2018-08-16)
**Note:** Version bump only for package docz-example-basic
<a name="0.10.2"></a>
## [0.10.2](https://github.com/pedronauck/docz/compare/v0.10.1...v0.10.2) (2018-08-13)
**Note:** Version bump only for package docz-example-basic
<a name="0.10.1"></a>
## [0.10.1](https://github.com/pedronauck/docz/compare/v0.10.0...v0.10.1) (2018-08-13)
**Note:** Version bump only for package docz-example-basic
<a name="0.10.0"></a>
# [0.10.0](https://github.com/pedronauck/docz/compare/v0.9.6...v0.10.0) (2018-08-13)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.6"></a>
## [0.9.6](https://github.com/pedronauck/docz/compare/v0.9.5...v0.9.6) (2018-08-06)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.5"></a>
## [0.9.5](https://github.com/pedronauck/docz/compare/v0.9.4...v0.9.5) (2018-08-04)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.4"></a>
## [0.9.4](https://github.com/pedronauck/docz/compare/v0.9.4-beta.1...v0.9.4) (2018-08-04)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.3"></a>
## [0.9.3](https://github.com/pedronauck/docz/compare/v0.9.2...v0.9.3) (2018-08-03)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.2"></a>
## [0.9.2](https://github.com/pedronauck/docz/compare/v0.9.1...v0.9.2) (2018-08-02)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.1"></a>
## [0.9.1](https://github.com/pedronauck/docz/compare/v0.9.0...v0.9.1) (2018-08-02)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.0"></a>
# [0.9.0](https://github.com/pedronauck/docz/compare/v0.9.0-beta.1...v0.9.0) (2018-08-02)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.0-beta.1"></a>
# [0.9.0-beta.1](https://github.com/pedronauck/docz/compare/v0.9.0-beta.0...v0.9.0-beta.1) (2018-08-01)
**Note:** Version bump only for package docz-example-basic
<a name="0.9.0-beta.0"></a>
# [0.9.0-beta.0](https://github.com/pedronauck/docz/compare/v0.8.0...v0.9.0-beta.0) (2018-08-01)
**Note:** Version bump only for package docz-example-basic
<a name="0.8.0"></a>
# [0.8.0](https://github.com/pedronauck/docz/compare/v0.7.1...v0.8.0) (2018-07-28)
**Note:** Version bump only for package docz-example-basic
<a name="0.7.1"></a>
## [0.7.1](https://github.com/pedronauck/docz/compare/v0.7.0...v0.7.1) (2018-07-24)
**Note:** Version bump only for package docz-example-basic
<a name="0.7.0"></a>
# [0.7.0](https://github.com/pedronauck/docz/compare/v0.6.2...v0.7.0) (2018-07-23)
**Note:** Version bump only for package docz-example-basic
<a name="0.6.2"></a>
## [0.6.2](https://github.com/pedronauck/docz/compare/v0.6.1...v0.6.2) (2018-07-20)
**Note:** Version bump only for package docz-example-basic
<a name="0.6.1"></a>
## [0.6.1](https://github.com/pedronauck/docz/compare/v0.6.0...v0.6.1) (2018-07-19)
**Note:** Version bump only for package docz-example-basic
<a name="0.6.0"></a>
# [0.6.0](https://github.com/pedronauck/docz/compare/v0.5.9...v0.6.0) (2018-07-19)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.9"></a>
## [0.5.9](https://github.com/pedronauck/docz/compare/v0.5.8...v0.5.9) (2018-07-16)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.8"></a>
## [0.5.8](https://github.com/pedronauck/docz/compare/v0.5.7...v0.5.8) (2018-07-11)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.7"></a>
## [0.5.7](https://github.com/pedronauck/docz/compare/v0.5.6...v0.5.7) (2018-07-11)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.6"></a>
## [0.5.6](https://github.com/pedronauck/docz/compare/v0.5.5...v0.5.6) (2018-07-11)
### Bug Fixes
* **docz:** add theme config transform before merge ([dc3448a](https://github.com/pedronauck/docz/commit/dc3448a))
<a name="0.5.5"></a>
## [0.5.5](https://github.com/pedronauck/docz/compare/v0.5.4...v0.5.5) (2018-07-07)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.4"></a>
## [0.5.4](https://github.com/pedronauck/docz/compare/v0.5.3...v0.5.4) (2018-07-07)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.3"></a>
## [0.5.3](https://github.com/pedronauck/docz/compare/v0.5.2...v0.5.3) (2018-07-05)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.2"></a>
## [0.5.2](https://github.com/pedronauck/docz/compare/v0.5.1...v0.5.2) (2018-07-05)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.1"></a>
## [0.5.1](https://github.com/pedronauck/docz/compare/v0.3.4...v0.5.1) (2018-07-03)
**Note:** Version bump only for package docz-example-basic
<a name="0.5.0"></a>
# [0.5.0](https://github.com/pedronauck/docz/compare/v0.3.4...v0.5.0) (2018-07-03)
**Note:** Version bump only for package docz-example-basic
<a name="0.4.0"></a>
# [0.4.0](https://github.com/pedronauck/docz/compare/v0.3.4...v0.4.0) (2018-06-30)
**Note:** Version bump only for package docz-example-basic
<a name="0.3.4"></a>
## [0.3.4](https://github.com/pedronauck/docz/compare/v0.3.3...v0.3.4) (2018-06-26)
**Note:** Version bump only for package docz-example-basic
<a name="0.3.3"></a>
## [0.3.3](https://github.com/pedronauck/docz/compare/v0.3.2...v0.3.3) (2018-06-26)
### Bug Fixes
* **docz-core:** copy templates files for dist ([#88](https://github.com/pedronauck/docz/issues/88)) ([5e4b98d](https://github.com/pedronauck/docz/commit/5e4b98d))
<a name="0.3.2"></a>
## [0.3.2](https://github.com/pedronauck/docz/compare/v0.3.1...v0.3.2) (2018-06-25)
**Note:** Version bump only for package docz-example-basic
<a name="0.3.1"></a>
## [0.3.1](https://github.com/pedronauck/docz/compare/v0.2.11...v0.3.1) (2018-06-25)
### Features
* **docz-default-theme:** dark mode and responsiveness ([#87](https://github.com/pedronauck/docz/issues/87)) ([a4db115](https://github.com/pedronauck/docz/commit/a4db115)), closes [#81](https://github.com/pedronauck/docz/issues/81)
<a name="0.3.0"></a>
# [0.3.0](https://github.com/pedronauck/docz/compare/v0.3.0-beta.0...v0.3.0) (2018-06-25)
**Note:** Version bump only for package docz-example-basic
<a name="0.3.0-beta.0"></a>
# [0.3.0-beta.0](https://github.com/pedronauck/docz/compare/v0.2.11...v0.3.0-beta.0) (2018-06-25)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.11"></a>
## [0.2.11](https://github.com/pedronauck/docz/compare/v0.2.10...v0.2.11) (2018-06-22)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.10"></a>
## [0.2.10](https://github.com/pedronauck/docz/compare/v0.2.9...v0.2.10) (2018-06-21)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.9"></a>
## [0.2.9](https://github.com/pedronauck/docz/compare/v0.2.8...v0.2.9) (2018-06-21)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.8"></a>
## [0.2.8](https://github.com/pedronauck/docz/compare/v0.2.7...v0.2.8) (2018-06-21)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.7"></a>
## [0.2.7](https://github.com/pedronauck/docz/compare/v0.2.6...v0.2.7) (2018-06-20)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.6"></a>
## [0.2.6](https://github.com/pedronauck/docz/compare/v0.2.5...v0.2.6) (2018-06-17)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.5"></a>
## [0.2.5](https://github.com/pedronauck/docz/compare/v0.2.4...v0.2.5) (2018-06-15)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.4"></a>
## [0.2.4](https://github.com/pedronauck/docz/compare/v0.2.3...v0.2.4) (2018-06-13)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.3"></a>
## [0.2.3](https://github.com/pedronauck/docz/compare/v0.2.2...v0.2.3) (2018-06-13)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.2"></a>
## [0.2.2](https://github.com/pedronauck/docz/compare/v0.2.1...v0.2.2) (2018-06-12)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.1"></a>
## [0.2.1](https://github.com/pedronauck/docz/compare/v0.2.0...v0.2.1) (2018-06-12)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.0"></a>
# [0.2.0](https://github.com/pedronauck/docz/compare/v0.2.0-beta.2...v0.2.0) (2018-06-11)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.0-beta.2"></a>
# [0.2.0-beta.2](https://github.com/doczjs/docz/compare/v0.2.0-beta.1...v0.2.0-beta.2) (2018-06-10)
### Bug Fixes
* **docz-core:** autolink headings ([0b8369d](https://github.com/doczjs/docz/commit/0b8369d))
<a name="0.2.0-beta.1"></a>
# [0.2.0-beta.1](https://github.com/doczjs/docz/compare/v0.2.0-beta.0...v0.2.0-beta.1) (2018-06-10)
**Note:** Version bump only for package docz-example-basic
<a name="0.2.0-beta.0"></a>
# [0.2.0-beta.0](https://github.com/doczjs/docz/compare/v0.1.2-beta.6...v0.2.0-beta.0) (2018-06-10)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.6"></a>
## [0.1.2-beta.6](https://github.com/doczjs/docz/compare/v0.1.2-beta.5...v0.1.2-beta.6) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.5"></a>
## [0.1.2-beta.5](https://github.com/doczjs/docz/compare/v0.1.2-beta.4...v0.1.2-beta.5) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.4"></a>
## [0.1.2-beta.4](https://github.com/doczjs/docz/compare/v0.1.2-beta.3...v0.1.2-beta.4) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.3"></a>
## [0.1.2-beta.3](https://github.com/doczjs/docz/compare/v0.1.2-beta.2...v0.1.2-beta.3) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.2"></a>
## [0.1.2-beta.2](https://github.com/doczjs/docz/compare/v0.1.2-beta.1...v0.1.2-beta.2) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.1"></a>
## [0.1.2-beta.1](https://github.com/doczjs/docz/compare/v0.1.2-beta.0...v0.1.2-beta.1) (2018-06-09)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.2-beta.0"></a>
## [0.1.2-beta.0](https://github.com/doczjs/docz/compare/v0.1.1...v0.1.2-beta.0) (2018-06-02)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.6"></a>
## [0.1.1-beta.6](https://github.com/doczjs/docz/compare/v0.1.1-beta.5...v0.1.1-beta.6) (2018-06-01)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.5"></a>
## [0.1.1-beta.5](https://github.com/doczjs/docz/compare/v0.1.1-beta.4...v0.1.1-beta.5) (2018-06-01)
### Bug Fixes
* **load-cfg:** add namedExports options ([d36194d](https://github.com/doczjs/docz/commit/d36194d))
<a name="0.1.1-beta.4"></a>
## [0.1.1-beta.4](https://github.com/doczjs/docz/compare/v0.1.1-beta.3...v0.1.1-beta.4) (2018-05-29)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.3"></a>
## [0.1.1-beta.3](https://github.com/doczjs/docz/compare/v0.1.1-beta.2...v0.1.1-beta.3) (2018-05-29)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.2"></a>
## [0.1.1-beta.2](https://github.com/doczjs/docz/compare/v0.1.1-beta.0...v0.1.1-beta.2) (2018-05-29)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.1"></a>
## [0.1.1-beta.1](https://github.com/doczjs/docz/compare/v0.1.1-beta.0...v0.1.1-beta.1) (2018-05-29)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.1-beta.0"></a>
## [0.1.1-beta.0](https://github.com/doczjs/docz/compare/v0.1.0...v0.1.1-beta.0) (2018-05-29)
**Note:** Version bump only for package docz-example-basic
<a name="0.1.0"></a>
# 0.1.0 (2018-05-29)
### Bug Fixes
* **docz-core:** config watch for directory operations ([43fa7ab](https://github.com/doczjs/docz/commit/43fa7ab))
* **docz-core:** create plugin to fix paragraph parse on mdx ([42b4f05](https://github.com/doczjs/docz/commit/42b4f05))
* **docz-core:** packages splitting ([d2e74ee](https://github.com/doczjs/docz/commit/d2e74ee))
* **docz-example-basic:** package name ([dec5713](https://github.com/doczjs/docz/commit/dec5713))
### Features
* **docz:** add groups feature ([9652b30](https://github.com/doczjs/docz/commit/9652b30))
* add basic monorepo structure ([5a977ed](https://github.com/doczjs/docz/commit/5a977ed))
* **docz:** add components parser ([a4127d9](https://github.com/doczjs/docz/commit/a4127d9))
* **docz:** add custom routes for docs ([8458d91](https://github.com/doczjs/docz/commit/8458d91))
* **docz-core:** add build command ([ef7abd2](https://github.com/doczjs/docz/commit/ef7abd2))
* **docz-core:** add hot reload ([9ebe65d](https://github.com/doczjs/docz/commit/9ebe65d))
* **docz-core:** add playground code parse section ([6bbf158](https://github.com/doczjs/docz/commit/6bbf158))
* **docz-core:** set babel on the fly ([672be49](https://github.com/doczjs/docz/commit/672be49))
* add component props parse feature ([987627d](https://github.com/doczjs/docz/commit/987627d))
* add support for highlight code sections ([19bf7ea](https://github.com/doczjs/docz/commit/19bf7ea))
* **docz-core:** use websockets instead of generate json to process entries ([e0773a0](https://github.com/doczjs/docz/commit/e0773a0))
* **docz-theme-default:** start logic to create theme feature ([900cf2b](https://github.com/doczjs/docz/commit/900cf2b))
* refac to use mdx ([04b59e5](https://github.com/doczjs/docz/commit/04b59e5))

View File

@@ -0,0 +1,20 @@
{
"name": "docz-example-jsdoc",
"version": "0.11.1",
"license": "MIT",
"scripts": {
"dev": "docz dev",
"build": "docz build"
},
"dependencies": {
"emotion": "^9.2.8",
"prop-types": "^15.6.2",
"react": "^16.5.0",
"react-dom": "^16.5.0",
"react-emotion": "^9.2.8"
},
"devDependencies": {
"babel-plugin-emotion": "^9.2.8",
"docz": "^0.11.1"
}
}

View File

@@ -0,0 +1,21 @@
---
name: Getting Started
route: /
order: 1
---
# Getting Started
Design systems enable teams to build better products faster by making design reusable—reusability makes scale possible. This is the heart and primary value of design systems. A design system is a collection of reusable components, guided by clear standards, that can be assembled together to build any number of applications.
Regardless of the technologies and tools behind them, a successful design system follows these guiding principles:
- **Its consistent**. The way components are built and managed follows a predictable pattern.
- **Its self-contained**. Your design system is treated as a standalone dependency.
- **Its reusable**. Youve built components so they can be reused in many contexts.
- **Its accessible**. Applications built with your design system are usable by as many people as possible, no matter how they access the web.
- **Its robust**. No matter the product or platform to which your design system is applied, it should perform with grace and minimal bugs.
## Consistency
Your first, most important task when starting out is to define the rules of your system, document them, and ensure that everyone follows them. When you have clearly documented code standards and best practices in place, designers and developers from across your organization can easily use and, more importantly, contribute to your design system.

View File

@@ -0,0 +1,10 @@
/**
* Returns the sum of a and b
* @param {number} a
* @param {(number|null)} [b=0]
* @returns {number}
*/
export function sum(a, b) {
return a + b
}

View File

@@ -0,0 +1,9 @@
---
name: Utils
---
import { JSDoc } from 'docz'
# Utils
<JSDoc of="sum" />

View File

@@ -53,6 +53,7 @@
"happypack": "^5.0.0",
"html-minifier": "^3.5.20",
"humanize-string": "^1.0.2",
"jsdoc3-parser": "^2.0.0",
"koa": "^2.5.2",
"koa-connect": "^2.0.1",
"koa-mount": "^3.0.0",
@@ -95,6 +96,7 @@
"yargs": "^12.0.1"
},
"devDependencies": {
"@types/babel__core": "^7.0.1",
"@types/chokidar": "^1.7.5",
"@types/connect-history-api-fallback": "^1.3.1",
"@types/deepmerge": "^2.1.0",

View File

@@ -17,11 +17,15 @@ export const build = async (args: Config) => {
const dataServer = new DataServer()
try {
dataServer.register([states.entries(config), states.config(config)])
dataServer.register([
states.entries(config),
states.config(config),
states.metadata(config)
])
await Entries.writeApp(config)
await dataServer.init()
return
await run('onPreBuild', config)
await bundler.build(await bundler.getConfig(env))
await run('onPostBuild', config)

View File

@@ -33,7 +33,11 @@ export const dev = async (args: Config) => {
)
try {
dataServer.register([states.entries(newConfig), states.config(newConfig)])
dataServer.register([
states.entries(newConfig),
states.config(newConfig),
states.metadata(newConfig)
])
await Entries.writeApp(newConfig, true)
await dataServer.init()

View File

@@ -1,2 +1,3 @@
export { state as entries } from './entries'
export { state as config } from './config'
export { state as metadata } from './metadata'

View File

@@ -0,0 +1,40 @@
import * as path from 'path'
import chokidar from 'chokidar'
import equal from 'fast-deep-equal'
import { State, Params } from '../DataServer'
import { Config } from '../commands/args'
import * as paths from '../config/paths'
import { parseSourceFiles } from '../utils/jsdoc'
const update = (config: Config) => async (p: Params) => {
const oldMeta = p.state.metadata
const newMeta = {
jsdoc: await parseSourceFiles(config)
}
if(newMeta && !equal(oldMeta, newMeta)) {
p.setState('metadata', newMeta)
}
}
export const state = (config: Config): State => {
const src = path.relative(paths.root, config.src)
const files = path.join(src, config.files)
const watcher = chokidar.watch(files, {
cwd: paths.root,
ignored: /(^|[\/\\])\../,
persistent: true,
})
return {
init: update(config),
update: async params => {
const updateWithConfig = update(config)
watcher.on('add', async () => updateWithConfig(params))
watcher.on('change', async () => updateWithConfig(params))
watcher.on('unlink', async () => updateWithConfig(params))
return () => watcher.close()
}
}
}

View File

@@ -0,0 +1,73 @@
// @ts-ignore
import parser from 'jsdoc3-parser'
import glob from 'fast-glob'
import * as path from 'path'
import { Config } from '../commands/args'
import * as paths from '../config/paths'
interface ASTMeta {
range: number[]
lineno: number
columnno: number
path: string
code: any
}
interface ASTParam {
name: string
type?: {
names: string[]
}
optional?: boolean
defaultValue?: any
description?: string
}
interface ASTReturns {
name: string
type?: {
names: string[]
}
description?: string
}
interface ASTNode {
name: string
description?: string
comment?: string
meta?: ASTMeta
undocumented?: boolean
params?: ASTParam[]
returns?: ASTReturns
longname: string
kind: string
memberof?: string
scope?: string
}
export type JSDocAST = ASTNode[]
async function findSourceFiles(config: Config): Promise<string[]> {
const src = path.resolve(paths.root, config.src)
return glob<string>(`${src}/**/*.(js|ts|jsx|tsx)`, {
onlyFiles: true,
unique: true,
nocase: true,
matchBase: true,
})
}
export async function parseSourceFiles(config: Config): Promise<JSDocAST> {
const files = await findSourceFiles(config)
const promises = files.map(async (file) => {
return new Promise<JSDocAST>((resolve, reject) => {
return parser(file, (error: string | null, ast: JSDocAST) => resolve(ast))
})
})
const asts = await Promise.all(promises)
return asts.reduce((acc, ast) => acc.concat(ast), [])
}

View File

@@ -0,0 +1,74 @@
import * as React from 'react'
import { Metadata, metadataSelector, state } from '../state'
import { withMDXComponents } from '@mdx-js/tag/dist/mdx-provider'
interface ASTMeta {
range: number[]
lineno: number
columnno: number
path: string
code: any
}
interface ASTParam {
name: string
type?: {
names: string[]
}
optional?: boolean
defaultValue?: any
description?: string
}
interface ASTReturns {
name: string
type?: {
names: string[]
}
description?: string
}
interface ASTNode {
name: string
description?: string
comment?: string
meta?: ASTMeta
undocumented?: boolean
params?: ASTParam[]
returns?: ASTReturns
longname: string
kind: string
memberof?: string
scope?: string
}
export type JSDocAST = ASTNode[]
interface Props {
of: string
from?: string
}
const findDefinition = (name: string, ast: JSDocAST): ASTNode | undefined => {
return ast.find(node => node.name === name)
}
const BaseJSDoc: React.SFC<Props> = (props) => {
return (
<state.Consumer select={[metadataSelector]}>
{(metadata: Metadata) => {
console.log(metadata)
const def = findDefinition(props.of, metadata.jsdoc || [])
if(!def) return 'Not found'
return (
<div>
<div>{def.name}</div>
<div>{def.description}</div>
</div>
)
}}
</state.Consumer>
)
}
export const JSDoc = withMDXComponents(BaseJSDoc)

View File

@@ -4,6 +4,7 @@ export { Docs, DocsRenderProps } from './components/Docs'
export { Link, LinkProps } from './components/Link'
export { Playground } from './components/Playground'
export { PropsTable } from './components/PropsTable'
export { JSDoc } from './components/JSDoc'
export { ThemeConfig } from './components/ThemeConfig'
export {
DocPreview,

View File

@@ -1,6 +1,6 @@
import { ComponentType as CT } from 'react'
import createState from 'react-copy-write'
import { JSDocAST } from './components/JSDoc'
import { ComponentsMap } from './components/DocPreview'
export type MSXComponent = CT<{
@@ -43,6 +43,10 @@ export interface Config {
repository: string | null
}
export interface Metadata {
jsdoc?: JSDocAST
}
type Import = () => Promise<MSXImport>
export type EntryMap = Record<string, Entry>
@@ -52,9 +56,13 @@ export type TransformFn = (config: Config) => Config
export interface State {
config: Config
entries: EntryMap
metadata: Metadata
}
export const state = createState({
config: {},
entries: {},
metadata: {}
})
export const metadataSelector = state.createSelector((s: State) => s.metadata)

View File

@@ -781,7 +781,7 @@
lodash "^4.17.10"
to-fast-properties "^2.0.0"
"@babel/types@^7.0.0":
"@babel/types@^7.0.0", "@babel/types@^7.0.0-beta.54":
version "7.0.0"
resolved "https://registry.npmjs.org/@babel/types/-/types-7.0.0.tgz#6e191793d3c854d19c6749989e3bc55f0e962118"
dependencies:
@@ -1589,6 +1589,12 @@
dependencies:
"@types/node" "*"
"@types/babel__core@^7.0.1":
version "7.0.1"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.0.1.tgz#8b608a1c55cb4c752352cc6c78f7beb61a3fd51f"
dependencies:
"@babel/types" "^7.0.0-beta.54"
"@types/body-parser@*":
version "1.17.0"
resolved "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.17.0.tgz#9f5c9d9bd04bb54be32d5eb9fc0d8c974e6cf58c"
@@ -2589,6 +2595,10 @@ babel-types@^6.26.0:
lodash "^4.17.4"
to-fast-properties "^1.0.3"
babylon@7.0.0-beta.19:
version "7.0.0-beta.19"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.19.tgz#e928c7e807e970e0536b078ab3e0c48f9e052503"
babylon@^6.18.0:
version "6.18.0"
resolved "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
@@ -2671,7 +2681,7 @@ bluebird-co@^2.2.0:
version "2.2.0"
resolved "https://registry.npmjs.org/bluebird-co/-/bluebird-co-2.2.0.tgz#e0a49e63b6b17e34c91f48b3934b769a377fbed7"
bluebird@^3.5.1:
bluebird@^3.5.1, bluebird@~3.5.0:
version "3.5.2"
resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz#1be0908e054a751754549c270489c1505d4ab15a"
@@ -3063,6 +3073,12 @@ caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
catharsis@~0.8.9:
version "0.8.9"
resolved "https://registry.yarnpkg.com/catharsis/-/catharsis-0.8.9.tgz#98cc890ca652dd2ef0e70b37925310ff9e90fc8b"
dependencies:
underscore-contrib "~0.3.0"
ccount@^1.0.0:
version "1.0.3"
resolved "https://registry.npmjs.org/ccount/-/ccount-1.0.3.tgz#f1cec43f332e2ea5a569fd46f9f5bde4e6102aff"
@@ -4403,7 +4419,7 @@ escape-string-applescript@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/escape-string-applescript/-/escape-string-applescript-2.0.0.tgz#760bca838668e408fe5ee52ce42caf7cb46c5273"
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5, escape-string-regexp@~1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -6473,10 +6489,39 @@ js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
argparse "^1.0.7"
esprima "^4.0.0"
js2xmlparser@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-3.0.0.tgz#3fb60eaa089c5440f9319f51760ccd07e2499733"
dependencies:
xmlcreate "^1.0.1"
jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
jsdoc3-parser@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/jsdoc3-parser/-/jsdoc3-parser-2.0.0.tgz#c7c3282a6a0029bd460f6211ce7b27686fb9d60d"
dependencies:
jsdoc "^3.5.5"
jsdoc@^3.5.5:
version "3.5.5"
resolved "https://registry.yarnpkg.com/jsdoc/-/jsdoc-3.5.5.tgz#484521b126e81904d632ff83ec9aaa096708fa4d"
dependencies:
babylon "7.0.0-beta.19"
bluebird "~3.5.0"
catharsis "~0.8.9"
escape-string-regexp "~1.0.5"
js2xmlparser "~3.0.0"
klaw "~2.0.0"
marked "~0.3.6"
mkdirp "~0.5.1"
requizzle "~0.2.1"
strip-json-comments "~2.0.1"
taffydb "2.6.2"
underscore "~1.8.3"
jsesc@^1.3.0:
version "1.3.0"
resolved "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b"
@@ -6584,6 +6629,12 @@ klaw@^1.0.0:
optionalDependencies:
graceful-fs "^4.1.9"
klaw@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-2.0.0.tgz#59c128e0dc5ce410201151194eeb9cbf858650f6"
dependencies:
graceful-fs "^4.1.9"
koa-compose@^3.0.0, koa-compose@^3.2.1:
version "3.2.1"
resolved "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz#a85ccb40b7d986d8e5a345b3a1ace8eabcf54de7"
@@ -7147,6 +7198,10 @@ markdown-table@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/markdown-table/-/markdown-table-0.4.0.tgz#890c2c1b3bfe83fb00e4129b8e4cfe645270f9d1"
marked@~0.3.6:
version "0.3.19"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790"
match-sorter@^2.3.0:
version "2.3.0"
resolved "https://registry.npmjs.org/match-sorter/-/match-sorter-2.3.0.tgz#99eaf386689f75bf976f6bbf7f49afb9a7ffecc8"
@@ -9319,6 +9374,12 @@ requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
requizzle@~0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/requizzle/-/requizzle-0.2.1.tgz#6943c3530c4d9a7e46f1cddd51c158fc670cdbde"
dependencies:
underscore "~1.6.0"
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@@ -10219,6 +10280,10 @@ table@^4.0.2, table@^4.0.3:
slice-ansi "1.0.0"
string-width "^2.1.1"
taffydb@2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.6.2.tgz#7cbcb64b5a141b6a2efc2c5d2c67b4e150b2a268"
tapable@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz#cbb639d9002eed9c6b5975eb20598d7936f1f9f2"
@@ -10606,6 +10671,20 @@ umask@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d"
underscore-contrib@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/underscore-contrib/-/underscore-contrib-0.3.0.tgz#665b66c24783f8fa2b18c9f8cbb0e2c7d48c26c7"
dependencies:
underscore "1.6.0"
underscore@1.6.0, underscore@~1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.6.0.tgz#8b38b10cacdef63337b8b24e4ff86d45aea529a8"
underscore@~1.8.3:
version "1.8.3"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022"
unescape@^0.2.0:
version "0.2.0"
resolved "https://registry.npmjs.org/unescape/-/unescape-0.2.0.tgz#b78b9b60c86f1629df181bf53eee3bc8d6367ddf"
@@ -11407,6 +11486,10 @@ xdg-trashdir@^2.1.1:
user-home "^2.0.0"
xdg-basedir "^2.0.0"
xmlcreate@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/xmlcreate/-/xmlcreate-1.0.2.tgz#fa6bf762a60a413fb3dd8f4b03c5b269238d308f"
xregexp@4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"