Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const json = options.json;
delete options.json;
const version = options.version;
delete options.version;
if (!options.logger) {
// reduce console logging
options.logger = function(message, level, newline) {
if (level === 3) {
log(colors.red(message));
}
};
}
// typedoc instance
const app = new typedocModule.Application(options);
if (version && options.logger !== "none") {
log(app.toString());
}
try {
const src = app.expandInputFiles(files);
const project = app.convert(src);
if (project) {
if (out) app.generateDocs(project, out);
if (json) app.generateJson(project, json);
if (app.logger.hasErrors()) {
stream.emit("error", new PluginError(PLUGIN_NAME, "There were errors generating TypeDoc output, see above."));
stream.emit("end");
return;
}
} else {
task('document', async ctx => {
const TypeDoc = require('typedoc');
const typedocApp = new TypeDoc.Application({
experimentalDecorators: true,
logger: 'console',
mode: 'modules',
module: 'CommonJS',
target: 'ES6',
ignoreCompilerErrors: true,
excludePrivate: true,
excludeExternals: true,
allowJs: false,
exclude: '**/*.test.ts',
});
const typedocProject = typedocApp.convert(typedocApp.expandInputFiles(['src/core/FuseBox.ts']));
if (typedocProject) {
// Project may not have converted correctly
import { readdirSync, readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { Application } from 'typedoc';
const packagesDir = resolve(__dirname, '..', '..', 'packages');
const apiDocsDir = resolve(__dirname, '..', '..', 'website', 'docs', 'api');
let dirs = readdirSync(packagesDir);
// Do not build the docs for these packages
const excludeDirs = ['database-tests', 'e2e', 'error', 'types'];
// Config for typedoc;
const app = new Application({
theme: 'markdown',
module: 'commonjs',
mode: 'file',
ignoreCompilerErrors: true,
excludePrivate: true,
excludeNotExported: true,
tsconfig: 'tsconfig.json',
});
// Do not build the docs for these packages
dirs = dirs.filter(dir => !excludeDirs.includes(dir));
dirs.forEach(dir => {
// Generate the api doc for each package
app.generateDocs(
app.expandInputFiles([resolve(packagesDir, dir, 'src')]),
async function onEvent(event, path) {
try {
const app = new Application({
...config.compilerOptions,
mode: "file",
readme: "none",
theme: "markdown",
gitRevision: "master",
logger: () => {},
// Exclude everything except public APIs
excludeExternals: true,
excludePrivate: true,
excludeProtected: true,
excludeNotExported: true
});
let files;
function buildDocsForPackage(pkg) {
const app = new TypeDoc.Application({
mode: 'file',
target: 'ES6',
module: 'es6',
moduleResolution: 'node',
exclude: '**/__tests__/**',
ignoreCompilerErrors: true,
excludePrivate: true,
excludeNotExported: true,
stripInternal: true,
excludeExternals: true,
suppressExcessPropertyErrors: true,
suppressImplicitAnyIndexErrors: true,
readme: 'none',
});
console.log(`Generating docs for ${pkg.dirName}`);
beforeAll(() => {
app = new Application({
mode: 'file',
module: 'CommonJS',
target: 'ES5',
readme: 'none',
theme: 'markdown',
logger: 'none',
plugin: path.join(__dirname, '../../../dist/index'),
});
app.convert(['./test/stubs/functions.ts']);
app.renderer.addComponent('frontmatter', new FrontMatterComponent(app.renderer));
frontMatterComponent = app.renderer.getComponent('frontmatter');
});
import { Application } from 'typedoc';
const app = new Application({
experimentalDecorators: true,
ignoreCompilerErrors: false,
listInvalidSymbolLinks: true,
theme: 'markdown',
readme: 'none',
excludePrivate: true,
excludeProtected: true,
excludeNotExported: true,
target: 'ES2017',
tsconfig: './tsconfig.js',
});
const project = app.convert(app.expandInputFiles(['src']));
if (project) app.generateDocs(project, 'docs');
const getJSON = (src) =>
_.chain(new typedoc.Application({
exclude: '**/node_modules/**',
ignoreCompilerErrors: true,
includeDeclarations: true
}))
.thru((app) => app
.convert([src])
.toObject()
)
//.tap((v) => require('fs').writeFileSync('./full.json', JSON.stringify(v, false, 4)))
.get('children[0].children')
.filter(({comment}) => comment)
//.tap((v) => require('fs').writeFileSync('./tmp.json', JSON.stringify(v, false, 4)))
.value()
if (!fs.existsSync(tsconfigPath)) {
const json: TDNode = {
id: 0,
name: path.basename(folder),
kind: 0,
kindString: undefined,
flags: {
},
originalName: path.basename(folder),
folder
};
fs.writeFile(docCache, JSON.stringify(json, undefined, 4), err => {
resolve(json);
});
} else {
const app = new TypeDoc.Application({
tsconfig: `${folder}/tsconfig.js`
});
const project = app.convert(app.expandInputFiles([`${folder}/src`]));
if (project) {
const json = app.serializer.projectToObject(project);
fs.writeFile(docCache, JSON.stringify(json, undefined, 4), err => {
resolve(json);
});
app.generateDocs(project, `./api/${path.basename(folder)}`);
} else {
reject("Error parsing typescript");
}
}
});
}