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 docs script should relativize internal links #493

Closed
Eric-Arellano opened this issue Dec 7, 2023 · 0 comments · Fixed by #870
Closed

API docs script should relativize internal links #493

Eric-Arellano opened this issue Dec 7, 2023 · 0 comments · Fixed by #870

Comments

@Eric-Arellano
Copy link
Collaborator

Eric-Arellano commented Dec 7, 2023

If API docs use https://docs.quantum.ibm.com/start/configure-qiskit-local, then we should change this to /start/configure-qiskit-local. That is, we should chop off the prefix.

We actually already did this for qiskit.org:

function transformLink(link: Link): Link | undefined {
const updateText = link.url === link.text;
const prefixes = [
"https://qiskit.org/documentation/apidoc/",
"https://qiskit.org/documentation/stubs/",
];
const prefix = prefixes.find((prefix) => link.url.startsWith(prefix));
if (!prefix) {
return;
}
let [url, anchor] = link.url.split("#");
url = removePrefix(url, prefix);
url = removeSuffix(url, ".html");
if (anchor && anchor !== url) {
url = `${url}#${anchor}`;
}
const newText = updateText ? url : undefined;
return { url: `/api/qiskit/${url}`, text: newText };
}

We need to keep that code for historical API docs. But we should expand it to handle https://docs.quantum.ibm.com and https://docs.quantum-computing.ibm.com. We should also apply the logic to Qiskit, whereas right now it only is used for Runtime and Provider.

@Eric-Arellano Eric-Arellano added this to the 24-02-13 Qiskit 1.0 milestone Dec 7, 2023
@Eric-Arellano Eric-Arellano removed this from the 24-02-13 Qiskit 1.0 milestone Jan 11, 2024
@Eric-Arellano Eric-Arellano self-assigned this Feb 22, 2024
@Eric-Arellano Eric-Arellano moved this to In Progress in Docs Planning Feb 22, 2024
Eric-Arellano added a commit that referenced this issue Feb 22, 2024
This is prework for #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`
@Eric-Arellano Eric-Arellano moved this from In Progress to Done in Docs Planning Feb 22, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 23, 2024
Closes #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>
frankharkins pushed a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
This is prework for Qiskit#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`
frankharkins pushed a commit to frankharkins/documentation that referenced this issue Jul 22, 2024
Closes Qiskit#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>
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.

2 participants