Skip to content

Commit

Permalink
fix doc:generate script
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Jun 19, 2019
1 parent 9846b30 commit 6e3fd80
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
17 changes: 12 additions & 5 deletions docs/scripts/generateDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const fs = require("fs");
const path = require("path");
const ts = require("typescript");
const globby = require("globby");

const name = process.argv.slice(2).filter(a => !a.startsWith("-"));
const options = process.argv.slice(2).filter(a => a.startsWith("-"));
Expand Down Expand Up @@ -366,9 +367,15 @@ function parsePropTypes(name, source, tsx) {
// eslint-disable-next-line no-console
console.log(`Generating documents...${name.length > 0 ? `: ${name.join(", ")}` : ""}`);

const componentFiles = fs
.readdirSync(path.resolve(__dirname, "..", "..", "src"))
.filter(cf => /\.tsx?$/.test(cf) && !/index\.tsx?$/.test(cf))
const componentFiles = globby
.sync([
"src/*/*.ts{,x}",
"!src/*/index.ts{,x}",
"!src/*/story.ts{,x}",
"!src/*/test.ts{,x}",
"!src/*/*.test.ts{,x}",
"!src/core/**/*",
])
.filter(cf => name.length === 0 || name.includes(cf.replace(/\.tsx?$/, "")));

if (componentFiles.length > 0) {
Expand All @@ -382,8 +389,8 @@ if (componentFiles.length > 0) {
const preview = options.includes("--preview");

componentFiles.forEach(cf => {
const name = cf.replace(/\.tsx?$/, "");
const code = fs.readFileSync(path.resolve(__dirname, "..", "..", "src", cf), "utf8");
const name = path.parse(cf).name;
const code = fs.readFileSync(cf, "utf8");
const props = parsePropTypes(name, code);
if (preview) {
// eslint-disable-next-line no-console
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.13.0",
"file-loader": "^3.0.1",
"globby": "^9.2.0",
"jasmine-core": "^3.4.0",
"jest": "^24.8.0",
"lodash.omit": "^4.5.0",
Expand Down
20 changes: 17 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ array-sort@^1.0.0:
get-value "^2.0.6"
kind-of "^5.0.2"

array-union@^1.0.1:
array-union@^1.0.1, array-union@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=
Expand Down Expand Up @@ -4767,7 +4767,7 @@ [email protected]:
arrify "^1.0.1"
path-type "^3.0.0"

dir-glob@^2.0.0:
dir-glob@^2.0.0, dir-glob@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.2.2.tgz#fa09f0694153c8918b18ba0deafae94769fc50c4"
integrity sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw==
Expand Down Expand Up @@ -6261,6 +6261,20 @@ globby@^7.1.1:
pify "^3.0.0"
slash "^1.0.0"

globby@^9.2.0:
version "9.2.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d"
integrity sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg==
dependencies:
"@types/glob" "^7.1.1"
array-union "^1.0.2"
dir-glob "^2.2.2"
fast-glob "^2.2.6"
glob "^7.1.3"
ignore "^4.0.3"
pify "^4.0.1"
slash "^2.0.0"

good-listener@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/good-listener/-/good-listener-1.2.2.tgz#d53b30cdf9313dffb7dc9a0d477096aa6d145c50"
Expand Down Expand Up @@ -6757,7 +6771,7 @@ ignore@^3.3.5:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
integrity sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==

ignore@^4.0.6:
ignore@^4.0.3, ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
Expand Down

0 comments on commit 6e3fd80

Please sign in to comment.