libsdl-org / sdlwiki

This is the raw contents of SDL's wiki. You can edit this through GitHub or at https://wiki.libsdl.org/ now!
https://wiki.libsdl.org/
84 stars 38 forks source link

Removes API pages for types that were renamed in SDL3. #497

Closed blaisemccourtney closed 6 months ago

blaisemccourtney commented 6 months ago

I made this helper script to delete the right pages and to double-check things.


import subprocess
import os

renamed_split_str = "_renamed_"

if not os.path.exists("sdlwiki/SDL3/"):

    print("Repository expected at: sdlwiki/ . Works on folder: sdlwiki/SDL3/ .")
    exit(1)

with open("SDL_oldnames.h") as f:

    removed_list = []

    for line in f:

        if renamed_split_str in line:

            words = line.split(" ")

            for word in words:

                if renamed_split_str in word:

                    [old_name, new_name] = word.split(renamed_split_str)

                    old_name = old_name.strip()
                    new_name = new_name.strip()

                    path_to_delete = "SDL3/" + old_name + ".md"

                    try:
                        return_value = subprocess.check_call(
                            "git rm " + path_to_delete,
                            shell=True,
                            cwd="sdlwiki",
                            stdout=subprocess.DEVNULL,
                            stderr=subprocess.DEVNULL
                        )

                        removed_list.append(old_name)

                        print(old_name)

                    except subprocess.CalledProcessError:

                        pass

    if len(removed_list) < 1:

        print("!!! Did not find anything to remove! !!!")

    else:

        print("Removed: " + str(len(removed_list)))

        print("grep command: grep -rI \"\\(" + "\\|".join(removed_list) + "\\)\" .")
slouken commented 6 months ago

Thanks!