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

Ensure API docs don't have stale images #2541

Merged
merged 7 commits into from
Jan 3, 2025
Merged

Conversation

Eric-Arellano
Copy link
Collaborator

@Eric-Arellano Eric-Arellano commented Jan 2, 2025

Closes #2538. We only didn't delete the API images due to #2540.

To fix #2540, we have to fix our skip of release note images. We also had to manually move 4 release note images for legacy release note files from the latest Qiskit images folder to instead the 0.40 and 0.43 Box artifacts, then manually update those release notes to point to the paths. With those fixes and the re-uploaded Box artifacts, npm run regen-apis doesn't make changes.

This change allows us to have checkStaleImages.ts no longer worry about API docs images, which dramatically speeds up the program. It's now fast enough to run on every PR. Closes #2530.

With ripgrep:

  Time (mean ± σ):      1.705 s ±  0.022 s    [User: 1.143 s, System: 1.085 s]
  Range (min … max):    1.660 s …  1.735 s    10 runs

With git grep (CI):

  Time (mean ± σ):      4.118 s ±  0.054 s    [User: 11.290 s, System: 1.092 s]
  Range (min … max):    4.044 s …  4.200 s    10 runs

} else if (pkg.isDev()) {
// We don't want to store images from other versions when we generate a
// different dev version
await rmFilesInFolder(destFolder);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary because updateApiDocs.ts will have already removed all images as part of removing Markdown.

@Eric-Arellano Eric-Arellano changed the title [on hold] Ensure API docs don't have stale images Ensure API docs don't have stale images Jan 2, 2025
@Eric-Arellano Eric-Arellano marked this pull request as ready for review January 2, 2025 22:09
@Eric-Arellano
Copy link
Collaborator Author

Hold off on merging. npm run regen-apis shows that these images are lost due to this PR:

docs/api/qiskit/release-notes/0.40.mdx
59:>     ![\_images/legacy\_release\_notes-2.png](/images/api/qiskit/legacy_release_notes-2.png)
349:    ![\_images/legacy\_release\_notes-3.png](/images/api/qiskit/legacy_release_notes-3.png)
599:    ![\_images/legacy\_release\_notes-4.png](/images/api/qiskit/legacy_release_notes-4.png)

docs/api/qiskit/release-notes/0.43.mdx
595:    ![\_images/legacy\_release\_notes-1.png](/images/api/qiskit/legacy_release_notes-1.png)

I need to figure out the cleanest way to fix this problem.

@Eric-Arellano Eric-Arellano changed the title Ensure API docs don't have stale images [on hold] Ensure API docs don't have stale images Jan 2, 2025
Copy link
Collaborator

@arnaucasau arnaucasau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!! Looking at the lost images, they were manually added to the current version folder in #346. Given that only those two versions use the legacy release note images, maybe we could store the images in their folders and manually modify their links in 0.40.mdx and 0.43.mdx to point to the new location.

scripts/js/lib/zx.ts Outdated Show resolved Hide resolved
scripts/js/commands/api/updateApiDocs.ts Outdated Show resolved Hide resolved
@Eric-Arellano
Copy link
Collaborator Author

maybe we could store the images in their folders and manually modify their links in 0.40.mdx and 0.43.mdx to point to the new location.

Thanks for finding that. I tried that approach but we still don't copy the images because this code only copies images we actually use:

console.log("Saving images");
const allImages = uniqBy(
results.flatMap((result) => result.images),
(image) => image.fileName,
);
await saveImages(allImages, `${htmlPath}/_images`, publicBaseFolder, pkg);

So, I think the best approach is to instead save the images in a non-auto-generated folder.

@Eric-Arellano Eric-Arellano changed the title [on hold] Ensure API docs don't have stale images Ensure API docs don't have stale images Jan 3, 2025
Copy link
Collaborator

@arnaucasau arnaucasau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Tested locally and works well! 🚀

@Eric-Arellano Eric-Arellano added this pull request to the merge queue Jan 3, 2025
Merged via the queue into main with commit b393158 Jan 3, 2025
3 checks passed
@Eric-Arellano Eric-Arellano deleted the EA/stale-api-images branch January 3, 2025 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
2 participants