Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use arbitrary Sphinx HTML artifact folder #1336

Merged
merged 3 commits into from
May 9, 2024
Merged
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
26 changes: 19 additions & 7 deletions scripts/commands/updateApiDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface Arguments {
historical: boolean;
dev: boolean;
skipDownload: boolean;
sphinxArtifactFolder?: string;
}

const readArgs = (): Arguments => {
Expand Down Expand Up @@ -60,6 +61,14 @@ const readArgs = (): Arguments => {
description:
"Rather than downloading the artifact from Box, reuse what is already downloaded. This can save time, but it risks using an outdated version of the docs.",
})
.option("sphinx-artifact-folder", {
alias: "a",
type: "string",
implies: "skip-download",
normalize: true,
description:
"Skip downloading the artifact from Box and instead use the given directory as the root of the Sphinx HTML output.",
})
.parseSync();
};

Expand All @@ -85,12 +94,7 @@ zxMain(async () => {
await deleteExistingMarkdown(pkg);

console.log(`Run pipeline for ${pkg.name}:${pkg.versionWithoutPatch}`);
await runConversionPipeline(
`${sphinxArtifactFolder}/artifact`,
"docs",
"public",
pkg,
);
await runConversionPipeline(sphinxArtifactFolder, "docs", "public", pkg);
});

function determineMinorVersion(args: Arguments): string {
Expand All @@ -112,6 +116,14 @@ function determineMinorVersion(args: Arguments): string {
}

async function prepareSphinxFolder(pkg: Pkg, args: Arguments): Promise<string> {
if (args.sphinxArtifactFolder) {
if (!(await pathExists(args.sphinxArtifactFolder))) {
throw new Error(
`Explicit artifact path '${args.sphinxArtifactFolder}' does not exist.`,
);
}
return args.sphinxArtifactFolder;
}
const sphinxArtifactFolder = pkg.sphinxArtifactFolder();
if (
args.skipDownload &&
Expand All @@ -123,7 +135,7 @@ async function prepareSphinxFolder(pkg: Pkg, args: Arguments): Promise<string> {
} else {
await downloadSphinxArtifact(pkg, sphinxArtifactFolder);
}
return sphinxArtifactFolder;
return `${sphinxArtifactFolder}/artifact`;
}

async function deleteExistingMarkdown(pkg: Pkg): Promise<void> {
Expand Down
Loading