mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-31 18:49:43 +08:00
Update typedoc and fix doc json gen
This commit is contained in:
parent
8652097906
commit
3c35fa6df0
18077
package-lock.json
generated
18077
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -64,7 +64,7 @@
|
|||||||
"tslint": "~6.1.0",
|
"tslint": "~6.1.0",
|
||||||
"tslint-config-prettier": "^1.18.0",
|
"tslint-config-prettier": "^1.18.0",
|
||||||
"tslint-ionic-rules": "0.0.21",
|
"tslint-ionic-rules": "0.0.21",
|
||||||
"typedoc": "^0.22.3",
|
"typedoc": "^0.22.4",
|
||||||
"typescript": "4.1.6",
|
"typescript": "4.1.6",
|
||||||
"typescript-tslint-plugin": "^1.0.1",
|
"typescript-tslint-plugin": "^1.0.1",
|
||||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||||
|
@ -27,31 +27,42 @@ const typedoc = new Application();
|
|||||||
typedoc.options.addReader(new TypeDoc.TSConfigReader());
|
typedoc.options.addReader(new TypeDoc.TSConfigReader());
|
||||||
typedoc.options.addReader(new TypeDoc.TypeDocReader());
|
typedoc.options.addReader(new TypeDoc.TypeDocReader());
|
||||||
|
|
||||||
typedoc.bootstrap({
|
|
||||||
mode: 'modules',
|
|
||||||
ignoreCompilerErrors: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
run(pluginsDir);
|
run(pluginsDir);
|
||||||
|
|
||||||
async function run(pluginsDir: string) {
|
async function run(pluginsDir: string) {
|
||||||
|
try {
|
||||||
const typedocData = await generateTypedoc(pluginsDir);
|
const typedocData = await generateTypedoc(pluginsDir);
|
||||||
const modules = typedocData.children.filter(isModule);
|
const modules = typedocData.children.filter(isModule);
|
||||||
const plugins = modules.filter(hasPlugin).map(processPlugin);
|
const plugins = modules.filter(hasPlugin).map(processPlugin);
|
||||||
await fs.outputJson(resolve(__dirname, 'plugins.json'), plugins, {
|
await fs.outputJson(resolve(__dirname, 'plugins.json'), plugins, {
|
||||||
spaces: 2,
|
spaces: 2,
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Unable to generate typedoc', e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateTypedoc(root: string, outputPath = typedocTmp) {
|
async function generateTypedoc(root: string, outputPath = typedocTmp) {
|
||||||
const pluginDirs = await fs.readdir(root);
|
const pluginDirs = await fs.readdir(root);
|
||||||
const paths = pluginDirs.map(dir => resolve(root, dir, 'index.ts'));
|
const paths = pluginDirs.map(dir => resolve(root, dir, 'index.ts'));
|
||||||
typedoc.generateJson(paths, outputPath);
|
typedoc.bootstrap({
|
||||||
|
/*
|
||||||
|
mode: 'modules',
|
||||||
|
ignoreCompilerErrors: true,
|
||||||
|
*/
|
||||||
|
entryPoints: paths,
|
||||||
|
tsconfig: `tsconfig.json`,
|
||||||
|
});
|
||||||
|
const project = typedoc.converter.convert(typedoc.getEntryPoints() ?? []);
|
||||||
|
|
||||||
|
await typedoc.generateJson(project, outputPath);
|
||||||
|
|
||||||
return fs.readJson(outputPath);
|
return fs.readJson(outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processPlugin(pluginModule): Plugin {
|
function processPlugin(pluginModule): Plugin {
|
||||||
const pluginClass = pluginModule.children.find(isPlugin);
|
const pluginClass = pluginModule.children.find(isPlugin);
|
||||||
|
console.log(pluginClass);
|
||||||
const decorator = getPluginDecorator(pluginClass);
|
const decorator = getPluginDecorator(pluginClass);
|
||||||
const packageName = `@ionic-native/${basename(dirname(pluginModule.originalName))}`;
|
const packageName = `@ionic-native/${basename(dirname(pluginModule.originalName))}`;
|
||||||
const displayName = getTag(pluginClass, 'name');
|
const displayName = getTag(pluginClass, 'name');
|
||||||
@ -84,6 +95,8 @@ function processPlugin(pluginModule): Plugin {
|
|||||||
const getPluginDecorator = (child: any) => {
|
const getPluginDecorator = (child: any) => {
|
||||||
if (isPlugin(child)) {
|
if (isPlugin(child)) {
|
||||||
const decorator = child.decorators.find(d => d.name === 'Plugin');
|
const decorator = child.decorators.find(d => d.name === 'Plugin');
|
||||||
|
|
||||||
|
console.log('Found decorator', decorator.arguments, child);
|
||||||
return runInNewContext(`(${decorator.arguments.config})`);
|
return runInNewContext(`(${decorator.arguments.config})`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
"target": "es5",
|
"target": "es5",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
"lib": ["es6"]
|
"lib": ["es6"],
|
||||||
|
"paths": {
|
||||||
|
"@ionic-native/core": ["../src/@ionic-native/core"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user