Commit Graph

729 Commits

Author SHA1 Message Date
Eric Arellano aaec587777 Update image of admin (#961) 2024-03-05 14:50:00 +00:00
Eric Arellano 0bd9de95ea Remove sequencing assumption in conversionPipeline.ts (#958)
Makes two refactors:

1. Removes creation of `apidoc/` and `stubs/` markdown folders. We never
wrote to these folders. We already create the markdown folder in
`updateApiDocs.ts` if it doesn't exist, so this wasn't necessary.
2. Removes the implicit requirement that `copyImages` is called before
`postProcessResults` so that method inlining doesn't break the images.
Now you can run `copyImages` whenever.
2024-03-05 14:44:15 +00:00
Eric Arellano 4c5b3c94d1 Split up conversionPipeline.ts into helper functions (#957)
Refactor for https://github.com/Qiskit/documentation/issues/715.
Functionality is the same and regenerating provider didn't change.
2024-03-05 14:11:15 +00:00
Eric Arellano d7afd6882f Refactor release notes logic in `conversionPipeline.ts` (#953)
Uses helper functions and better groups code to make it easier to read.
Should be the same behavior.
2024-03-04 22:52:08 +00:00
Eric Arellano 79a1b657e0 Split out `conversionPipeline.ts` from `updateApiDocs.ts` (#952)
This is a refactor to unblock the new integration test in
https://github.com/Qiskit/documentation/issues/715. We need to test the
conversion pipeline, so its code needs to live in `lib` not `commands`.

I renamed the function `convertHtmlToMarkdown` to instead
`runConversionPipeline` and moved it to `conversionPipeline.ts`. I
didn't want the phrase "html to markdown" because because we already
have `htmlToMd.ts`; this pipeline does way more than convert HTML to
markdown, such as also copying image files and inlining methods into
classes.

This PR also refactors the rest of `updateApiDocs.ts` via helper
functions. A follow up will refactor `conversionPipeline.ts`.
2024-03-04 22:43:36 +00:00
abbycross 69d76a1041 Add note about recent change to sessions (#955)
Closes #921
2024-03-04 20:48:03 +00:00
abbycross ac6d5dc88a Update drawer output images in mdx files to match Qiskit 1.0 (part one) (#864)
Closes #833
2024-03-04 20:22:58 +00:00
Eric Arellano 15586fd249 Don't show h1s in module page table of contents (#949)
Closes https://github.com/Qiskit/documentation/issues/932.

We decided:

1. We are going to keep showing h1s for class and function pages. It's
useful because they have non-trivial code at the top level, like their
docstring and constructor. It's nice to have the quick way to access the
value.
2. For now at least, we won't show h4s in the module pages. There are 8
module pages in the current API docs that use h4s. I think showing h4s
improved ~3 of them, and made ~5 worse. So, for now, let's not include
them. This can be revisited, especially after
https://github.com/Qiskit/documentation/issues/942.

This regens all APIs but reverts dev docs, which have unrelated changes
and will be regenerated in a dedicated PR.
2024-03-04 17:30:48 +00:00
Juan Cruz-Benito 146e3d91f6 Update documentation about Qiskit Transpiler Service & AI transpiler passes (#797)
Adding documentation of the new features and changes available after the
release of versions 0.2.0 & 0.2.1 of the `qiskit_transpiler_service`

---------

Co-authored-by: ABBY CROSS <across@us.ibm.com>
2024-03-04 15:31:38 +00:00
Eric Arellano 9196122272 Extract another helper function in htmlToMd.ts (#945)
Part of https://github.com/Qiskit/documentation/issues/845.
2024-03-04 12:07:11 +00:00
abbycross 8b9050e14f remove trademark from Qiskit and update readme (#946) 2024-03-01 21:02:42 +00:00
Eric Arellano 36741c14e7 Document how to pull in new versions of preview (#944)
It's confusing when `./start` diverges from `docs.quantum.ibm.com`.

We now warn every time when running `./start`:

```
❯ ./start 
Warning: this may be using an outdated version of the app. Run `docker pull qiskit/documentation` to check for updates.
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
   ▲ Next.js 14.0.1
   - Local:        http://f9e8103d2cee:3000
   - Network:      http://172.17.0.2:3000

 ✓ Ready in 1377ms
[remoteRefresh] server is listening at port 5001
```

I debated always running `docker pull qiskit/documentation`
automatically, but I think it's too slow and annoying.
2024-03-01 19:02:05 +00:00
Arnau Casau 27f8821b5c Refactor `htmlToMd.ts`: Split `prepareHandlers` function (#943)
Part of #845

This PR refactors the `htmlToMd.ts` script. It splits the
`prepareHandlers` function into some helper functions to simplify the
logic and improve the readability.
2024-03-01 18:46:31 +00:00
Eric Arellano e497785371 Fix accidental deletion of GitHub source links for methods (#940)
Part of https://github.com/Qiskit/documentation/issues/517.

Turns out that we would accidentally delete all the GitHub links for
methods because we were using `closest().remove()` rather than
`.closest().first().remove()`. That means that we'd only have the link
for the class definition and not individual methods, which defeats the
point of precise source code links from
https://github.com/Qiskit/documentation/issues/517.

## Historical API docs

However, the behavior to not show methods is actually quite sensible for
our API docs, where we were using `sphinx.ext.viewcode` rather than
`sphinx.ext.linkcode`. That meant that we could only link to the overall
file, rather than specific line numbers. So, it's not very useful to
keep linking to the overall file for every method since they will each
have the same value and the class definition already has the value. So,
we check if the link is for a method and proactively remove it if so.

This change to proactively remove method links changes some historical
API doc versions, but not others. Why? It only removes the links if we
were doing method inlining, where the method had a dedicated HTML page
originally. That's because the `.remove()` line wouldn't impat the
distinct HTML pages.
2024-02-29 21:54:36 +00:00
Frank Harkins 6b640162d2 Fix learning uploader to handle tutorials (#938)
The logic that calculates the URL to display to the user expects the
page to belong to a course. This crashes when uploading a tutorial as
tutorials don't belong to a course.

This PR fixes that and updates the e2e test to include a tutorial page.

***

Resolves #799
2024-02-29 20:24:40 +00:00
Arnau Casau 5b0859eb4c Refactor htmlToMd.ts (#934)
Part of #845

This is the first refactor of `htmlToMd.ts`. It brings the following
changes:

- New function named `buildMathExpression` to build math expressions
whether they are inlined or not
- New function named `removeEmphasisSpaces` to remove the initial and
trailing spaces in an emphasis node
- The Unified plugin and the creation of the handlers for it were
separated into two functions. The unified plugin was inlined into
`generateMarkdownFile`

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2024-02-29 18:22:24 +00:00
Eric Arellano d69ba5dc77 Regen Runtime and Provider with full release notes and precise GitHub links (#931)
Part of https://github.com/Qiskit/documentation/issues/517. Also brings
in missing release notes due to bad configuration in Reno in the two
repositories.
2024-02-29 17:51:21 +00:00
Eric Arellano f77f3640b1 Metadata line length check ignores API docs (#930)
Follow up to https://github.com/Qiskit/documentation/pull/890. API docs
are auto-generated so we can't easily fix if the line length is not
ideal, which often happens from being too short.
2024-02-29 13:57:20 +00:00
Eric Arellano b91049d822 Split internal and external link checker into separate programs (#916)
Closes https://github.com/Qiskit/documentation/issues/876.

This split brings several improvements:

1. Simpler internal link checker code.
2. The external link checker now deduplicates links across all files,
which avoids repeating requests.
3. The external link checker logs its progress every 20 links.
4. It's possible to check external links without checking internal
links.

We run the external link checker in our weekly cron job over all files,
other than translations and historical Qiskit versions. That change was
added in https://github.com/Qiskit/documentation/pull/913.
2024-02-28 19:57:29 +00:00
Arnau Casau a2edf63200 Add space to GitHub source links (#915)
Part of #856

This PR adds a little space before every GitHub source link and
regenerates all API docs.

**Before**
![Screenshot 2024-02-28 at 16 30
20](https://github.com/Qiskit/documentation/assets/47946624/002e33dd-8819-4101-8ca3-17a73603a259)

**After**
![Screenshot 2024-02-28 at 16 29
38](https://github.com/Qiskit/documentation/assets/47946624/d59b59ad-459a-4883-8652-28e8edb214ea)
2024-02-28 18:12:48 +00:00
Arnau Casau d0d43929b5 Fix API generation regression (#899)
Closes #224

This PR fixes an issue with the API generation script that causes
regressions in attributes. For each attribute, we show on the
documentation website, its type (if exists) and its default value (if
exists).

An example of an attribute could be `instance: str | None = None` which
has the type `str | None` and the default value `None`. This is its
representation on the website:

![Captura desde 2024-02-27
19-12-42](https://github.com/Qiskit/documentation/assets/47946624/e2cce336-9d0a-4da7-bd80-3f7d7cf1f6c4)

To find the attribute and the default value, the script searches for the
index of the colon (type separator) and the index of the equal sign
(default value separator). The problem is that those two values are
optional, and we could have, for example, a default value involving a
string containing a colon symbol that would be detected as the type
separator when it's not.

To fix this, we could only search for the type separator before the
default value. We don't have any problem with the equal sign because it
cannot be a type of attribute.

The PR has regenerated all versions of qiskit, runtime, and provider.
2024-02-28 15:52:51 +00:00
Eric Arellano 2c82c0dc6a Pages render check only runs on changed files (#913)
Closes https://github.com/Qiskit/documentation/issues/886. As explained
there, it's safe to only run this check on changed files because whether
a page renders is independent from all the other pages.

We use a weekly cron job, though, to check all pages. That reduces our
risk from things like the docs preview Docker image changing on us and
resulting in some pages now failing to render.

--

This PR also stops checking external links in API docs builds and
instead moves the check to the new weekly cron job. Relates to
https://github.com/Qiskit/documentation/issues/876.

Per https://github.com/Qiskit/documentation/pull/372, it's annoying to
check external links in CI because it can be flaky
(https://github.com/Qiskit/documentation/issues/823).
2024-02-28 12:42:34 +00:00
abbycross fac0c0115d teensy nit-pick semicolon (#914)
otherwise goes with semicolon
2024-02-27 22:44:19 +00:00
Kevin J. Sung c6b11b7075 Update transpile section caution box to reflect more up-to-date information (#898)
Co-authored-by: Kaelyn Ferris <43348706+kaelynj@users.noreply.github.com>
2024-02-27 22:25:26 +00:00
Eric Arellano 845af16846 Regenerate Runtime 0.20 release note (#904)
Addresses
https://github.com/Qiskit/qiskit-ibm-runtime/issues/1428#issuecomment-1966573960.

I also updated the dev docs to the latest CI build, but only one image
changed.
2024-02-27 16:37:40 -05:00
Frank Harkins 929d1c55e9 Add flake8 tool instructions to migration guide (#875)
Adds instructions on using the flake8 plugin to detect deprecated
imports.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2024-02-27 18:17:12 +00:00
Frank Harkins 5c9c97b520 Replace Squeaky CI advice with custom advice (#897)
Closes https://github.com/Qiskit/documentation/issues/838.

Replaces the message in CI with correct instructions for our repository.
I've added a switch to remove the advice from the printed message, I
think this is the neatest net logic change:
33e24f8eb6.


<img width="600" alt="Screenshot 2024-02-27 at 17 20 42"
src="https://github.com/Qiskit/documentation/assets/36071638/dff70ada-2eca-4041-83fd-e0177bc52bca">

See https://github.com/frankharkins/documentation/pull/2 for the test
PR.

This doesn't display the message when running `tox -e lint`, but I think
it's unlikely a contributor would run that command locally without first
encountering it in CI.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2024-02-27 18:14:29 +00:00
Elena Peña Tapia c703c5c952 Fix Estimator example in Qiskit 1.0 feagure migration guide (#896)
When I wrote the guide my brain decided that 2 circuits and 2
observables were not possible to run with Estimator V1, but they are.
This PR fixes this oversight. Thanks @beckykd for pointing it out.
2024-02-27 18:00:02 +00:00
Arnau Casau 34fd8e3650 Deduplicate headers for overloaded methods (#895)
Closes #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:


244940a10c/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.
2024-02-27 17:02:01 +00:00
Kevin J. Sung 52b341bb0e Add documentation on transpiler plugins (#781)
Fixes #102 .
2024-02-27 16:15:54 +00:00
Kaelyn Ferris 45655181f3 Replace `line_length` kwarg w/ `fold` description (#892)
Closes #811

Fixes the out-of-date description of the `line_length` kwarg in
`QuantumCircuit.draw()` and `qiskit.visualization.circuit_drawer()` with
a description of the `fold` argument.
2024-02-27 15:01:44 +00:00
Kevin J. Sung ec42361ea5 enforce 50 <= description length <= 160 (#890)
Fixes #327
2024-02-26 22:36:55 +00:00
Eric Arellano 129f1073de Fix logic for checking historical Qiskit docs (#889)
Fixes a bug in https://github.com/Qiskit/documentation/pull/881. It
handled `--qiskit-release-notes` correctly, but it incorrectly would
skip `--historical-apis` for Qiskit versions before 0.45.

This also loads fewer files for the migration guides.
2024-02-26 18:57:59 +00:00
Eric Arellano 93f98be6a0 Generate Qiskit 1.0.1 (#877)
`npm run gen-api -- -p qiskit -v 1.0.1`
2024-02-26 13:45:38 -05:00
Arnau Casau ad885f0717 Update legacy release notes links to use Qiskit 0.45 (#865)
Part of #755

This PR changes the legacy release notes links to point to the qiskit
0.45 version folder.

### How the change was done

I created a little script to transform every link in a release note file
and re-write it in the same destination. I named it `updateLinks.ts`.

```ts
import { zxMain } from "../lib/zx";
import { globby } from "globby";
import { pathExists, getRoot } from "../lib/fs";
import { readFile, writeFile } from "fs/promises";
import transformLinks from "transform-markdown-links";

zxMain(async () => {
  const allVersions = (
    await globby("docs/api/qiskit/release-notes/[!index]*")
  ).map((releaseNotesPath) =>
    releaseNotesPath.split("/").pop()!.split(".").slice(0, -1).join("."),
  );

  for (const releaseNotesVersion of allVersions) {
    const source = `${getRoot()}/docs/api/qiskit/release-notes/${releaseNotesVersion}.md`;
    if (await pathExists(source)) {
      updateLinksFile('qiskit', releaseNotesVersion, source, source);
    }
  }
});

async function updateLinksFile(pkgName: string, versionWithoutPatch: string, source: string, dest: string) {
  let markdown = await readFile(source, { encoding: "utf8" });

  const regexAbsolutePath = new RegExp(
    "/api/" + pkgName + "/(?!release-notes)(?![0-9])",
  );

  markdown = transformLinks(markdown, (link, _) =>
    link.replace(regexAbsolutePath, `/api/${pkgName}/0.45/`),
  );

  await writeFile(dest, markdown);
}


```

To execute the script using `npm run update-legacy-links` you can modify
the `package.json` file by adding the following line in the `scripts`
section:

```ts
"update-legacy-links": "node -r esbuild-register scripts/commands/updateLinks.ts"
```
2024-02-26 12:11:50 -05:00
Eric Arellano e16e8184b0 Determine internal vs external links at parse time (#884)
Part of https://github.com/Qiskit/documentation/issues/876 to split the
internal and external link checkers into distinct programs. To do this,
it's useful to split out internal vs. external links at parse time,
whereas before we did it inside `FileBatch`. The external link checker
won't use `FileBatch`.

This is only a refactor and doesn't change the program, other than now
using `HEAD` for external link requests rather than `GET`. We also now
use a `Set` for anchors so that checking if an anchor is included is
faster.

---------

Co-authored-by: Arnau Casau <47946624+arnaucasau@users.noreply.github.com>
2024-02-26 14:36:47 +00:00
Frank Harkins 4c5c0ebf1a Add Qiskit bot reviewer for 'quantum-serverless' page (#883)
Late response as reviewer was OOO.
2024-02-26 12:26:55 +00:00
Eric Arellano e07b50d49a Split out `InternalLink` and `ExternalLink` classes (#882)
We decided as part of https://github.com/Qiskit/documentation/issues/876
that we should have distinct programs for checking internal vs external
links, since they are such distinct workflows.

This PR is a refactor to prepare for that change. The link checker
program still behaves the same as before; this is only a refactor.
2024-02-26 12:24:38 +00:00
Arnau Casau b712c1d2c2 Link checker: Qiskit legacy release notes in a single FileBatch (#881)
The legacy release notes of qiskit were generated from qiskit 0.45 and
we need to check them loading those docs. This PR groups together all
the legacy release notes in a FileBatch to avoid loading the same docs
multiple times.
2024-02-23 18:21:26 +00:00
abbycross cff81984ce Remove sentence that doesn't apply (#879)
As pointed out by @Alienah, the statement being removed by this PR isn't
true at this time.
2024-02-23 17:08:53 +00:00
Kaelyn Ferris 7badbc30db Reconfigure cspell to use dictionaries (#873)
Closes #827
2024-02-23 16:02:11 +00:00
Eric Arellano f6ffdf6d14 Relativize API links to docs.quantum.ibm.com (#870)
Closes https://github.com/Qiskit/documentation/issues/493. This change
makes our link checker work better because it can quickly validate the
relative links and also validate anchors, whereas external links are
much slower.

---------

Co-authored-by: Arnau Casau <47946624+arnaucasau@users.noreply.github.com>
2024-02-23 13:49:44 +00:00
Arnau Casau cfa6334596 Qiskit docs generation only changes release notes for its own version (#860)
### Summary 

Part of #755

This PR changes the logic of the API generation script to only modify
the release notes file of the version we are regenerating at that
moment. Before, the release notes files contained more than one version,
and we needed to update several files, independently of what version we
were regenerating. After https://github.com/Qiskit/qiskit/pull/11840, we
can assume that the release notes files will only contain their own
versions, and we can simply our script by removing some functions.

### New logic

The API generation script will transform every link of the release notes
files to point to its version folder instead of the top level. Once we
have the correct links, we will directly write the release notes file,
if we didn't have them before, or otherwise, we will create a new file
containing the header of the old file we had and the version sections of
the new one downloaded from Box. That way, we can make manual changes
like the table added in the release notes of qiskit 0.44 without losing
them in the next regeneration.

### Functions removed

This change allows us to remove the following two functions:

The `extractMarkdownReleaseNotesPatches` function extracted all the
versions in a release notes file and stored the markdown of each patch
to posteriorly merge them under their minor version file. Now we have
one minor version per file, so we don't need to break the release notes
into pieces anymore. The new logic treats all patch versions as a block.

The `sortReleaseNotesVersions` were used to sort the patch versions.
Given that the file will have the correct order, we don't need to worry
about it either.

Removing these two functions allows us to remove the test file, given
that they composed the entire file.
2024-02-23 11:29:39 +00:00
abbycross 138a8a064e fix spelling issues found by spellcheck (#872) 2024-02-22 22:50:53 +00:00
Eric Arellano 56e11f1c0f Store Sphinx artifacts in a less verbose location (#871)
Before: `.out/python/sources/qiskit/0.40.0`
After: `.sphinx-artifacts/qiskit/0.40`

We weren't storing anything else in `.out`, so there was no need to have
those subfolders.

It also isn't necessary to put the patch version in the folder name
since we only ever have one patch per minor release.
2024-02-22 19:52:59 +00:00
Arnau Casau 193233f85e Link checker: One release note per FileBatch (#862)
Part of #755 

This PR changes how we are checking the links of the Qiskit release
notes. The link checker will check every file in a different batch
allowing us to load all the necessary files for each release note.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
2024-02-22 18:32:26 +00:00
Eric Arellano f234147ba3 Refactor how we relativize links to qiskit.org (#869)
This is prework for https://github.com/Qiskit/documentation/issues/493
to relativize links to docs.quantum.ibm.com.

This refactors the code that we'll be modifying:

* Always applies the link transformation, whereas before it wasn't used
on Qiskit.
* renames `updateUrl` to `normalizeUrl`
* renames `transformLink` to `relativizeLink`
* adds tests for `relativizeLink`
2024-02-22 12:33:13 -05:00
abbycross 74cffe0f41 Specify optimization level with generate_preset_pass_manager (#868)
Closes #866
2024-02-22 17:03:18 +00:00
Frank Harkins daccbcc654 Add names to Qiskit bot (#867)
Adds usernames for each file, escaping based on their notification
preferences.

---------

Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
Co-authored-by: Arnau Casau <47946624+arnaucasau@users.noreply.github.com>
2024-02-22 15:32:51 +00:00
Eric Arellano cdc9ebfdb1 Remove old style of Matplotlib figures (#858)
Follow up to https://github.com/Qiskit/documentation/pull/848. Sphinx
used to use a different HTML structure we weren't accounting for.

After this PR, there are no more bad URLs:

```
❯ rg '_downloads' -l
scripts/lib/api/htmlToMd.test.ts
scripts/lib/links/ignores.ts
scripts/lib/api/processHtml.test.ts
```
2024-02-21 13:40:31 -05:00