Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSOC] Automatic Documentation System for TypeScript Components #3554

Merged
merged 100 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
034039a
Add react-docgen-typescript
ashikmeerankutty Jun 3, 2020
b895f10
Add react-docgen-typescript plugin
ashikmeerankutty Jun 3, 2020
0a3b3ff
Use ts.createProgram
ashikmeerankutty Jun 4, 2020
1a8e5ca
Hide errors for now
ashikmeerankutty Jun 4, 2020
278c085
Omit id from HTML Attributes in accordion
ashikmeerankutty Jun 5, 2020
5bdbb1a
Common props to beginning
ashikmeerankutty Jun 5, 2020
c909ba0
Fixed issue with boolean props not generated
ashikmeerankutty Jun 10, 2020
a3f7cb6
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jun 12, 2020
34953a3
Changed React.Component to Component for props info
ashikmeerankutty Jun 12, 2020
63c08e3
save Prop value as string
ashikmeerankutty Jun 14, 2020
8cd8e43
Use react for tsx and jsx in compiler option
ashikmeerankutty Jun 14, 2020
ef460a3
Removed console.log
ashikmeerankutty Jun 14, 2020
3245d60
Save prop value as string
ashikmeerankutty Jun 15, 2020
b283319
Added comment for children prop
ashikmeerankutty Jun 15, 2020
8568111
CommonProps to the beginning
ashikmeerankutty Jun 15, 2020
009857a
replace React.
ashikmeerankutty Jun 15, 2020
b56b8f0
Updated react-docgen-typescript
ashikmeerankutty Jun 15, 2020
0eeb689
Fixed typo in package.json
ashikmeerankutty Jun 15, 2020
d48de0b
Removed screenreader only prop used in docs
ashikmeerankutty Jun 23, 2020
cfd0736
Relaced React.
ashikmeerankutty Jun 24, 2020
b84a7db
Create program must use files from src-docs
ashikmeerankutty Jun 24, 2020
fb22d6d
increased uti.inspect maxlength
ashikmeerankutty Jun 24, 2020
b96c9e7
Updated export for flex_group
ashikmeerankutty Jun 24, 2020
e3222f1
Removed issues with some files
ashikmeerankutty Jun 24, 2020
c2781ee
Use spread operator
ashikmeerankutty Jun 24, 2020
f7dfef2
Replaced React
ashikmeerankutty Jun 24, 2020
a627eb1
Removed logs used to test
ashikmeerankutty Jun 24, 2020
8a19f76
Removed src-docs
ashikmeerankutty Jun 24, 2020
11313a8
Add comment to children node to flex grid
ashikmeerankutty Jun 24, 2020
a47bfd7
Add description for children node
ashikmeerankutty Jun 24, 2020
d686816
Fixed issues with components in generating props
ashikmeerankutty Jun 25, 2020
f70920d
Omit onClick prop from html elements
ashikmeerankutty Jun 25, 2020
c3b2332
Allow color title onClick
ashikmeerankutty Jun 25, 2020
748aca0
Removed color title onClick
ashikmeerankutty Jun 25, 2020
b80d4f4
Fixed issues with color and title
ashikmeerankutty Jun 25, 2020
83eb314
Support types from react-dnd
ashikmeerankutty Jun 25, 2020
60462b2
Fixed title prop in context_menu_panel
ashikmeerankutty Jun 25, 2020
76dabdf
Fixed required issue in checkable card
ashikmeerankutty Jun 25, 2020
a3624b9
Fixed issue with an if loop
ashikmeerankutty Jun 27, 2020
893d32e
Fixed issues with props not generating
ashikmeerankutty Jun 27, 2020
b4a5b0e
Fixed issues with props not generating
ashikmeerankutty Jun 27, 2020
5d7ecb0
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 1, 2020
bfffaa8
tests passing; responsive prop default
thompsongl Jul 1, 2020
911c9a0
Merge pull request #2 from thompsongl/autodocs
ashikmeerankutty Jul 1, 2020
d65cdda
Fix issue with overlay mask props
ashikmeerankutty Jul 2, 2020
567943f
Fixed title not generated and props for overlaymask
ashikmeerankutty Jul 4, 2020
143b678
Fixed wrong prop generated for children prop
ashikmeerankutty Jul 4, 2020
bb60bf4
get children prop from ast
ashikmeerankutty Jul 9, 2020
3578be2
get children prop from ast
ashikmeerankutty Jul 9, 2020
4e8d10e
removed filename usage
ashikmeerankutty Jul 9, 2020
7d70f8c
Re use typescript create program and get type from typescript
ashikmeerankutty Jul 10, 2020
d1980a3
Fixed children prop issue with class components
ashikmeerankutty Jul 10, 2020
f0220ed
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 13, 2020
189ca02
playground input updates
thompsongl Jul 13, 2020
ae26343
Update src-docs/src/services/playground/props.js
thompsongl Jul 13, 2020
7c9ee6b
Update src-docs/src/services/playground/props.js
thompsongl Jul 13, 2020
fc54162
Merge pull request #3 from thompsongl/autodocs
ashikmeerankutty Jul 14, 2020
983096f
use any HTML value instead of printing all html values
ashikmeerankutty Jul 14, 2020
0c44419
Merge branch 'autodocs' of github.com:ashikmeerankutty/eui into autodocs
ashikmeerankutty Jul 14, 2020
59bf018
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 14, 2020
0a23236
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 16, 2020
2a8e6e6
Replace some with every
ashikmeerankutty Jul 16, 2020
ecf9ffd
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 20, 2020
06d9add
Update src/components/toast/global_toast_list_item.tsx
ashikmeerankutty Jul 22, 2020
95a0a10
Update src/components/title/title.tsx
ashikmeerankutty Jul 22, 2020
9f1c064
Update src/components/tabs/tabs.tsx
ashikmeerankutty Jul 22, 2020
c855015
Update src/components/steps/step.tsx
ashikmeerankutty Jul 22, 2020
3bce149
Update src/components/badge/notification_badge/badge_notification.tsx
ashikmeerankutty Jul 22, 2020
622c231
Update src/components/resizable_container/resizable_panel.tsx
ashikmeerankutty Jul 22, 2020
cef7b8e
Removed babel plugin react docgen and props types from ts props
ashikmeerankutty Jul 23, 2020
72d9799
Apply suggestions from code review
ashikmeerankutty Jul 23, 2020
606b80b
Removed babel plugin react docgen
ashikmeerankutty Jul 23, 2020
1b7a33d
Fixed children prop
ashikmeerankutty Jul 23, 2020
88b6648
description must respect line breaks
ashikmeerankutty Jul 25, 2020
67efb81
Fixed issue with any
ashikmeerankutty Jul 25, 2020
8e4292b
Fixed props types
ashikmeerankutty Jul 25, 2020
2dd9d58
Add more comments
ashikmeerankutty Jul 26, 2020
54a0e78
Replaces ReactElement<any>
ashikmeerankutty Jul 26, 2020
c0a1490
Replace ReactNode and ReactElement expanded string
ashikmeerankutty Jul 26, 2020
b0948b8
Update src/components/accessibility/screen_reader.tsx
ashikmeerankutty Jul 27, 2020
d40a588
Merge branch 'autodocs' of github.com:ashikmeerankutty/eui into autodocs
ashikmeerankutty Jul 27, 2020
8cdc1a7
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Jul 27, 2020
54b3d58
Fixed warnings from webpack
ashikmeerankutty Aug 7, 2020
933cace
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Aug 7, 2020
983c912
Fixed issue with facet button
ashikmeerankutty Aug 10, 2020
1ab36d9
Fixed issue with link
ashikmeerankutty Aug 10, 2020
bd29033
Fixed issue with link
ashikmeerankutty Aug 10, 2020
1e2e568
Fixed issue with toggle
ashikmeerankutty Aug 11, 2020
24a51da
Fixed issue with ReactText
ashikmeerankutty Aug 11, 2020
ce9a31f
Fixed issue with link
ashikmeerankutty Aug 11, 2020
29195a0
Add ; back
ashikmeerankutty Aug 11, 2020
08baeab
Merge remote-tracking branch 'upstream/master' into autodocs
ashikmeerankutty Aug 11, 2020
006a7fe
Fixed prettier errors
ashikmeerankutty Aug 11, 2020
dc651dc
Fex prettier problem
ashikmeerankutty Aug 11, 2020
d8e1cb5
Add proptypes from ts props back
ashikmeerankutty Aug 12, 2020
614b4be
align test ouput
thompsongl Aug 12, 2020
de17f6f
Merge branch 'master' into autodocs
thompsongl Aug 12, 2020
20c95fe
Merge branch 'master' into autodocs
thompsongl Aug 12, 2020
106e8c6
increase minified bundle build node memory limit
thompsongl Aug 12, 2020
31edf89
increase other prod-like build node memory limit
thompsongl Aug 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ module.exports = {
"@babel/plugin-syntax-dynamic-import",
"pegjs-inline-precompile",
"./scripts/babel/proptypes-from-ts-props",
"./scripts/babel/react-docgen-typescript",
ashikmeerankutty marked this conversation as resolved.
Show resolved Hide resolved
"add-module-exports",
[
"react-docgen",
{
"resolver": "findAllExportedComponentDefinitions"
}
],
// stage 3
"@babel/proposal-object-rest-spread",
// stage 2
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test-unit": "cross-env NODE_ENV=test jest --config ./scripts/jest/config.json",
"test-a11y": "node ./scripts/a11y-testing",
"test-staged": "yarn lint && node scripts/test-staged.js",
"start-test-server": "BABEL_MODULES=false NODE_ENV=puppeteer webpack-dev-server --config src-docs/webpack.config.js --port 9999",
"start-test-server": "BABEL_MODULES=false NODE_ENV=puppeteer NODE_OPTIONS=--max-old-space-size=4096 webpack-dev-server --config src-docs/webpack.config.js --port 9999",
"test-visual": "wdio test/wdio.conf.js",
"yo-component": "yo ./generator-eui/app/component.js",
"test-visual-tests": "node ./scripts/run-visual-tests.js",
Expand Down Expand Up @@ -128,7 +128,6 @@
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-inline-react-svg": "^1.0.1",
"babel-plugin-pegjs-inline-precompile": "^0.1.0",
"babel-plugin-react-docgen": "^3.1.0",
"babel-template": "^6.26.0",
"cache-loader": "^2.0.1",
"chai": "^4.1.2",
Expand Down Expand Up @@ -191,6 +190,7 @@
"puppeteer": "^2.0.0",
"raw-loader": "^0.5.1",
"react": "^16.12.0",
"react-docgen-typescript": "^1.17.1",
"react-dom": "^16.12.0",
"react-redux": "^5.1.2",
"react-router": "^5.2.0",
Expand Down
43 changes: 34 additions & 9 deletions scripts/babel/proptypes-from-ts-props/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable new-cap */

const fs = require('fs');
Expand Down Expand Up @@ -471,8 +491,7 @@ function getPropTypesForNode(node, optional, state) {

if (
types.isLiteral(propType) ||
(types.isIdentifier(propType) &&
propType.name === 'undefined')
(types.isIdentifier(propType) && propType.name === 'undefined')
) {
// can't use a literal straight, wrap it with PropTypes.oneOf([ the_literal ])
propType = convertLiteralToOneOf(types, propType);
Expand Down Expand Up @@ -511,7 +530,7 @@ function getPropTypesForNode(node, optional, state) {
// translates intersections (Foo & Bar & Baz) to a shape with the types' members (Foo, Bar, Baz) merged together
case 'TSIntersectionType':
const usableNodes = [...node.types].filter(node => {
let nodePropTypes = getPropTypesForNode(node, true, state);
const nodePropTypes = getPropTypesForNode(node, true, state);

if (
types.isMemberExpression(nodePropTypes) &&
Expand All @@ -526,7 +545,8 @@ function getPropTypesForNode(node, optional, state) {
!types.isCallExpression(nodePropTypes) ||
!types.isMemberExpression(nodePropTypes.callee) ||
nodePropTypes.callee.object.name !== 'PropTypes' ||
(nodePropTypes.callee.property.name !== 'shape' && nodePropTypes.callee.property.name !== 'oneOfType')
(nodePropTypes.callee.property.name !== 'shape' &&
nodePropTypes.callee.property.name !== 'oneOfType')
) {
return false;
}
Expand Down Expand Up @@ -712,9 +732,15 @@ function getPropTypesForNode(node, optional, state) {
(types.isIdentifier(propertyPropType) &&
propertyPropType.name === 'undefined')
) {
propertyPropType = convertLiteralToOneOf(types, propertyPropType);
propertyPropType = convertLiteralToOneOf(
types,
propertyPropType
);
if (!property.optional) {
propertyPropType = makePropTypeRequired(types, propertyPropType);
propertyPropType = makePropTypeRequired(
types,
propertyPropType
);
}
}

Expand Down Expand Up @@ -1085,7 +1111,7 @@ const typeDefinitionExtractors = {
return [];
}

const cacheKey = `${sourceFilename}_${resolvedPath}`
const cacheKey = `${sourceFilename}_${resolvedPath}`;
if (importedDefinitionsCache.has(cacheKey)) {
return importedDefinitionsCache.get(cacheKey);
}
Expand Down Expand Up @@ -1562,8 +1588,7 @@ module.exports = function propTypesFromTypeScript({ types }) {
types.isIdentifier(variableDeclarator.init.callee.object) &&
variableDeclarator.init.callee.object.name === 'React' &&
types.isIdentifier(variableDeclarator.init.callee.property) &&
variableDeclarator.init.callee.property.name === 'forwardRef')
)
variableDeclarator.init.callee.property.name === 'forwardRef'))
) {
// props for the component come from the second argument to the type params
const typeDefinition =
Expand Down
Loading