mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Update redirects
This commit is contained in:
@@ -69,6 +69,7 @@ def main():
|
||||
[
|
||||
"git",
|
||||
"diff",
|
||||
"--find-renames",
|
||||
"--name-status",
|
||||
"--diff-filter=R",
|
||||
args.revision1,
|
||||
|
||||
@@ -13,11 +13,13 @@ How to use:
|
||||
- Run this script
|
||||
|
||||
Example:
|
||||
python convert_git_renames_to_csv.py stable 3.4 >> redirects.csv
|
||||
python convert_git_renames_to_csv.py stable latest >> redirects.csv
|
||||
python create_redirects.py
|
||||
|
||||
This would add all files that were renamed in 3.4 from stable to redirects.csv,
|
||||
This would add all files that were renamed in latest from stable to redirects.csv,
|
||||
and then create the redirects on RTD accordingly.
|
||||
Make sure to use the old branch first, then the more recent branch (i.e., stable > master).
|
||||
You need to have both branches or revisions available and up to date locally.
|
||||
Care is taken to not add redirects that already exist on RTD.
|
||||
"""
|
||||
|
||||
@@ -38,6 +40,7 @@ USER_AGENT = "Godot RTD Redirects on Mozilla/5.0 (Windows NT 10.0; Win64; x64) A
|
||||
DEFAULT_PAGINATED_SIZE = 1024
|
||||
API_SLEEP_TIME = 0.2 # Seconds.
|
||||
REDIRECT_SUFFIXES = [".html", "/"]
|
||||
BUILD_PATH = "../../_build/html"
|
||||
TIMEOUT_SECONDS = 5
|
||||
HTTP = None
|
||||
|
||||
@@ -72,18 +75,34 @@ def parse_command_line_args():
|
||||
action="store_true",
|
||||
help="Enables verbose output.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--validate",
|
||||
action="store_true",
|
||||
help="Validates each redirect by checking the target page exists. Implies --dry-run.",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
def is_dry_run(args):
|
||||
return args.dry_run or args.validate
|
||||
|
||||
def validate(destination):
|
||||
p = BUILD_PATH + destination
|
||||
if not os.path.exists(p):
|
||||
print("Invalid destination: " + destination + " (" + p + ")")
|
||||
|
||||
def make_redirect(source, destination, args, retry=0):
|
||||
if args.validate:
|
||||
validate(destination)
|
||||
|
||||
json_data = {"from_url": source, "to_url": destination, "type": "page"}
|
||||
headers = REQUEST_HEADERS
|
||||
|
||||
if args.verbose:
|
||||
print("POST " + REDIRECT_URL, headers, json_data)
|
||||
|
||||
if args.dry_run:
|
||||
print(f"Created redirect {source} -> {destination} (DRY RUN)")
|
||||
if is_dry_run(args):
|
||||
if not args.validate:
|
||||
print(f"Created redirect {source} -> {destination} (DRY RUN)")
|
||||
return
|
||||
|
||||
response = HTTP.post(
|
||||
@@ -222,7 +241,7 @@ def redirect_to_str(item):
|
||||
def main():
|
||||
args = parse_command_line_args()
|
||||
|
||||
if not args.dry_run:
|
||||
if not is_dry_run(args):
|
||||
load_auth()
|
||||
|
||||
retry_strategy = Retry(
|
||||
@@ -252,12 +271,12 @@ def main():
|
||||
print("Loaded", len(redirects_file), "redirects from", args.file + ".")
|
||||
|
||||
existing = []
|
||||
if not args.dry_run:
|
||||
if not is_dry_run(args):
|
||||
existing = get_existing_redirects(args.delete)
|
||||
print("Loaded", len(existing), "existing redirects from RTD.")
|
||||
|
||||
print("Total redirects:", str(len(to_add)) +
|
||||
" (+" + str(len(existing)), "existing.)")
|
||||
" new + " + str(len(existing)), "existing =", to_add+existing, "total")
|
||||
|
||||
redirects = []
|
||||
added = {}
|
||||
@@ -312,12 +331,12 @@ def main():
|
||||
if not id(redirect[0], redirect[1]) in existing_ids:
|
||||
make_redirect(redirect[0], redirect[1], args)
|
||||
|
||||
if not args.dry_run:
|
||||
if not is_dry_run(args):
|
||||
sleep()
|
||||
|
||||
print("Finished creating", len(redirects), "redirects.")
|
||||
|
||||
if args.dry_run:
|
||||
if is_dry_run(args):
|
||||
print("THIS WAS A DRY RUN, NOTHING WAS SUBMITTED TO READTHEDOCS!")
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ source,destination
|
||||
/development/compiling/compiling_for_uwp.html,/contributing/development/compiling/compiling_for_uwp.html
|
||||
/development/compiling/compiling_for_web.html,/contributing/development/compiling/compiling_for_web.html
|
||||
/development/compiling/compiling_for_windows.html,/contributing/development/compiling/compiling_for_windows.html
|
||||
/development/compiling/compiling_for_x11.html,/contributing/development/compiling/compiling_for_linuxbsd.html
|
||||
/development/compiling/compiling_with_mono.html,/contributing/development/compiling/compiling_with_mono.html
|
||||
/development/compiling/compiling_with_script_encryption_key.html,/contributing/development/compiling/compiling_with_script_encryption_key.html
|
||||
/development/compiling/cross-compiling_for_ios_on_linux.html,/contributing/development/compiling/cross-compiling_for_ios_on_linux.html
|
||||
@@ -324,11 +325,13 @@ source,destination
|
||||
/reference/shading_language.html,/learning/features/shading/shading_language.html
|
||||
/reference/unity_to_godot.html,/learning/editor/unity_to_godot.html
|
||||
/reference/variant_class.html,/development/cpp/variant_class.html
|
||||
/tutorials/3d/introduction_to_global_illumination.html,/tutorials/3d/global_illumination/introduction_to_global_illumination.html
|
||||
/tutorials/3d/faking_global_illumination.html,/tutorials/3d/global_illumination/faking_global_illumination.html
|
||||
/tutorials/3d/introduction_to_global_illumination.html,/tutorials/3d/global_illumination/introduction_to_global_illumination.html
|
||||
/tutorials/3d/inverse_kinematics.html,/community/tutorials/3d/inverse_kinematics.html
|
||||
/tutorials/3d/procedural_geometry/immediategeometry.html,/tutorials/3d/procedural_geometry/immediatemesh.html
|
||||
/tutorials/3d/reflection_probes.html,/tutorials/3d/global_illumination/reflection_probes.html
|
||||
/tutorials/3d/sdfgi.html,/tutorials/3d/global_illumination/using_sdfgi.html
|
||||
/tutorials/3d/spatial_material.html,/tutorials/3d/standard_material_3d.html
|
||||
/tutorials/3d/using_lightmap_gi.html,/tutorials/3d/global_illumination/using_lightmap_gi.html
|
||||
/tutorials/3d/using_voxel_gi.html,/tutorials/3d/global_illumination/using_voxel_gi.html
|
||||
/tutorials/3d/vertex_animation/animating_thousands_of_fish.html,/tutorials/performance/vertex_animation/animating_thousands_of_fish.html
|
||||
@@ -380,15 +383,21 @@ source,destination
|
||||
/tutorials/optimization/optimizing_3d_performance.html,/tutorials/performance/optimizing_3d_performance.html
|
||||
/tutorials/optimization/using_multimesh.html,/tutorials/performance/using_multimesh.html
|
||||
/tutorials/optimization/using_servers.html,/tutorials/performance/using_servers.html
|
||||
/tutorials/physics/using_kinematic_body_2d.html,/tutorials/physics/using_character_body_2d.html
|
||||
/tutorials/platform/android_in_app_purchases.html,/tutorials/platform/android/android_in_app_purchases.html
|
||||
/tutorials/platform/customizing_html5_shell.html,/tutorials/platform/web/customizing_html5_shell.html
|
||||
/tutorials/platform/html5_shell_classref.html,/tutorials/platform/web/html5_shell_classref.html
|
||||
/tutorials/platform/platform_html5.html,/tutorials/platform/web/index.html
|
||||
/tutorials/plugins/android/android_plugin.html,/tutorials/platform/android/android_plugin.html
|
||||
/tutorials/plugins/android/index.html,/tutorials/platform/android/index.html
|
||||
/tutorials/plugins/editor/spatial_gizmos.html,/tutorials/plugins/editor/3d_gizmos.html
|
||||
/tutorials/plugins/gdnative/gdnative-c-example.html,/tutorials/scripting/gdnative/gdnative_c_example.html
|
||||
/tutorials/plugins/gdnative/gdnative-cpp-example.html,/tutorials/scripting/gdnative/gdnative_cpp_example.html
|
||||
/tutorials/plugins/gdnative/index.html,/tutorials/scripting/gdnative/index.html
|
||||
/tutorials/scripting/gdnative/gdnative_c_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
|
||||
/tutorials/scripting/gdnative/gdnative_cpp_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
|
||||
/tutorials/scripting/gdnative/index.html,/tutorials/scripting/gdextension/index.html
|
||||
/tutorials/scripting/gdnative/what_is_gdnative.html,/tutorials/scripting/gdnative/what_is_gdextension.html
|
||||
/tutorials/shading/advanced_postprocessing.html,/tutorials/shaders/advanced_postprocessing.html
|
||||
/tutorials/shading/godot_shader_language_style_guide.html,/tutorials/shaders/shaders_style_guide.html
|
||||
/tutorials/shading/index.html,/tutorials/shaders/index.html
|
||||
@@ -409,10 +418,3 @@ source,destination
|
||||
/tutorials/viewports/multiple_resolutions.html,/tutorials/rendering/multiple_resolutions.html
|
||||
/tutorials/viewports/using_viewport_as_texture.html,/tutorials/shaders/using_viewport_as_texture.html
|
||||
/tutorials/viewports/viewports.html,/tutorials/rendering/viewports.html
|
||||
/tutorials/physics/using_kinematic_body_2d.html,/tutorials/physics/using_character_body_2d.html
|
||||
/tutorials/plugins/editor/spatial_gizmos.html,/tutorials/plugins/editor/3d_gizmos.html
|
||||
/tutorials/3d/procedural_geometry/immediategeometry.html,/tutorials/3d/procedural_geometry/immediatemesh.html
|
||||
/tutorials/scripting/gdnative/index.html,/tutorials/scripting/gdextension/index.html
|
||||
/tutorials/scripting/gdnative/what_is_gdnative.html,/tutorials/scripting/gdnative/what_is_gdextension.html
|
||||
/tutorials/scripting/gdnative/gdnative_c_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
|
||||
/tutorials/scripting/gdnative/gdnative_cpp_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
|
||||
|
||||
|
Reference in New Issue
Block a user