feat(v2): allow skipping build docs for next version (#2877)

* feat(v2): allow skipping build docs for next version

* Refactor

* Refactor

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
This commit is contained in:
Alexey Pyltsyn 2020-06-25 18:21:05 +03:00 committed by GitHub
parent 8304e8253c
commit bdffd28b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 24 deletions

View file

@ -63,6 +63,7 @@ const DEFAULT_OPTIONS: PluginOptions = {
showLastUpdateTime: false,
showLastUpdateAuthor: false,
admonitions: {},
excludeNextVersionDocs: false,
};
function getFirstDocLinkOfSidebar(
@ -175,8 +176,12 @@ export default function pluginContentDocs(
// Prepare metadata container.
const docsMetadataRaw: DocsMetadataRaw = {};
const docsPromises = [];
const includeDefaultDocs = !(
options.excludeNextVersionDocs && process.argv[2] === 'build'
);
// Metadata for default/master docs files.
if (includeDefaultDocs) {
const docsFiles = await globby(include, {
cwd: docsDir,
});
@ -194,6 +199,7 @@ export default function pluginContentDocs(
}),
),
);
}
// Metadata for versioned docs.
if (versioning.enabled) {
@ -222,13 +228,14 @@ export default function pluginContentDocs(
}
// Load the sidebars and create docs ordering.
const sidebarPaths = [
sidebarPath,
...versionsNames.map(
(versionName) =>
`${versionedSidebarsDir}/${versionName}-sidebars.json`,
),
];
const sidebarPaths = versionsNames.map(
(versionName) => `${versionedSidebarsDir}/${versionName}-sidebars.json`,
);
if (includeDefaultDocs) {
sidebarPaths.unshift(sidebarPath);
}
const loadedSidebars: Sidebar = loadSidebars(sidebarPaths);
const order: Order = createOrder(loadedSidebars);

View file

@ -25,6 +25,7 @@ export interface PluginOptions extends MetadataOptions, PathOptions {
remarkPlugins: ([Function, object] | Function)[];
rehypePlugins: string[];
admonitions: any;
excludeNextVersionDocs: boolean;
}
export type SidebarItemDoc = {

View file

@ -288,6 +288,12 @@ module.exports = {
* Whether to display the last date the doc was updated.
*/
showLastUpdateTime: false,
/**
* Skip the next release docs when versioning is enabled.
* This will not generate HTML files in the production build for documents
* in `/docs/next` directory, only versioned docs.
*/
excludeNextVersionDocs: false,
},
],
],