Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Since our base directory is the Bazel execroot, we need to make sure that Dgeni can
// find all templates needed to output the API docs.
templateFinder.templateFolders = [join(execRootPath, 'tools/dgeni/templates/')];
// The output path for files will be computed by joining the output folder with the base path
// from the "readFilesProcessors". Since the base path is the execroot, we can just use
// the output path passed from Bazel (e.g. $EXECROOT/bazel-out/bin/src/docs-content)
writeFilesProcessor.outputFolder = outputDirPath;
});
// Run the docs generation. The process will be automatically kept alive until Dgeni
// completed. In case the returned promise has been rejected, we need to manually exit the
// process with the proper exit code because Dgeni doesn't use native promises which would
// automatically cause the error to propagate.
new Dgeni([apiDocsPackage]).generate().catch((e: any) => {
console.error(e);
process.exit(1);
});
}
// tslint:disable-next-line: no-non-null-assertion
tsParser.options.paths!['*'] = [relative(packagePath, join(execRootPath, 'node_modules/*'))];
// Since our base directory is the Bazel execroot, we need to make sure that Dgeni can
// find all templates needed to output the API docs.
templateFinder.templateFolders = [
join(execRootPath, 'schematics/documentation/dgeni/templates/')
];
// The output path for files will be computed by joining the output folder with the base path
// from the "readFilesProcessors". Since the base path is the execroot, we can just use
// the output path passed from Bazel (e.g. $EXECROOT/bazel-out/bin/src/docs-content)
writeFilesProcessor.outputFolder = outputDirPath;
});
const docs = new Dgeni([apiDocsPackage]);
await docs.generate().catch((e: any) => {
console.error(e);
process.exit(1);
});
}
function next(error) {
if (error) {
console.log(error);
}
}
let p = Promise.resolve();
if (process.argv.indexOf('--watch-only') === -1) {
console.log('================================================================');
console.log('Running initial doc generation');
console.log('----------------------------------------------------------------');
console.log('Skip the full doc-gen by running: `yarn docs-watch --watch-only`');
console.log('================================================================');
const {Dgeni} = require('dgeni');
const dgeni = new Dgeni([require('../angular.io-package')]);
// Turn off all the potential failures for this doc-gen one-off run.
// This enables authors to run `docs-watch` while the docs are still in an unstable state.
const injector = dgeni.configureInjector();
injector.get('linkInlineTagDef').failOnBadLink = false;
injector.get('checkAnchorLinksProcessor').$enabled = false;
injector.get('renderExamples').ignoreBrokenExamples = true;
p = dgeni.generate();
}
p.then(() => {
console.log('===================================================================');
console.log('Started watching files in:');
console.log(' - ', CONTENTS_PATH);
console.log(' - ', API_SOURCE_PATH);
function setupTestDgeniInstance(configureFn?: (host: Host) => void) {
const testPackage = mockPackage() as Package;
if (configureFn) {
testPackage.config((tsHost: Host) => configureFn(tsHost));
}
const dgeni = new Dgeni([testPackage]);
const injector = dgeni.configureInjector();
// Load factories from the Dgeni injector.
host = injector.get('tsHost');
parser = injector.get('tsParser');
}
import { Dgeni } from 'dgeni';
import { resolve } from 'path';
const argv = require('yargs').argv;
const packagePaths = argv._;
const packages = packagePaths.map(packagePath => {
if (packagePath.indexOf('.') === 0) {
packagePath = resolve(packagePath);
}
return require('../' + packagePath).default;
});
new Dgeni(packages)
.generate()
.then(docs => {
console.log(`${docs.length} docs generated.`);
})
.catch(err => {
console.error(err);
process.exit(1);
});
rimraf('../../dist/docs/**/*', function() {
new Dgeni([guideDocPackage]).generate().catch(() => process.exit(1));
new Dgeni([apiDocs]).generate().catch(() => process.exit(1));
});
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
tsProcessor = injector.get('readTypeScriptModules');
parseTagsProcessor = injector.get('parseTagsProcessor');
extractTagsProcessor = injector.get('extractTagsProcessor');
mergeParameterInfoProcessor = injector.get('mergeParameterInfo');
tsProcessor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
tsProcessor.sourceFiles = ['methodParameters.ts'];
});
task('api-docs', () => {
const docs = new Dgeni([apiDocsPackage]);
return docs.generate();
});
task('api-docs', () => {
const docsPackage = require(path.resolve(__dirname, '../../dgeni'));
const docs = new Dgeni([docsPackage]);
return docs.generate();
});
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
tsProcessor = injector.get('readTypeScriptModules');
linkProcessor = injector.get('linkInheritedDocs');
tsProcessor.basePath = path.resolve(__dirname, '../mocks/linkInheritedDocs');
tsProcessor.sourceFiles = ['index.ts', 'deps.ts'];
});