From f8aaea3c1497854c59cdcf232632ec0b5cbfbe8d Mon Sep 17 00:00:00 2001 From: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com> Date: Tue, 7 May 2024 08:36:59 -0400 Subject: [PATCH] Allow not setting githubSlug (#1308) The new Qiskit transpiler service client will not have GitHub links when we first add it. --- scripts/lib/api/Pkg.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/lib/api/Pkg.ts b/scripts/lib/api/Pkg.ts index d4b57c8dcea..d9e6c45673e 100644 --- a/scripts/lib/api/Pkg.ts +++ b/scripts/lib/api/Pkg.ts @@ -35,7 +35,7 @@ type PackageType = "latest" | "historical" | "dev"; export class Pkg { readonly name: string; readonly title: string; - readonly githubSlug: string; + readonly githubSlug?: string; readonly version: string; readonly versionWithoutPatch: string; readonly type: PackageType; @@ -48,7 +48,7 @@ export class Pkg { constructor(kwargs: { name: string; title: string; - githubSlug: string; + githubSlug?: string; version: string; versionWithoutPatch: string; type: PackageType; @@ -130,7 +130,7 @@ export class Pkg { return new Pkg({ name: kwargs.name ?? "my-quantum-project", title: kwargs.title ?? "My Quantum Project", - githubSlug: kwargs.githubSlug ?? "qiskit/my-quantum-project", + githubSlug: kwargs.githubSlug, version: kwargs.version ?? "0.1.0", versionWithoutPatch: kwargs.versionWithoutPatch ?? "0.1", type: kwargs.type ?? "latest", @@ -191,6 +191,12 @@ export class Pkg { * `sphinx.ext.viewcode`, which means we need to deal with its quirks like handling `__init__.py`. */ determineGithubUrlFn(): (fileName: string) => string { + if (!this.githubSlug) { + throw new Error( + `Encountered sphinx.ext.viewcode link, but Pkg.githubSlug is not set for ${this.name}`, + ); + } + // For files like `my_module/__init__.py`, `sphinx.ext.viewcode` will title the // file `my_module.py`. We need to add back the `/__init__.py` when linking to GitHub. const convertToInitPy = new Set([