diff --git a/scripts/js/lib/api/updateLinks.test.ts b/scripts/js/lib/api/updateLinks.test.ts index e84bed82872..125715a5af0 100644 --- a/scripts/js/lib/api/updateLinks.test.ts +++ b/scripts/js/lib/api/updateLinks.test.ts @@ -31,6 +31,8 @@ test.describe("updateLinks", () => { [link8](#qiskit_ibm_runtime.RuntimeJob.job) [link9](https://qiskit.org/documentation/apidoc/algorithms.html) [link10](https://qiskit.org/documentation/stubs/qiskit.circuit.BreakLoopOp.html#assemble) +[link11](qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.a_method) +[link12](qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.InlineClass.another_method) `, meta: { apiType: "class", @@ -97,7 +99,9 @@ test.describe("updateLinks", () => { [link7](qiskit_ibm_runtime.RuntimeJob) [link8](#qiskit_ibm_runtime.RuntimeJob.job) [link9](/api/qiskit/algorithms) -[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)\n`, +[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble) +[link11](qiskit_ibm_runtime.RuntimeJob#a_method) +[link12](qiskit_ibm_runtime.RuntimeJob#another_method)\n`, meta: { apiName: "qiskit_ibm_runtime.RuntimeJob", apiType: "class", @@ -149,7 +153,9 @@ test.describe("updateLinks", () => { [link7](runtime-job) [link8](#qiskit_ibm_runtime.RuntimeJob.job) [link9](/api/qiskit/algorithms) -[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble)\n`, +[link10](/api/qiskit/qiskit.circuit.BreakLoopOp#assemble) +[link11](runtime-job#a_method) +[link12](runtime-job#another_method)\n`, meta: { apiName: "qiskit_ibm_runtime.RuntimeJob", apiType: "class", diff --git a/scripts/js/lib/api/updateLinks.ts b/scripts/js/lib/api/updateLinks.ts index c63649d64b5..d1f8c4c6a42 100644 --- a/scripts/js/lib/api/updateLinks.ts +++ b/scripts/js/lib/api/updateLinks.ts @@ -92,9 +92,21 @@ export function normalizeUrl( url = normalizedUrlWithoutHash; } + // Rather than linking to the component like `Function` or `Attribute`, we link to the header. + // This is necessary because until we implement https://github.com/Qiskit/documentation/issues/1395, the + // anchor for the component would take you too low in the page, given that the header is above the component. // qiskit_ibm_runtime.RuntimeJob#qiskit_ibm_runtime.RuntimeJob.job -> qiskit_ibm_runtime.RuntimeJob#job + // + // TODO(#2217): Remove this special case and use the full ID instead. if (hash?.startsWith(`${page}.`)) { - const member = removePrefix(hash, `${page}.`); + let member = removePrefix(hash, `${page}.`); + // Also check for inline classes, which often show up on module pages. + // qiskit_addon_obp.utils.truncating#qiskit_addon_obp.utils.truncating.TruncationErrorBudget.p_norm + // -> qiskit_addon_obp.utils.truncating#p_norm, whereas without this check + // it would be qiskit_addon_obp.utils.truncating#TruncationErrorBudget.p_norm. + if (member.includes(".")) { + member = member.split(".", 2)[1]; + } url = `${normalizedUrlWithoutHash}#${member}`; } }