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

Split sphinxHtmlToMarkdown into helper functions #596

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions scripts/lib/sphinx/sphinxHtmlToMarkdown.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
import { describe, test, expect } from "@jest/globals";
import { sphinxHtmlToMarkdown } from "./sphinxHtmlToMarkdown";

const DEFAULT_ARGS = {
imageDestination: "/images/qiskit",
baseSourceUrl: "https://github.com/Qiskit/qiskit-ibm-runtime/tree/0.9.2/",
releaseNotesTitle: "My Quantum release notes",
};

describe("sphinxHtmlToMarkdown", () => {
test("remove .html extension from relative links", async () => {
expect(
Expand Down Expand Up @@ -114,7 +120,7 @@ describe("sphinxHtmlToMarkdown", () => {
</div>
`,
url: "http://qiskit.org/docs/quantum-circuit.html",
imageDestination: "/images/qiskit",
...DEFAULT_ARGS,
}),
).toMatchInlineSnapshot(`
{
Expand Down Expand Up @@ -506,7 +512,7 @@ Can be either (1) a dictionary mapping XX angle values to fidelity at that angle
</div>
`,
url: "https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.Sampler.html",
baseSourceUrl: `https://github.com/Qiskit/qiskit-ibm-runtime/tree/0.9.2/`,
...DEFAULT_ARGS,
})
).markdown,
).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -1418,7 +1424,7 @@ compilation flow follows the structure given below:</p>

Most circuits must undergo a series of transformations that make them compatible with a given target device, and optimize them to reduce the effects of noise on the resulting outcomes. Rewriting quantum circuits to match hardware constraints and optimizing for performance can be far from trivial. The flow of logic in the rewriting tool chain need not be linear, and can often have iterative sub-loops, conditional branches, and other complex behaviors. That being said, the standard compilation flow follows the structure given below:

![../\\_images/transpiling\\_core\\_steps.png](/images/api//transpiling_core_steps.png)
![../\\_images/transpiling\\_core\\_steps.png](/images/qiskit/transpiling_core_steps.png)

Qiskit has four pre-built transpilation pipelines available here:
"
Expand All @@ -1443,13 +1449,13 @@ test("identify release notes", async () => {
</ul>
`,
url: "http://qiskit.org/docs/release_notes.html",
imageDestination: "/images/qiskit",
...DEFAULT_ARGS,
}),
).toMatchInlineSnapshot(`
{
"images": [],
"isReleaseNotes": true,
"markdown": "# Release Notes
"markdown": "# My Quantum release notes

<span id="release-notes-0-14-0" />

Expand Down Expand Up @@ -1528,6 +1534,7 @@ async function toMd(html: string) {
await sphinxHtmlToMarkdown({
url: "https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.Sampler.html",
html,
...DEFAULT_ARGS,
})
).markdown;
}
Expand All @@ -1536,5 +1543,6 @@ async function toMdWithMeta(html: string) {
return await sphinxHtmlToMarkdown({
url: "https://qiskit.org/documentation/partners/qiskit_ibm_runtime/stubs/qiskit_ibm_runtime.Sampler.html",
html,
...DEFAULT_ARGS,
});
}
Loading