Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/generators/json-simple/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ export default {
// This simply grabs all the different files and stringifies them
const stringifiedContent = JSON.stringify(mappedInput);

// Writes all the API docs stringified content into one file
// Note: The full JSON generator in the future will create one JSON file per top-level API doc file
await writeFile(join(options.output, 'api-docs.json'), stringifiedContent);
if (options.output) {
// Writes all the API docs stringified content into one file
// Note: The full JSON generator in the future will create one JSON file per top-level API doc file
await writeFile(
join(options.output, 'api-docs.json'),
stringifiedContent
);
}

return mappedInput;
},
};
8 changes: 6 additions & 2 deletions src/generators/legacy-html-all/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getRemarkRehype } from '../../utils/remark.mjs';
*
* @typedef {Array<TemplateValues>} Input
*
* @type {import('../types.d.ts').GeneratorMetadata<Input, void>}
* @type {import('../types.d.ts').GeneratorMetadata<Input, string>}
*/
export default {
name: 'legacy-html-all',
Expand Down Expand Up @@ -96,6 +96,10 @@ export default {
minifyJS: true,
});

await writeFile(join(output, 'all.html'), minified);
if (output) {
await writeFile(join(output, 'all.html'), minified);
}

return minified;
},
};
48 changes: 26 additions & 22 deletions src/generators/legacy-html/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,34 @@ export default {
for (const node of headNodes) {
const result = processModuleNodes(node);

// We minify the html result to reduce the file size and keep it "clean"
const minified = await minify(result, {
collapseWhitespace: true,
minifyJS: true,
});

await writeFile(join(output, `${node.api}.html`), minified);
if (output) {
// We minify the html result to reduce the file size and keep it "clean"
const minified = await minify(result, {
collapseWhitespace: true,
minifyJS: true,
});

await writeFile(join(output, `${node.api}.html`), minified);
}
}

// Define the output folder for API docs assets
const assetsFolder = join(output, 'assets');

// Removes the current assets directory to copy the new assets
// and prevent stale assets from existing in the output directory
// If the path does not exists, it will simply ignore and continue
await rm(assetsFolder, { recursive: true, force: true });

// We copy all the other assets to the output folder at the end of the process
// to ensure that all latest changes on the styles are applied to the output
// Note.: This is not meant to be used for DX/developer purposes.
await cp(join(baseDir, 'assets'), assetsFolder, {
recursive: true,
force: true,
});
if (output) {
// Define the output folder for API docs assets
const assetsFolder = join(output, 'assets');

// Removes the current assets directory to copy the new assets
// and prevent stale assets from existing in the output directory
// If the path does not exists, it will simply ignore and continue
await rm(assetsFolder, { recursive: true, force: true });

// We copy all the other assets to the output folder at the end of the process
// to ensure that all latest changes on the styles are applied to the output
// Note.: This is not meant to be used for DX/developer purposes.
await cp(join(baseDir, 'assets'), assetsFolder, {
recursive: true,
force: true,
});
}

return generatedValues;
},
Expand Down
Loading