From 78e9a3d13f36c20afdb9524dc0e10a524bdb2829 Mon Sep 17 00:00:00 2001 From: ColinCollins <35832931+ColinCollins@users.noreply.github.com> Date: Wed, 17 Apr 2019 19:29:38 +0800 Subject: [PATCH] create the docs-3d build workflow (#4232) --- .gitignore | 1 + package.json | 4 +++- scripts/build-docs.js | 42 ++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 scripts/build-docs.js diff --git a/.gitignore b/.gitignore index 1a131fbb24..f8dff048d4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ DebugInfos.json /package-lock.json playground/library /declarations +docs-3d diff --git a/package.json b/package.json index 829662adef..0b5fc458b2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "build:min": "uglifyjs ./bin/cocos-3d.dev.js --mangle --source-map -o ./bin/cocos-3d.min.js", "build-rollup": "tsc --build rollup/tsconfig.json", "dev": "rollup -w -c ./rollup/config.js", - "postinstall": "npm run build-rollup" + "postinstall": "npm run build-rollup", + "buildDocs": "node ./scripts/build-docs" }, "repository": { "type": "git", @@ -71,6 +72,7 @@ "rollup-plugin-node-resolve": "^3.4.0", "rollup-watch": "^4.3.1", "tslint": "^5.12.0", + "typedoc": "github:cocos-creator/typedoc#master", "typescript": "^3.2.2", "uglify-js": "^3.4.9", "vconsole": "^3.3.0", diff --git a/scripts/build-docs.js b/scripts/build-docs.js new file mode 100644 index 0000000000..0c00ea2b67 --- /dev/null +++ b/scripts/build-docs.js @@ -0,0 +1,42 @@ +(function buildingDocs () { + let [index, out] = process.argv.slice(3); + const { spawn } = require('child_process'); + + let options = { + indexPath: index || `${process.cwd()}\\index.ts`, + mode: 'modules', + out: out || `${process.cwd()}\\docs-3d`, + name: 'Creator-3D-Docs' + }; + + // typedoc command + let command = [ + options.indexPath, + '--mode', options.mode, + '--ignoreCompilerErrors', + '--disableOutputCheck', + '--includeDeclarations', + '--name', + options.name, + '--out', + options.out]; + + let child = spawn('typedoc', command, { + shell: true, + env: process.env, + }); + + child.stdout.on('data', function (data) { + console.log(data.toString()); + }); + child.stderr.on('data', function (data) { + console.error(`${data}`); + }); + child.on('close', (code) => { + if (code !== 0) { + console.log('Building Failed!'); + return; + } + console.log('Building Success!'); + }); +})(); diff --git a/tsconfig.json b/tsconfig.json index 08f005c97e..e588673e31 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "lib": ["es2015", "es2017", "dom"], "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ - "allowJs": false, /* Allow javascript files to be compiled. */ + "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */