in build-scripts/build_api_helpers.ts [60:120]
export function generateDocs(libs: LibraryInfo[]): string[] {
const docGenScript = 'build-scripts/doc-gen/make-api.ts';
const outputPaths = [];
libs.forEach(lib => {
const outputPath =
path.resolve(`${lib.outputFolder}/${lib.packageName}.json`);
const repoName = lib.repoName || 'tfjs';
const opts = {
input: path.resolve(`libs/${repoName}/${lib.packageName}/src/index.ts`),
pkg: path.resolve(`libs/${repoName}/${lib.packageName}/package.json`),
src: path.resolve(`libs/${repoName}/${lib.packageName}/src/`),
repo: path.resolve(`libs/${repoName}/${lib.packageName}/`),
github: lib.github,
out: outputPath,
allowedDeclarationFileSubpaths: lib.allowedDeclarationFileSubpaths ?
lib.allowedDeclarationFileSubpaths.join(',') :
'""',
};
const docGenCommand = `ts-node --project tsconfig.json ${docGenScript} ` +
`--in ${opts.input} --package ${opts.pkg} --src ${opts.src} --github ${
opts.github} --out ${opts.out} --repo ${
opts.repo} --allowed-declaration-file-subpaths ${
opts.allowedDeclarationFileSubpaths}`;
// Prep the component. If "local" has been passed in then we do nothing
// to what is in libs. Else we want to check out a tag that correspond to
// to the version specified the component.
if (!commander.local) {
const identifier =
(lib.packageName !== 'tfjs-vis' &&
lib.packageName !== 'tfjs-react-native' &&
lib.packageName !== 'tfjs-tflite' && lib.packageName !== 'tasks') ?
'tfjs' :
lib.packageName;
const checkoutCommand = `cd libs/${repoName} \
&& git fetch --tags --force \
&& git checkout ${identifier}-v${lib.version}`;
sh(checkoutCommand,
`Error checkout out ${lib.version} for ${lib.packageName}`);
}
console.log(`********* Generating docs for ${lib.packageName} *********`);
sh('pwd', `Error pwd`);
const buildCommand =
`cd libs/${repoName}/${
lib.packageName} && yarn install --frozen-lockfile` +
` && cd ../../.. && ${docGenCommand}`;
console.log('buildcommand ', buildCommand);
sh(buildCommand, `Error building docs for ${lib.packageName}`);
outputPaths.push(outputPath);
});
return outputPaths;
}