Skip to content

Commit

Permalink
Allow not setting githubSlug (Qiskit#1308)
Browse files Browse the repository at this point in the history
The new Qiskit transpiler service client will not have GitHub links when
we first add it.
  • Loading branch information
Eric-Arellano authored May 7, 2024
1 parent 74ca780 commit c5923fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/lib/api/Pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -48,7 +48,7 @@ export class Pkg {
constructor(kwargs: {
name: string;
title: string;
githubSlug: string;
githubSlug?: string;
version: string;
versionWithoutPatch: string;
type: PackageType;
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit c5923fd

Please sign in to comment.