Skip to content

Commit

Permalink
Fix span tag id=undefined and fix /api/qiskit/index entry (Qiskit#500)
Browse files Browse the repository at this point in the history
This PR fixes the issue with the undefined span IDs when generating the
documentation and transforms the `/api/qiskit/index` entry in the toc
file to `/api/qiskit`. A new test has been added to verify we don't
generate span tags with an undefined id.

The Qiskit docs have been regenerated to verify the correct behavior of
the script for the current version. The changes in the docs files are
empty lines matching the great work done by @Eric-Arellano in Qiskit#484
removing the tags manually.

Closes Qiskit#485
Closes Qiskit#227
  • Loading branch information
arnaucasau authored Dec 8, 2023
1 parent 63fa429 commit 6826c1a
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 40 deletions.
2 changes: 1 addition & 1 deletion docs/api/qiskit-ibm-provider/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"children": [
{
"title": "Overview",
"url": "/api/qiskit-ibm-provider/index"
"url": "/api/qiskit-ibm-provider"
},
{
"title": "IBMBackend",
Expand Down
2 changes: 1 addition & 1 deletion docs/api/qiskit-ibm-runtime/0.14/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"children": [
{
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/0.14/index"
"url": "/api/qiskit-ibm-runtime/0.14/"
},
{
"title": "Estimator",
Expand Down
2 changes: 1 addition & 1 deletion docs/api/qiskit-ibm-runtime/0.15/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"children": [
{
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/0.15/index"
"url": "/api/qiskit-ibm-runtime/0.15"
},
{
"title": "Estimator",
Expand Down
2 changes: 1 addition & 1 deletion docs/api/qiskit-ibm-runtime/_toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"children": [
{
"title": "Overview",
"url": "/api/qiskit-ibm-runtime/index"
"url": "/api/qiskit-ibm-runtime"
},
{
"title": "Estimator",
Expand Down
4 changes: 0 additions & 4 deletions docs/api/qiskit/qiskit.algorithms.eigensolvers.VQD.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ A classical optimizer or a list of optimizers,

[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]



### one for every k-th eigenvalue. Can either be a Qiskit optimizer or a callable

that takes an array as input and returns a Qiskit or SciPy optimization result.
Expand All @@ -94,8 +92,6 @@ Beta parameters in the VQD paper. Should have length k - 1, with k the number of

[list](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")]



### initial point

An optional initial point (i.e. initial parameter values) or a list of initial points (one for every k-th eigenvalue) for the optimizer. If `None` then VQD will look to the ansatz for a preferred point and if not will simply compute a random one.
Expand Down
2 changes: 0 additions & 2 deletions docs/api/qiskit/qiskit.providers.BackendV1.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ Initialize a backend class

In addition to the public abstract methods, subclasses should also implement the following private methods:



`abstract classmethod _default_options()`

Return the default options
Expand Down
2 changes: 0 additions & 2 deletions docs/api/qiskit/qiskit.providers.basicaer.QasmSimulatorPy.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Initialize a backend class

In addition to the public abstract methods, subclasses should also implement the following private methods:



`classmethod _default_options()`

Return the default options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Initialize a backend class

In addition to the public abstract methods, subclasses should also implement the following private methods:



`classmethod _default_options()`

Return the default options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Initialize a backend class

In addition to the public abstract methods, subclasses should also implement the following private methods:



`classmethod _default_options()`

Return the default options
Expand Down
22 changes: 0 additions & 22 deletions docs/api/qiskit/qiskit.transpiler.passes.NoiseAdaptiveLayout.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ Choose a noise-adaptive Layout based on current calibration data for the backend
>
> The pass implements the qubit mapping method from: Noise-Adaptive Compiler Mappings for Noisy Intermediate-Scale Quantum Computers Prakash Murali, Jonathan M. Baker, Ali Javadi-Abhari, Frederic T. Chong, Margaret R. Martonosi ASPLOS 2019 (arXiv:1901.11054).


`Ordering of edges`



`Map qubits edge-by-edge in the order of decreasing frequency of occurrence in the program dag.`

### Initialization
Expand All @@ -34,40 +30,22 @@ Choose a noise-adaptive Layout based on current calibration data for the backend

`Initialization()`



`If an edge exists with both endpoints unmapped,`



`pick the best available hardware cx to execute this edge.`



`Iterative step`



`When an edge exists with one endpoint unmapped,`



`map that endpoint to a location which allows`



`maximum reliability for CNOTs with previously mapped qubits.`



`In the end if there are unmapped qubits (which don't`



`participate in any CNOT), map them to any available`



`hardware qubit.`

### Notes
Expand Down
3 changes: 2 additions & 1 deletion scripts/lib/sphinx/generateToc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export function generateToc(
const tocModules = modules.map(
(module): TocEntry => ({
title: module.meta.python_api_name!,
url: module.url,
// Remove the final /index from the url
url: module.url.replace(/\/index$/, ""),
}),
);
const tocModulesByTitle = keyBy(tocModules, (toc) => toc.title);
Expand Down
53 changes: 53 additions & 0 deletions scripts/lib/sphinx/sphinxHtmlToMarkdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,59 @@ test("identify release notes", async () => {
`);
});

// This test checks that the conversion to markdown is correct when we have a <dt class=sig-object"> tag
// without id. For more information: https://github.com/Qiskit/documentation/issues/485
test("test dt tag without id", async () => {
expect(
await toMd(`
<div role="main">
<p>In addition to the public abstract methods, subclasses should also implement the following
private methods:</p>
<dl class="py method">
<dt class="sig sig-object py">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">_default_options</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/qiskit/providers/basicaer/qasm_simulator.html#QasmSimulatorPy._default_options"><span class="viewcode-link"><span class="pre">[source]</span></span></a></dt>
<dd><p>Return the default options</p>
<p>This method will return a <a class="reference internal" href="qiskit.providers.Options.html#qiskit.providers.Options" title="qiskit.providers.Options"><code class="xref py py-class docutils literal notranslate"><span class="pre">qiskit.providers.Options</span></code></a>
subclass object that will be used for the default options. These
should be the default parameters to use for the options of the
backend.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns<span class="colon">:</span></dt>
<dd class="field-odd"><p><dl class="simple">
<dt>A options object with</dt><dd><p>default values set</p>
</dd>
</dl>
</p>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference internal" href="qiskit.providers.Options.html#qiskit.providers.Options" title="qiskit.providers.Options">qiskit.providers.Options</a></p>
</dd>
</dl>
</dd></dl>
</div>
`),
).toMatchInlineSnapshot(`
"In addition to the public abstract methods, subclasses should also implement the following private methods:
\`classmethod _default_options()\`
Return the default options
This method will return a [\`qiskit.providers.Options\`](qiskit.providers.Options#qiskit.providers.Options "qiskit.providers.Options") subclass object that will be used for the default options. These should be the default parameters to use for the options of the backend.
**Returns**
**A options object with**
default values set
**Return type**
[qiskit.providers.Options](qiskit.providers.Options#qiskit.providers.Options "qiskit.providers.Options")
"
`);
});

async function toMd(html: string) {
return (
await sphinxHtmlToMarkdown({
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/sphinx/sphinxHtmlToMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export async function sphinxHtmlToMarkdown(options: {
.map((child) => {
const $child = $page(child);
$child.find(".viewcode-link").closest("a").remove();
const id = $dl.find("dt.sig-object").attr("id");
const id = $dl.find("dt.sig-object").attr("id") || "";

if (child.name === "dt" && $dl.hasClass("class")) {
if (!meta.python_api_type) {
Expand Down

0 comments on commit 6826c1a

Please sign in to comment.