Skip to content

Commit

Permalink
Deduplicate headers for overloaded methods (Qiskit#895)
Browse files Browse the repository at this point in the history
Closes Qiskit#167

The script was creating a title for every `<dt>` tag inside a `<dl>`
tag. This is almost always correct given that we only have a `<dt>` tag
for each method. The problem with overload methods is that we have a
`<dt>` for each `@typing.overload` definition.

For example, the `quantumcircuit.py` file overloads the definition of
for_loop:


https://github.com/Qiskit/qiskit/blob/244940a10c17f1dc3d74e2665a3ae869dc3d7291/qiskit/circuit/quantumcircuit.py#L4862-L4884

This is an example of the HTML generated

```html
<dl class="py method">
    <dt class="sig sig-object py" id="qiskit.circuit.QuantumCircuit.for_loop">
    <span class="sig-name descname"><span class="pre">for_loop</span>

    <dt class="sig sig-object py">
    <span class="sig-name descname"><span class="pre">for_loop</span>
    
    <dd><p>Create a <code class="docutils literal notranslate"><span class="pre">for</span></code> loop on this circuit.</p>
```
To solve the problem this PR adds an extra condition to check whether
the `<dt>` tag has an id or not. Only the first `<dt>` tag will have an
id, so we can use this fact to create only one `<h3>` for each method.
  • Loading branch information
arnaucasau authored Feb 27, 2024
1 parent 52b341b commit 34fd8e3
Show file tree
Hide file tree
Showing 30 changed files with 4 additions and 348 deletions.
12 changes: 0 additions & 12 deletions docs/api/qiskit/0.33/qiskit.circuit.QuantumCircuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1259,14 +1259,10 @@ The circuit index of an [`AncillaQubit`](qiskit.circuit.AncillaQubit "qiskit.cir

### for\_loop

##### for\_loop

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.for_loop.ForLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.19/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`

Create a `for` loop on this circuit.
Expand Down Expand Up @@ -1550,14 +1546,10 @@ A handle to the instruction created.

### if\_test

##### if\_test

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.if_else.IfContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.19/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str] = 'None') → qiskit.circuit.instructionset.InstructionSet`

Create an `if` statement on this circuit.
Expand Down Expand Up @@ -4050,14 +4042,10 @@ Apply unitary gate to q.
### while\_loop
##### while\_loop
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.while_loop.WhileLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.19/qiskit/circuit/quantumcircuit.py "view source code")
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`
Create a `while` loop on this circuit.
Expand Down
12 changes: 0 additions & 12 deletions docs/api/qiskit/0.35/qiskit.circuit.QuantumCircuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1259,14 +1259,10 @@ The circuit index of an [`AncillaQubit`](qiskit.circuit.AncillaQubit "qiskit.cir

### for\_loop

##### for\_loop

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.for_loop.ForLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`

Create a `for` loop on this circuit.
Expand Down Expand Up @@ -1550,14 +1546,10 @@ A handle to the instruction created.

### if\_test

##### if\_test

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.if_else.IfContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str] = 'None') → qiskit.circuit.instructionset.InstructionSet`

Create an `if` statement on this circuit.
Expand Down Expand Up @@ -4166,14 +4158,10 @@ Apply unitary gate to q.
### while\_loop
##### while\_loop
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.while_loop.WhileLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`
Create a `while` loop on this circuit.
Expand Down
8 changes: 0 additions & 8 deletions docs/api/qiskit/0.35/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,10 @@ Create a context, during which the value of the dependency manager will be `Fals

### require\_in\_call

### require\_in\_call

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: Callable) → Callable`

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: str) → Callable[[Callable], Callable]`

Create a decorator for callables that requires that the dependency is available when the decorated function or method is called.
Expand All @@ -194,14 +190,10 @@ Callable

### require\_in\_instance

### require\_in\_instance

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: Type) → Type`

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: str) → Callable[[Type], Type]`

A class decorator that requires the dependency is available when the class is initialised. This decorator can be used even if the class does not define an `__init__` method.
Expand Down
12 changes: 0 additions & 12 deletions docs/api/qiskit/0.36/qiskit.circuit.QuantumCircuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1259,14 +1259,10 @@ The circuit index of an [`AncillaQubit`](qiskit.circuit.AncillaQubit "qiskit.cir

### for\_loop

##### for\_loop

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.for_loop.ForLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`

Create a `for` loop on this circuit.
Expand Down Expand Up @@ -1550,14 +1546,10 @@ A handle to the instruction created.

### if\_test

##### if\_test

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.if_else.IfContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str] = 'None') → qiskit.circuit.instructionset.InstructionSet`

Create an `if` statement on this circuit.
Expand Down Expand Up @@ -4166,14 +4158,10 @@ Apply unitary gate to q.
### while\_loop
##### while\_loop
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.while_loop.WhileLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.20/qiskit/circuit/quantumcircuit.py "view source code")
<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`
Create a `while` loop on this circuit.
Expand Down
8 changes: 0 additions & 8 deletions docs/api/qiskit/0.36/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,10 @@ Create a context, during which the value of the dependency manager will be `Fals

### require\_in\_call

### require\_in\_call

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: Callable) → Callable`

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: str) → Callable[[Callable], Callable]`

Create a decorator for callables that requires that the dependency is available when the decorated function or method is called.
Expand All @@ -194,14 +190,10 @@ Callable

### require\_in\_instance

### require\_in\_instance

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: Type) → Type`

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: str) → Callable[[Type], Type]`

A class decorator that requires the dependency is available when the class is initialised. This decorator can be used even if the class does not define an `__init__` method.
Expand Down
12 changes: 0 additions & 12 deletions docs/api/qiskit/0.37/qiskit.circuit.QuantumCircuit.md
Original file line number Diff line number Diff line change
Expand Up @@ -1310,14 +1310,10 @@ The circuit index of an [`AncillaQubit`](qiskit.circuit.AncillaQubit "qiskit.cir

### for\_loop

##### for\_loop

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.for_loop.ForLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.for_loop" />

`QuantumCircuit.for_loop(indexset: Iterable[int], loop_parameter: Optional[qiskit.circuit.parameter.Parameter], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`

Create a `for` loop on this circuit.
Expand Down Expand Up @@ -1609,14 +1605,10 @@ A handle to the instruction created.

### if\_test

##### if\_test

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.if_else.IfContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.if_test" />

`QuantumCircuit.if_test(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], true_body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str] = 'None') → qiskit.circuit.instructionset.InstructionSet`

Create an `if` statement on this circuit.
Expand Down Expand Up @@ -4259,14 +4251,10 @@ circuit.unitary(matrix, [0, 1])

### while\_loop

##### while\_loop
<span id="qiskit.circuit.QuantumCircuit.while_loop" />

`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: None, qubits: None, clbits: None, *, label: Optional[str]) → qiskit.circuit.controlflow.while_loop.WhileLoopContext`[GitHub](https://github.com/qiskit/qiskit/tree/stable/0.21/qiskit/circuit/quantumcircuit.py "view source code")

<span id="qiskit.circuit.QuantumCircuit.while_loop" />
`QuantumCircuit.while_loop(condition: Tuple[Union[qiskit.circuit.classicalregister.ClassicalRegister, qiskit.circuit.classicalregister.Clbit], int], body: QuantumCircuit, qubits: Sequence[Union[qiskit.circuit.quantumregister.Qubit, qiskit.circuit.quantumregister.QuantumRegister, int, slice, Sequence[Union[qiskit.circuit.quantumregister.Qubit, int]]]], clbits: Sequence[Union[qiskit.circuit.classicalregister.Clbit, qiskit.circuit.classicalregister.ClassicalRegister, int, slice, Sequence[Union[qiskit.circuit.classicalregister.Clbit, int]]]], *, label: Optional[str]) → qiskit.circuit.instructionset.InstructionSet`

Create a `while` loop on this circuit.
Expand Down
8 changes: 0 additions & 8 deletions docs/api/qiskit/0.37/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,10 @@ Create a context, during which the value of the dependency manager will be `Fals

### require\_in\_call

### require\_in\_call

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: Callable) → Callable`

<span id="qiskit.utils.LazyDependencyManager.require_in_call" />

`require_in_call(feature_or_callable: str) → Callable[[Callable], Callable]`

Create a decorator for callables that requires that the dependency is available when the decorated function or method is called.
Expand All @@ -196,14 +192,10 @@ Callable

### require\_in\_instance

### require\_in\_instance

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: Type) → Type`

<span id="qiskit.utils.LazyDependencyManager.require_in_instance" />

`require_in_instance(feature_or_class: str) → Callable[[Type], Type]`

A class decorator that requires the dependency is available when the class is initialised. This decorator can be used even if the class does not define an `__init__` method.
Expand Down
Loading

0 comments on commit 34fd8e3

Please sign in to comment.