Skip to content

Commit

Permalink
API generation script: fix attributes headings (Qiskit#1153)
Browse files Browse the repository at this point in the history
Closes Qiskit#1120 

This PR changes the script to use the `name` extracted from the
`signature` of the attributes instead of using the `id` to create the
`<h3>`s. This behavior was changed in Qiskit#1026, but It broke a couple of
headings.

It also fixes two attributes of `qiskit.algorithms.eigensolvers.VQD`
manually modifying the artifacts stored in
[Box](https://ibm.ent.box.com/folder/246867452622?s=tqmvw6ldivzkhh934nhufan4rg3dregr)
for versions 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45 and 0.46. See more
at Qiskit#1120
  • Loading branch information
arnaucasau authored Apr 10, 2024
1 parent 3493637 commit b3396ed
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 124 deletions.
2 changes: 1 addition & 1 deletion docs/api/qiskit/0.19/qiskit.validation.BaseSchema.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python_api_name: qiskit.validation.BaseSchema
type
</Attribute>

###
### constructor is passed all named parameters from deserialization.

<Attribute name="constructor is passed all named parameters from deserialization." />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ python_api_name: qiskit.providers.ibmq.managed.ManagedResults
* **backend\_name** (`str`) – Name of the backend used to run the experiments.
* **success** (`bool`) – `True` if all experiments were successful and results available. `False` otherwise.

### id0
### backend\_name

<Attribute id="id0" name="backend_name">
Name of the backend used to run the experiments.
</Attribute>

### id1
### success

<Attribute id="id1" name="success">
Whether all experiments were successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ python_api_name: qiskit.providers.ibmq.managed.ManagedResults
* **backend\_name** (`str`) – Name of the backend used to run the experiments.
* **success** (`bool`) – `True` if all experiments were successful and results available. `False` otherwise.

### id0
### backend\_name

<Attribute id="id0" name="backend_name">
Name of the backend used to run the experiments.
</Attribute>

### id1
### success

<Attribute id="id1" name="success">
Whether all experiments were successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ python_api_name: qiskit.providers.ibmq.managed.ManagedResults
* **backend\_name** (`str`) – Name of the backend used to run the experiments.
* **success** (`bool`) – `True` if all experiments were successful and results available. `False` otherwise.

### id0
### backend\_name

<Attribute id="id0" name="backend_name">
Name of the backend used to run the experiments.
</Attribute>

### id1
### success

<Attribute id="id1" name="success">
Whether all experiments were successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ python_api_name: qiskit.providers.ibmq.managed.ManagedResults
* **backend\_name** (`str`) – Name of the backend used to run the experiments.
* **success** (`bool`) – `True` if all experiments were successful and results available. `False` otherwise.

### id0
### backend\_name

<Attribute id="id0" name="backend_name">
Name of the backend used to run the experiments.
</Attribute>

### id1
### success

<Attribute id="id1" name="success">
Whether all experiments were successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ python_api_name: qiskit.providers.ibmq.managed.ManagedResults
* **backend\_name** (`str`) – Name of the backend used to run the experiments.
* **success** (`bool`) – `True` if all experiments were successful and results available. `False` otherwise.

### id0
### backend\_name

<Attribute id="id0" name="backend_name">
Name of the backend used to run the experiments.
</Attribute>

### id1
### success

<Attribute id="id1" name="success">
Whether all experiments were successful.
Expand Down
10 changes: 0 additions & 10 deletions docs/api/qiskit/0.39/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
list\[float]
</Attribute>

###

<Attribute name="initial point">
An optional initial point (i.e. initial parameter values) 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.

**Type**

list\[float]
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
10 changes: 0 additions & 10 deletions docs/api/qiskit/0.40/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
list\[float]
</Attribute>

###

<Attribute name="initial point">
An optional initial point (i.e. initial parameter values) 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.

**Type**

list\[float]
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
10 changes: 0 additions & 10 deletions docs/api/qiskit/0.41/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
list\[float]
</Attribute>

###

<Attribute name="initial point">
An optional initial point (i.e. initial parameter values) 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.

**Type**

list\[float]
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
10 changes: 0 additions & 10 deletions docs/api/qiskit/0.42/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
list\[float]
</Attribute>

###

<Attribute name="initial point">
An optional initial point (i.e. initial parameter values) 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.

**Type**

list\[float]
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
18 changes: 1 addition & 17 deletions docs/api/qiskit/0.43/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
### optimizer

<Attribute id="qiskit.algorithms.eigensolvers.VQD.optimizer" name="optimizer">
A classical optimizer or a list of optimizers,
A classical optimizer or a list of optimizers, 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.

**Type**

[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]
</Attribute>

###

<Attribute name="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.
</Attribute>

### k

<Attribute id="qiskit.algorithms.eigensolvers.VQD.k" name="k">
Expand All @@ -91,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
list\[float]
</Attribute>

###

<Attribute name="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.

**Type**

Sequence\[float] | Sequence\[Sequence\[float]] | None
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
18 changes: 1 addition & 17 deletions docs/api/qiskit/0.44/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
### optimizer

<Attribute id="qiskit.algorithms.eigensolvers.VQD.optimizer" name="optimizer">
A classical optimizer or a list of optimizers,
A classical optimizer or a list of optimizers, 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.

**Type**

[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]
</Attribute>

###

<Attribute name="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.
</Attribute>

### k

<Attribute id="qiskit.algorithms.eigensolvers.VQD.k" name="k">
Expand All @@ -91,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
[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)")]
</Attribute>

###

<Attribute name="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.

**Type**

Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")] | Sequence\[Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")]] | None
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
18 changes: 1 addition & 17 deletions docs/api/qiskit/0.45/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
### optimizer

<Attribute id="qiskit.algorithms.eigensolvers.VQD.optimizer" name="optimizer">
A classical optimizer or a list of optimizers,
A classical optimizer or a list of optimizers, 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.

**Type**

[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]
</Attribute>

###

<Attribute name="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.
</Attribute>

### k

<Attribute id="qiskit.algorithms.eigensolvers.VQD.k" name="k">
Expand All @@ -91,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
[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)")]
</Attribute>

###

<Attribute name="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.

**Type**

Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")] | Sequence\[Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")]] | None
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
18 changes: 1 addition & 17 deletions docs/api/qiskit/0.46/qiskit.algorithms.eigensolvers.VQD.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,13 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
### optimizer

<Attribute id="qiskit.algorithms.eigensolvers.VQD.optimizer" name="optimizer">
A classical optimizer or a list of optimizers,
A classical optimizer or a list of optimizers, 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.

**Type**

[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer") | Sequence\[[Optimizer](qiskit.algorithms.optimizers.Optimizer "qiskit.algorithms.optimizers.Optimizer")]
</Attribute>

###

<Attribute name="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.
</Attribute>

### k

<Attribute id="qiskit.algorithms.eigensolvers.VQD.k" name="k">
Expand All @@ -91,16 +85,6 @@ python_api_name: qiskit.algorithms.eigensolvers.VQD
[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)")]
</Attribute>

###

<Attribute name="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.

**Type**

Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")] | Sequence\[Sequence\[[float](https://docs.python.org/3/library/functions.html#float "(in Python v3.12)")]] | None
</Attribute>

### callback

<Attribute id="qiskit.algorithms.eigensolvers.VQD.callback" name="callback">
Expand Down
4 changes: 2 additions & 2 deletions docs/api/qiskit/dev/qpy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ These functions will raise a custom subclass of [`QiskitError`](exceptions#qiski
Set the error message.
</Class>

### QPY\_VERSION
### qiskit.qpy.QPY\_VERSION

<Attribute id="qiskit.qpy.QPY_VERSION" name="qiskit.qpy.QPY_VERSION">
The current QPY format version as of this release. This is the default value of the `version` keyword argument on [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump") and also the upper bound for accepted values for the same argument. This is also the upper bond on the versions supported by [`qpy.load()`](#qiskit.qpy.load "qiskit.qpy.load").
Expand All @@ -182,7 +182,7 @@ These functions will raise a custom subclass of [`QiskitError`](exceptions#qiski
[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")
</Attribute>

### QPY\_COMPATIBILITY\_VERSION
### qiskit.qpy.QPY\_COMPATIBILITY\_VERSION

<Attribute id="qiskit.qpy.QPY_COMPATIBILITY_VERSION" name="qiskit.qpy.QPY_COMPATIBILITY_VERSION">
The current minimum compatibility QPY format version. This is the minimum version that [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump") will accept for the `version` keyword argument. [`qpy.load()`](#qiskit.qpy.load "qiskit.qpy.load") will be able to load all released format versions of QPY (up until `QPY_VERSION`).
Expand Down
4 changes: 2 additions & 2 deletions docs/api/qiskit/qpy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ These functions will raise a custom subclass of [`QiskitError`](exceptions#qiski
Set the error message.
</Class>

### QPY\_VERSION
### qiskit.qpy.QPY\_VERSION

<Attribute id="qiskit.qpy.QPY_VERSION" name="qiskit.qpy.QPY_VERSION">
The current QPY format version as of this release. This is the default value of the `version` keyword argument on [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump") and also the upper bound for accepted values for the same argument. This is also the upper bond on the versions supported by [`qpy.load()`](#qiskit.qpy.load "qiskit.qpy.load").
Expand All @@ -182,7 +182,7 @@ These functions will raise a custom subclass of [`QiskitError`](exceptions#qiski
[int](https://docs.python.org/3/library/functions.html#int "(in Python v3.12)")
</Attribute>

### QPY\_COMPATIBILITY\_VERSION
### qiskit.qpy.QPY\_COMPATIBILITY\_VERSION

<Attribute id="qiskit.qpy.QPY_COMPATIBILITY_VERSION" name="qiskit.qpy.QPY_COMPATIBILITY_VERSION">
The current minimum compatibility QPY format version. This is the minimum version that [`qpy.dump()`](#qiskit.qpy.dump "qiskit.qpy.dump") will accept for the `version` keyword argument. [`qpy.load()`](#qiskit.qpy.load "qiskit.qpy.load") will be able to load all released format versions of QPY (up until `QPY_VERSION`).
Expand Down
3 changes: 2 additions & 1 deletion scripts/lib/api/generateApiComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ function prepareAttributeProps(
colonIndex = text.length;
}

$(`<h3>${getLastPartFromFullIdentifier(id)}</h3>`).insertBefore($dl);
// The attributes have the following shape: name [: type] [= value]
const name = text.slice(0, Math.min(colonIndex, equalIndex)).trim();
const attributeTypeHint = text
.slice(Math.min(colonIndex + 1, equalIndex), equalIndex)
.trim();
const attributeValue = text.slice(equalIndex, text.length).trim();

$(`<h3>${name}</h3>`).insertBefore($dl);

return {
id,
name,
Expand Down

0 comments on commit b3396ed

Please sign in to comment.