forked from Qiskit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get CI green for guides migration (Qiskit#1520)
Part of Qiskit#1462 This PR prepares our checks for the guides migration to get green CI when we make the change. Changes: - Added API docs links to `ignore.ts`. Those links need to be updated from the other repos and from the Box artifacts for historical versions. Once the migration is done we'll have redirects set up for those links as explained [here](Qiskit#1461). - Added some words to the cspell dictionary and fixed other complaints from the checker - Added a script to fix the Qiskit bot files by changing the paths to `guides/`. The PR also changes the ignores we had to `guides/`, leaving the old ones that should be removed once the migration is done. - Fixed the `update_internal_links.py` script to switch over more links and consider the migration guides. - Added entries for the notebooks with their names on the `guides/` folder. Once the migration is done, we need to remove the old ones.
- Loading branch information
1 parent
f68dc7c
commit c7e2a8b
Showing
8 changed files
with
197 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,4 +159,7 @@ simulable | |
resynthesizes | ||
sdist" | ||
transpiling | ||
mthree | ||
Algorithmiq | ||
unphysical | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env python3.11 | ||
|
||
# This code is a Qiskit project. | ||
# | ||
# (C) Copyright IBM 2024. | ||
# | ||
# This code is licensed under the Apache License, Version 2.0. You may obtain a | ||
# copy of this license in the LICENSE file in the root directory of this source | ||
# tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this copyright | ||
# notice, and modified files need to carry a notice indicating that they have | ||
# been altered from the originals. | ||
|
||
import yaml | ||
from textwrap import dedent | ||
from pathlib import Path | ||
from main import OLD_FOLDERS, REDIRECTS | ||
|
||
|
||
def get_new_qiskit_bot_notifications(qiskit_bot_file_path: str) -> None: | ||
with open(qiskit_bot_file_path, "r") as file: | ||
data = yaml.load(file, Loader=yaml.SafeLoader) | ||
|
||
new_entries = {} | ||
for file_path in data["notifications"]: | ||
file_path_split = file_path.split("/") | ||
search_key = f"{file_path_split[-2]}/{file_path_split[-1]}" | ||
|
||
if search_key in REDIRECTS: | ||
new_file = REDIRECTS[search_key] | ||
if new_file == "": | ||
new_file = "index" | ||
new_entries[f"docs/guides/{new_file}"] = data["notifications"][file_path] | ||
elif file_path_split[-2] not in OLD_FOLDERS: | ||
# We don't want to modify the migration guides | ||
new_entries[file_path] = data["notifications"][file_path] | ||
|
||
return new_entries | ||
|
||
|
||
def replace_indentation_placeholder(qiskit_bot_file_path: str) -> None: | ||
file = Path(qiskit_bot_file_path) | ||
data = file.read_text() | ||
data = data.replace('"INDENTATION":', "notifications:") | ||
file.write_text(data) | ||
|
||
|
||
def generate_new_qiskit_bot_file( | ||
qiskit_bot_file_path: str, notifications: dict[str, str] | ||
) -> None: | ||
with open(qiskit_bot_file_path, "w") as file: | ||
file.write( | ||
dedent( | ||
"""\ | ||
--- | ||
always_notify: true | ||
notification_prelude: | | ||
Thanks for contributing to Qiskit documentation! | ||
Before your PR can be merged, it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. Thanks! 🙌 | ||
# We use backticks around users who don`t want a GitHub notification, but whom | ||
# we still want their name in the Qiskit Bot message so people know they are | ||
# relevant. | ||
""" | ||
) | ||
) | ||
# Use a placeholder to have the correct indentation for the notifications | ||
yaml.dump( | ||
{"INDENTATION": notifications}, | ||
file, | ||
default_flow_style=False, | ||
default_style='"', | ||
) | ||
replace_indentation_placeholder(qiskit_bot_file_path) | ||
|
||
|
||
def main() -> None: | ||
qiskit_bot_file_path = "qiskit_bot.yaml" | ||
notifications = get_new_qiskit_bot_notifications(qiskit_bot_file_path) | ||
generate_new_qiskit_bot_file(qiskit_bot_file_path, notifications) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |