Skip to content

Commit

Permalink
Fix header hierarchy for the API docs (Qiskit#1283)
Browse files Browse the repository at this point in the history
The PR adds a method to autogenerate the correct level for the headers
of the MDX components (Attribute, Function, and Class) and regenerates
the API docs.

### How to find the heading level

Before setting the header, the script looks for the level of the
previous header to determine which one corresponds to the component that
is being generated. The script looks at all the siblings of the
`Cheerio` element we use to define the component to find the previous
header that wasn't created by the script before. We need to skip the
generated headers to avoid the case where we have multiple
methods/attributes/classes at the same level which shouldn't be mixed
with the header of the previous level.

If there's no header found in the first step, it means that we are
dealing with a component inside of an inline class, and therefore, the
script searches for the last header that corresponds to an inline class
to determine the new level. This is true because when we are inside an
inline class, there are no headers that haven't been generated by the
script.

Notice that the script always sets the header of an inline class in the
parent level instead of creating another sibling, so we cannot search
for generated siblings' headers.

To distinguish between the headers of the different components, an
attribute called `data-header-type` is used. This attribute is useful in
the last search.

Closes Qiskit#1215

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
  • Loading branch information
arnaucasau and Eric-Arellano authored May 7, 2024
1 parent 9c5a5c4 commit 6f82514
Show file tree
Hide file tree
Showing 138 changed files with 2,236 additions and 1,326 deletions.
12 changes: 8 additions & 4 deletions docs/api/qiskit-ibm-provider/0.10/ibm_utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Utility functions related to the IBM Quantum Provider.

Message broker for the Publisher / Subscriber mechanism

### Publisher

<Class id="qiskit_ibm_provider.utils.pubsub.Publisher" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L140-L155" signature="Publisher">
Represents a “publisher”.

Expand All @@ -51,7 +53,7 @@ Message broker for the Publisher / Subscriber mechanism
Publisher().publish("event", args, ... )
```

### publish
#### publish

<Function id="qiskit_ibm_provider.utils.pubsub.Publisher.publish" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L152-L155" signature="publish(event, *args, **kwargs)">
Triggers an event, and associates some data to it, so if there are any subscribers, their callback will be called synchronously.
Expand All @@ -62,12 +64,14 @@ Message broker for the Publisher / Subscriber mechanism
</Function>
</Class>

### Subscriber

<Class id="qiskit_ibm_provider.utils.pubsub.Subscriber" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L158-L182" signature="Subscriber">
Represents a “subscriber”.

Every component (class) can become a [`Subscriber`](#qiskit_ibm_provider.utils.pubsub.Subscriber "qiskit_ibm_provider.utils.pubsub.Subscriber") and subscribe to events, that will call callback functions when they are emitted.

### clear
#### clear

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.clear" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L180-L182" signature="clear()">
Unsubscribe everything
Expand All @@ -77,7 +81,7 @@ Message broker for the Publisher / Subscriber mechanism
`None`
</Function>

### subscribe
#### subscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.subscribe" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L168-L173" signature="subscribe(event, callback)">
Subscribes to an event, associating a callback function to that event, so when the event occurs, the callback will be called.
Expand All @@ -89,7 +93,7 @@ Message broker for the Publisher / Subscriber mechanism
`bool`
</Function>

### unsubscribe
#### unsubscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.unsubscribe" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.10/qiskit_ibm_provider/utils/pubsub.py#L175-L178" signature="unsubscribe(event, callback)">
Unsubscribe a pair event-callback, so the callback will not be called anymore when the event occurs.
Expand Down
12 changes: 8 additions & 4 deletions docs/api/qiskit-ibm-provider/0.9/ibm_utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Utility functions related to the IBM Quantum Provider.

Message broker for the Publisher / Subscriber mechanism

### Publisher

<Class id="qiskit_ibm_provider.utils.pubsub.Publisher" github="https://github.com/qiskit/qiskit-ibm-provider/tree/stable/0.9/qiskit_ibm_provider/utils/pubsub.py" signature="Publisher">
Represents a “publisher”.

Expand All @@ -51,7 +53,7 @@ Message broker for the Publisher / Subscriber mechanism
Publisher().publish("event", args, ... )
```

### publish
#### publish

<Function id="qiskit_ibm_provider.utils.pubsub.Publisher.publish" signature="publish(event, *args, **kwargs)">
Triggers an event, and associates some data to it, so if there are any subscribers, their callback will be called synchronously.
Expand All @@ -62,12 +64,14 @@ Message broker for the Publisher / Subscriber mechanism
</Function>
</Class>

### Subscriber

<Class id="qiskit_ibm_provider.utils.pubsub.Subscriber" github="https://github.com/qiskit/qiskit-ibm-provider/tree/stable/0.9/qiskit_ibm_provider/utils/pubsub.py" signature="Subscriber">
Represents a “subscriber”.

Every component (class) can become a [`Subscriber`](#qiskit_ibm_provider.utils.pubsub.Subscriber "qiskit_ibm_provider.utils.pubsub.Subscriber") and subscribe to events, that will call callback functions when they are emitted.

### clear
#### clear

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.clear" signature="clear()">
Unsubscribe everything
Expand All @@ -77,7 +81,7 @@ Message broker for the Publisher / Subscriber mechanism
`None`
</Function>

### subscribe
#### subscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.subscribe" signature="subscribe(event, callback)">
Subscribes to an event, associating a callback function to that event, so when the event occurs, the callback will be called.
Expand All @@ -89,7 +93,7 @@ Message broker for the Publisher / Subscriber mechanism
`bool`
</Function>

### unsubscribe
#### unsubscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.unsubscribe" signature="unsubscribe(event, callback)">
Unsubscribe a pair event-callback, so the callback will not be called anymore when the event occurs.
Expand Down
12 changes: 8 additions & 4 deletions docs/api/qiskit-ibm-provider/ibm_utils.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Utility functions related to the IBM Quantum Provider.

Message broker for the Publisher / Subscriber mechanism

### Publisher

<Class id="qiskit_ibm_provider.utils.pubsub.Publisher" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L140-L155" signature="Publisher">
Represents a “publisher”.

Expand All @@ -51,7 +53,7 @@ Message broker for the Publisher / Subscriber mechanism
Publisher().publish("event", args, ... )
```

### publish
#### publish

<Function id="qiskit_ibm_provider.utils.pubsub.Publisher.publish" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L152-L155" signature="publish(event, *args, **kwargs)">
Triggers an event, and associates some data to it, so if there are any subscribers, their callback will be called synchronously.
Expand All @@ -62,12 +64,14 @@ Message broker for the Publisher / Subscriber mechanism
</Function>
</Class>

### Subscriber

<Class id="qiskit_ibm_provider.utils.pubsub.Subscriber" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L158-L182" signature="Subscriber">
Represents a “subscriber”.

Every component (class) can become a [`Subscriber`](#qiskit_ibm_provider.utils.pubsub.Subscriber "qiskit_ibm_provider.utils.pubsub.Subscriber") and subscribe to events, that will call callback functions when they are emitted.

### clear
#### clear

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.clear" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L180-L182" signature="clear()">
Unsubscribe everything
Expand All @@ -77,7 +81,7 @@ Message broker for the Publisher / Subscriber mechanism
`None`
</Function>

### subscribe
#### subscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.subscribe" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L168-L173" signature="subscribe(event, callback)">
Subscribes to an event, associating a callback function to that event, so when the event occurs, the callback will be called.
Expand All @@ -89,7 +93,7 @@ Message broker for the Publisher / Subscriber mechanism
`bool`
</Function>

### unsubscribe
#### unsubscribe

<Function id="qiskit_ibm_provider.utils.pubsub.Subscriber.unsubscribe" github="https://github.com/Qiskit/qiskit-ibm-provider/tree/stable/0.11/qiskit_ibm_provider/utils/pubsub.py#L175-L178" signature="unsubscribe(event, callback)">
Unsubscribe a pair event-callback, so the callback will not be called anymore when the event occurs.
Expand Down
2 changes: 2 additions & 0 deletions docs/api/qiskit/0.19/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ python_api_name: qiskit.ignis.logging
| [`IgnisLogging`](qiskit.ignis.logging.IgnisLogging "qiskit.ignis.logging.IgnisLogging")() | Singleton class to configure file logging via IgnisLogger |
| [`IgnisLogReader`](qiskit.ignis.logging.IgnisLogReader "qiskit.ignis.logging.IgnisLogReader")() | Class to read from Ignis log files |

###

<Class github="https://github.com/qiskit-community/qiskit-ignis/tree/stable/0.3/qiskit/ignis/logging/ignis_logging.py" signature="IgnisLogger(name, level=0)">
A logger class for Ignis

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,44 @@ Convert symmetric TSP instances into Pauli list Deal with TSPLIB format. It supp
| ------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- |
| [`TspData`](#qiskit.optimization.applications.ising.tsp.TspData "qiskit.optimization.applications.ising.tsp.TspData")(name, dim, coord, w) | Create new instance of TspData(name, dim, coord, w) |

### TspData

<Class id="qiskit.optimization.applications.ising.tsp.TspData" signature="TspData(name, dim, coord, w)">
Create new instance of TspData(name, dim, coord, w)

### coord
#### coord

<Attribute id="qiskit.optimization.applications.ising.tsp.TspData.coord">
Alias for field number 2
</Attribute>

### count
#### count

<Function id="qiskit.optimization.applications.ising.tsp.TspData.count" signature="count(value, /)">
Return number of occurrences of value.
</Function>

### dim
#### dim

<Attribute id="qiskit.optimization.applications.ising.tsp.TspData.dim">
Alias for field number 1
</Attribute>

### index
#### index

<Function id="qiskit.optimization.applications.ising.tsp.TspData.index" signature="index(value, start=0, stop=9223372036854775807, /)">
Return first index of value.

Raises ValueError if the value is not present.
</Function>

### name
#### name

<Attribute id="qiskit.optimization.applications.ising.tsp.TspData.name">
Alias for field number 0
</Attribute>

### w
#### w

<Attribute id="qiskit.optimization.applications.ising.tsp.TspData.w">
Alias for field number 3
Expand Down
Loading

0 comments on commit 6f82514

Please sign in to comment.