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 index page to left ToC for Runtime and Provider #1269

Merged
merged 17 commits into from
May 2, 2024
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
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-provider/0.10/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit IBM Provider (deprecated)",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-provider/0.10"
},
{
"title": "qiskit_ibm_provider",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-provider/0.7/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit IBM Provider (deprecated)",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-provider/0.7"
},
{
"title": "qiskit_ibm_provider",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-provider/0.8/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit IBM Provider (deprecated)",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-provider/0.8"
},
{
"title": "qiskit_ibm_provider",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-provider/0.9/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit IBM Provider (deprecated)",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-provider/0.9"
},
{
"title": "qiskit_ibm_provider",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-provider/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit IBM Provider (deprecated)",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-provider"
},
{
"title": "qiskit_ibm_provider",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.14/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.14"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.15/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.15"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.16/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.16"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.17/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.17"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.18/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.18"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.19/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.19"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.20/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.20"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.21/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.21"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/0.22/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/0.22"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
4 changes: 4 additions & 0 deletions docs/api/qiskit-ibm-runtime/dev/_toc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"title": "Qiskit Runtime IBM Client",
"children": [
{
"title": "API index",
"url": "/api/qiskit-ibm-runtime/dev"
},
{
"title": "qiskit_ibm_runtime",
"children": [
Expand Down
3 changes: 0 additions & 3 deletions scripts/commands/checkOrphanPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ function apiDocsIgnores(): string[] {

return [
...versions.flatMap((vers) => [
`/api/qiskit-ibm-runtime/${vers}index`,
`/api/qiskit-ibm-provider/${vers}index`,
`/api/qiskit-ibm-runtime/${vers}qiskit_ibm_runtime.Estimator`,
`/api/qiskit-ibm-runtime/${vers}qiskit_ibm_runtime.Sampler`,
`/api/qiskit/${vers}aer`,
Expand All @@ -195,7 +193,6 @@ function apiDocsIgnores(): string[] {
`/api/qiskit/${vers}parallel`,
`/api/qiskit/${vers}transpiler_builtin_plugins`,
]),
`/api/qiskit/0.19/index`,
`/api/qiskit/dev/qiskit.primitives.BaseEstimator`,
`/api/qiskit/dev/qiskit.primitives.BaseSampler`,
];
Expand Down
4 changes: 4 additions & 0 deletions scripts/lib/api/__snapshots__/conversionPipeline.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ exports[`qiskit-sphinx-theme: _toc 1`] = `
"{
"title": "Qiskit Sphinx Theme",
"children": [
{
"title": "API index",
"url": "/api/qiskit-sphinx-theme"
},
{
"title": "api_example",
"children": [
Expand Down
12 changes: 10 additions & 2 deletions scripts/lib/api/generateToc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ describe("generateToc", () => {
test("TOC with grouped modules", () => {
// This ordering is intentional.
const topLevelEntries: TocGroupingEntry[] = [
{ moduleId: "my_quantum_project", title: "API index", kind: "module" },
{
moduleId: "my_quantum_project",
title: "API index (custom)",
kind: "module",
},
{ name: "Group 2", kind: "section" },
{ name: "Group 1", kind: "section" },
{
Expand Down Expand Up @@ -236,7 +240,7 @@ describe("generateToc", () => {
title: "My Quantum Project",
children: [
{
title: "API index",
title: "API index (custom)",
url: "/api/my-quantum-project",
},
{
Expand Down Expand Up @@ -354,6 +358,10 @@ describe("generateToc", () => {

expect(toc).toEqual({
children: [
{
title: "API index",
url: "/api/my-quantum-project",
},
{
title: "Release notes",
url: "/api/my-quantum-project/release-notes",
Expand Down
23 changes: 23 additions & 0 deletions scripts/lib/api/generateToc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export function generateToc(pkg: Pkg, results: HtmlToMdResultWithUrl[]): Toc {
}

generateOverviewPage(tocModules);
const maybeIndexPage = ensureIndexPage(pkg, sortedTocModules);
if (maybeIndexPage) {
sortedTocModules.unshift(maybeIndexPage);
}

return {
title: pkg.title,
Expand Down Expand Up @@ -231,6 +235,25 @@ function sortAndTruncateModules(entries: TocEntry[]): TocEntry[] {
return sorted;
}

/**
* Create a new TocEntry pointing to the index page if is not already there.
*
* Certain APIs like Runtime and Provider do not have the index page included,
* whereas Qiskit SDK already does.
*/
function ensureIndexPage(
pkg: Pkg,
tocModules: TocEntry[],
): TocEntry | undefined {
const docsFolder = pkg.outputDir("/");
return tocModules.some((entry) => entry.url === docsFolder)
? undefined
: {
title: "API index",
url: docsFolder,
};
}

function generateOverviewPage(tocModules: TocEntry[]): void {
for (const tocModule of tocModules) {
if (tocModule.children && tocModule.children.length > 0) {
Expand Down
Loading