Skip to content

Commit b298d59

Browse files
authored
refactor(_meta): replace with build time JSON (#2840)
* feat(docs): generate individual *.docs.json files * chore(src): remove static _meta * docs(CONTRIBUTING.md): remove _meta instructions * typo(docs): fix docblock casing * refactor(componentInfo): from _meta to docs.json * refactor(subComponent): casing to subcomponent * refactor(commonTests): work with *.info.json * fix(implementsShorthandProp): remove _meta * refactor(withDocInfo): to use *.info.json files * wip DocsRoot dynamic require * refactor(ComponentDoc): use *.info.json files * refactor(Sidebar): use *.info.json files * fix(DocsRoot): handle info.description * feat(ComponentProps): closed by default * fix(ComponentDoc): use *.info.json and simplify * fix(ComponentDocLinks): add suiName * fix(ComponentSidebarSection): update menu json * component menu and example menu json, fix maximize * feat(DocsRoot): async load component info * wip props and bugs * remove cruft, cleanup * fix dockblock typo, docblock * fix(ComponentTable): use props.name for key * fix(ComponentProp): displayName to name * fix(ComponentProps): clear active state on change * fix clicking subcomponent props * fix(ExternalExampleLayout): use example path name * fix tests * rebuild json files on change, rework build tasks * fix tsd:test script * fix(ComponentDoc): missing descriptions * wip split example menu json * prettier ignore generated json * normalize imports * chore(package): add yarn ci command * chore(package): add babel plugin dynamic import
1 parent 2d2d509 commit b298d59

File tree

262 files changed

+3430
-4583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+3430
-4583
lines changed

.babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@babel/plugin-proposal-class-properties",
88
"@babel/plugin-proposal-export-default-from",
99
"@babel/plugin-proposal-export-namespace-from",
10+
"@babel/plugin-syntax-dynamic-import",
1011
"lodash",
1112
"transform-react-handled-props",
1213
["transform-react-remove-prop-types", {

.github/CONTRIBUTING.md

+8-44
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ CONTRIBUTING
1111
- [Commands](#commands)
1212
- [Workflow](#workflow)
1313
- [Create a Component](#create-a-component)
14-
- [Define _meta](#define-_meta)
1514
- [Using propTypes](#using-proptypes)
1615
- [Conformance Test](#conformance-test)
1716
- [Open A PR](#open-a-pr)
@@ -80,6 +79,8 @@ Please follow the [Angular Git Commit Guidelines][8] format.
8079
```sh
8180
yarn start // run doc site
8281

82+
yarn ci // run all checks CI runs
83+
8384
yarn test // test once
8485
yarn test:watch // test on file change
8586

@@ -98,7 +99,6 @@ yarn lint:watch // lint on file change
9899
## Workflow
99100

100101
- [Create a Component](#create-a-component)
101-
- [Define _meta](#define-_meta)
102102
- [Conformance Test](#conformance-test)
103103
- [Open A PR](#open-a-pr)
104104
- [Spec out the API](#spec-out-the-api)
@@ -127,41 +127,6 @@ class Dropdown extends Component {
127127

128128
>You probably need to extend our [`AutoControlledComponent`](#autocontrolledcomponent) to support both [controlled][2] and [uncontrolled][3] component patterns.
129129
130-
### Define _meta
131-
132-
Every component has a static property called `_meta`. This object defines the component. The values here are used for generated documentation, generated test cases and some utilities.
133-
134-
Here's an example `_meta` object:
135-
136-
```js
137-
import { META } from '../../lib'
138-
139-
const _meta = {
140-
name: 'MyComponent',
141-
type: META.TYPES.MODULE,
142-
}
143-
```
144-
145-
Assuming the above `_meta` is in scope, here's how you should expose it:
146-
147-
```js
148-
function MyComponent() {
149-
return <div>Hello World</div>
150-
}
151-
152-
MyComponent._meta = _meta
153-
```
154-
155-
```js
156-
class MyComponent {
157-
static _meta = _meta
158-
159-
render() {
160-
return <div>Hello World</div>
161-
}
162-
}
163-
```
164-
165130
### Using propTypes
166131

167132
Every component must have fully described `propTypes`.
@@ -390,7 +355,7 @@ There are many common things to test for. Because of this, we have [`test/specs
390355
```js
391356
common.isConformant()
392357
common.hasUIClassName()
393-
common.hasSubComponents()
358+
common.hasSubcomponents()
394359
common.isTabbable()
395360
common.rendersChildren()
396361

@@ -420,7 +385,7 @@ describe('Menu', () => {
420385
common.isConformant(Menu)
421386
common.hasUIClassName(Menu)
422387
common.rendersChildren(Menu)
423-
common.hasSubComponents(Menu, [MenuItem]) // some take additional arguments
388+
common.hasSubcomponents(Menu, [MenuItem]) // some take additional arguments
424389
})
425390
```
426391

@@ -445,7 +410,6 @@ This is the only required test. It ensures a consistent baseline for the framew
445410

446411
>This list is not updated, check the [source][1] for the latest assertions.
447412
448-
1. The [static `_meta`](#_meta) object is valid
449413
1. Component and filename are correct
450414
1. Events are properly handled
451415
1. Extra `props` are spread
@@ -489,7 +453,7 @@ TODO
489453
- [Props](#props)
490454
- [Examples](#examples)
491455

492-
Our docs are generated from doc block comments, `propTypes`, and hand written examples.
456+
Our docs are generated from docblock comments, `propTypes`, and hand written examples.
493457

494458
### Website
495459

@@ -501,7 +465,7 @@ yarn start
501465

502466
### Components
503467

504-
A doc block should appear above a component class or function to describe it:
468+
A docblock should appear above a component class or function to describe it:
505469

506470
```js
507471
/**
@@ -515,7 +479,7 @@ function Select(props) {
515479

516480
### Props
517481

518-
A doc block should appear above each prop in `propTypes` to describe them:
482+
A docblock should appear above each prop in `propTypes` to describe them:
519483

520484
>Limited props shown for brevity.
521485
@@ -539,7 +503,7 @@ Label.propTypes = {
539503
/** Place the label in one of the upper corners . */
540504
corner: PropTypes.oneOfType([
541505
PropTypes.bool,
542-
PropTypes.oneOf(Label._meta.props.corner),
506+
PropTypes.oneOf(['left', 'right']),
543507
]),
544508

545509
/** Add an icon by icon className or pass an <Icon /> */

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
coverage/
99
dist/
10-
docs/app/docgenInfo.json
11-
docs/app/menuInfo.json
10+
docs/app/componentInfo
11+
docs/app/componentMenu.json
12+
docs/app/exampleMenus
1213
docs/build/
1314
dll/
1415
node_modules/

.prettierignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ coverage/
99

1010
dist/
1111
dll/
12-
docs/app/docgenInfo.json
13-
docs/app/menuInfo.jso
12+
docs/app/componentInfo
13+
docs/app/componentMenu.json
14+
docs/app/exampleMenus
1415
docs/build/
1516

1617
package.json

config.js

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const envConfig = {
2020
dir_dll: 'dll',
2121
dir_docs_dist: 'docs/build',
2222
dir_docs_src: 'docs/app',
23-
dir_umd_dist: 'dist/umd',
2423
}
2524

2625
// ------------------------------------
@@ -35,7 +34,6 @@ const paths = {
3534
dll: base.bind(null, envConfig.dir_dll),
3635
docsDist: base.bind(null, envConfig.dir_docs_dist),
3736
docsSrc: base.bind(null, envConfig.dir_docs_src),
38-
umdDist: base.bind(null, envConfig.dir_umd_dist),
3937
}
4038

4139
const config = {

docs/app/Components/ComponentDoc/ComponentControls/ComponentControls.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ import ComponentControlsMaximize from './ComponentControlsMaximize'
99
import ComponentControlsShowHtml from './ComponentControlsShowHtml'
1010

1111
const ComponentControls = (props) => {
12-
const { anchorName, showHTML, showCode, onCopyLink, onShowHTML, onShowCode, visible } = props
12+
const {
13+
anchorName,
14+
examplePath,
15+
showHTML,
16+
showCode,
17+
onCopyLink,
18+
onShowHTML,
19+
onShowCode,
20+
visible,
21+
} = props
1322

1423
return (
1524
<Transition duration={200} visible={!!visible} unmountOnHide>
@@ -20,7 +29,7 @@ const ComponentControls = (props) => {
2029
<div>
2130
<Menu color='green' compact icon size='small' text>
2231
<ComponentControlsCopyLink anchorName={anchorName} onClick={onCopyLink} />
23-
<ComponentControlsMaximize anchorName={anchorName} />
32+
<ComponentControlsMaximize examplePath={examplePath} />
2433
<ComponentControlsShowHtml active={showHTML} onClick={onShowHTML} />
2534
<ComponentControlsEditCode active={showCode} onClick={onShowCode} />
2635
</Menu>
@@ -30,6 +39,7 @@ const ComponentControls = (props) => {
3039
}
3140

3241
ComponentControls.propTypes = {
42+
examplePath: PropTypes.string,
3343
anchorName: PropTypes.string,
3444
onCopyLink: PropTypes.func,
3545
onShowCode: PropTypes.func,
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1+
import _ from 'lodash'
12
import PropTypes from 'prop-types'
23
import React from 'react'
34
import { Icon, Menu } from 'semantic-ui-react'
45

56
import { neverUpdate } from 'docs/app/HOC'
67
import ComponentControlsToolTip from './ComponentControlsToolTip'
78

8-
const ComponentControlsMaximize = ({ anchorName }) => (
9-
<ComponentControlsToolTip content='Full Screen'>
10-
<Menu.Item href={`/maximize/${anchorName}`} target='_blank'>
11-
<Icon
12-
color='grey'
13-
fitted
14-
name='window maximize'
15-
size='large'
16-
/>
17-
</Menu.Item>
18-
</ComponentControlsToolTip>
19-
)
9+
const ComponentControlsMaximize = ({ examplePath }) => {
10+
const href = `/maximize/${_.kebabCase(examplePath.split('/').slice(-1))}`
2011

12+
return (
13+
<ComponentControlsToolTip content='Full Screen'>
14+
<Menu.Item href={href} target='_blank'>
15+
<Icon color='grey' fitted name='window maximize' size='large' />
16+
</Menu.Item>
17+
</ComponentControlsToolTip>
18+
)
19+
}
2120
ComponentControlsMaximize.propTypes = {
22-
anchorName: PropTypes.string,
21+
examplePath: PropTypes.string.isRequired,
2322
}
2423

2524
export default neverUpdate(ComponentControlsMaximize)

0 commit comments

Comments
 (0)