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

API generation should remove Matplotlib figure captions #732

Closed
Tracked by #479
Eric-Arellano opened this issue Jan 30, 2024 · 0 comments · Fixed by #848
Closed
Tracked by #479

API generation should remove Matplotlib figure captions #732

Eric-Arellano opened this issue Jan 30, 2024 · 0 comments · Fixed by #848

Comments

@Eric-Arellano
Copy link
Collaborator

Eric-Arellano commented Jan 30, 2024

This RST results in this Sphinx-generated HTML:

Screenshot 2024-01-30 at 4 36 11 PM

Note the Fig 1 caption and how it has 3 links to download source files for the image:

Screenshot 2024-01-30 at 4 36 59 PM

This is how we render that RST in our platform after running the HTML through our pipeline:

Screenshot 2024-01-30 at 4 37 40 PM

The 3 URLs all are 404s. Instead, we should remove the caption entirely. The 3 URLs are not useful and we don't plan to support them—you can download the image directly. That would only leave the text Fig. 1, which we decided isn't a priority.

--

This impacts the Runtime 0.18 docs in #729, along with some historical docs if you run rg '_downloads' -l, e.g.:

![../\_images/qiskit-transpiler-passes-DynamicalDecoupling-1\_00.png](/images/api/qiskit/0.42/qiskit-transpiler-passes-DynamicalDecoupling-1_00.png)
Fig. 23 ([`png`](_downloads/dc45751fb822be8815f217a267bae356/qiskit-transpiler-passes-DynamicalDecoupling-1_00.png), [`hires.png`](_downloads/16422e7545ee14003706693459de64e2/qiskit-transpiler-passes-DynamicalDecoupling-1_00.hires.png), [`pdf`](_downloads/e872644fa4d73ec0d7933d354c8b5059/qiskit-transpiler-passes-DynamicalDecoupling-1_00.pdf))[](#id1 "Permalink to this image")
![../\_images/qiskit-transpiler-passes-DynamicalDecoupling-1\_01.png](/images/api/qiskit/0.42/qiskit-transpiler-passes-DynamicalDecoupling-1_01.png)
Fig. 24 ([`png`](_downloads/53fd5fc6bb784c9ab811978842d9b3d1/qiskit-transpiler-passes-DynamicalDecoupling-1_01.png), [`hires.png`](_downloads/26516316e2c0c58fddd6ab262df0a289/qiskit-transpiler-passes-DynamicalDecoupling-1_01.hires.png), [`pdf`](_downloads/de66a83309cd3c854ee1dc534a5d465d/qiskit-transpiler-passes-DynamicalDecoupling-1_01.pdf))[](#id2 "Permalink to this image")

--

Example HTML from Sphinx for a single figure:

<figure class="align-default" id="id1">
    <img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png" />
    <figcaption>
        <p>
            <span class="caption-number">Fig. 1 </span>
            <span class="caption-text">
                (
                <a class="reference download internal" download="" href="../_downloads/a640acbc08577560dc62a3c02c6ca2ac/fake_provider-1_00.png">
                    <code class="xref download docutils literal notranslate"><span class="pre">png</span></code>
                </a>
                ,
                <a class="reference download internal" download="" href="../_downloads/98e08086a49350bea51e64248343d7ac/fake_provider-1_00.hires.png">
                    <code class="xref download docutils literal notranslate"><span class="pre">hires.png</span></code>
                </a>
                ,
                <a class="reference download internal" download="" href="../_downloads/684bf35d507376624fcead10d9aedaed/fake_provider-1_00.pdf">
                    <code class="xref download docutils literal notranslate"><span class="pre">pdf</span></code>
                </a>
                )
            </span>
            <a class="headerlink" href="#id1" title="Link to this image"></a>
        </p>
    </figcaption>
</figure>

We want to simplify the HTML via a new helper function in processHtml.ts. It should look like this:

<figure class="align-default" id="id1">
    <img alt="../_images/fake_provider-1_00.png" class="plot-directive" src="../_images/fake_provider-1_00.png">
</figure>

The function needs to use https://cheerio.js.org to remove the <figcaption> but if it matches this selector: figcaption span.caption-text a.download.internal.reference. We don't want to remove any generic figcaption.

We should this in processHtml.test.ts, including that we don't remove generic figcaptions.

The final step is to run npm run regen-apis.

@Eric-Arellano Eric-Arellano added this to the 24-02-13 Qiskit 1.0 milestone Jan 30, 2024
@Eric-Arellano Eric-Arellano changed the title API generation does not handle Matplotlib figure captions API generation should remove Matplotlib figure captions Jan 31, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 31, 2024
The 0.17 docs are moved to be historical via `npm run make-historical --
-p qiskit-ibm-runtime`.

The 0.18 docs were generated with `npm run gen-api -- -p
qiskit-ibm-runtime -v 0.18.0 -a
https://github.com/Qiskit/qiskit-ibm-runtime/actions/runs/7703740124/artifacts/1204347771`.
Note that they include two new top-level modules, closing
#238.

This PR resulted in discovering
#732. This has always been
a problem we didn't know about. I manually ignore the broken links for
now to unblock the Runtime 0.18 release and to close
#238.
@Eric-Arellano Eric-Arellano moved this to In Review in Docs Planning Feb 19, 2024
@Eric-Arellano Eric-Arellano removed their assignment Feb 19, 2024
@github-project-automation github-project-automation bot moved this from In Review to Done in Docs Planning Feb 20, 2024
frankharkins pushed a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
The 0.17 docs are moved to be historical via `npm run make-historical --
-p qiskit-ibm-runtime`.

The 0.18 docs were generated with `npm run gen-api -- -p
qiskit-ibm-runtime -v 0.18.0 -a
https://github.com/Qiskit/qiskit-ibm-runtime/actions/runs/7703740124/artifacts/1204347771`.
Note that they include two new top-level modules, closing
Qiskit#238.

This PR resulted in discovering
Qiskit#732. This has always been
a problem we didn't know about. I manually ignore the broken links for
now to unblock the Runtime 0.18 release and to close
Qiskit#238.
frankharkins pushed a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants