Skip to content

Commit

Permalink
Allow deleting all existing docs guides (Qiskit#1493)
Browse files Browse the repository at this point in the history
Part of Qiskit#1297. Now when
you run `scripts/patterns-reorg/main.py --delete-existing`, Git will
recognize which files were renamed and preserve their Git history.
  • Loading branch information
Eric-Arellano authored Jun 4, 2024
1 parent 7a8945c commit ede6f4a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/patterns-reorg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@

import shutil
import json
from argparse import ArgumentParser
from pathlib import Path

from models import determine_redirects
from entries import TOP_LEVEL_ENTRIES


def create_parser() -> ArgumentParser:
parser = ArgumentParser()
parser.add_argument(
"--delete-existing",
action="store_true",
help="If true, delete the original guides.",
)
return parser


def write_guides_dir() -> None:
folder_path = Path("docs", "guides")
if folder_path.exists():
Expand All @@ -47,10 +58,20 @@ def write_redirects_file() -> None:
fp.write_text(text)


def delete_existing_guides() -> None:
for d in ["start", "run", "verify", "transpile", "build"]:
shutil.rmtree(Path("docs", d))


def main() -> None:
args = create_parser().parse_args()

write_guides_dir()
write_redirects_file()

if args.delete_existing:
delete_existing_guides()


if __name__ == "__main__":
main()

0 comments on commit ede6f4a

Please sign in to comment.