Add logic to generate ordered list of templates

We need to list templates in their table of contents order
if we want the monolithic POT file to match the order of
the documentation, which is more translator-friendly than
an folder-wise alphabetical ordering of POT files.

The logic is hacky and requires a prebuilt index.html from
the docs repo, but it works™.
This commit is contained in:
Rémi Verschelde
2018-05-08 21:55:46 +02:00
parent 9a18b140e2
commit 36c9962f51
2 changed files with 224 additions and 1 deletions

199
templates_list.txt Normal file
View File

@@ -0,0 +1,199 @@
index.pot
about/index.pot
about/introduction.pot
about/faq.pot
getting_started/step_by_step/index.pot
getting_started/step_by_step/intro_to_the_editor_interface.pot
getting_started/step_by_step/scenes_and_nodes.pot
getting_started/step_by_step/instancing.pot
getting_started/step_by_step/instancing_continued.pot
getting_started/step_by_step/scripting.pot
getting_started/step_by_step/scripting_continued.pot
getting_started/step_by_step/your_first_game.pot
getting_started/step_by_step/godot_design_philosophy.pot
getting_started/step_by_step/ui_introduction_to_the_ui_system.pot
getting_started/step_by_step/ui_main_menu.pot
getting_started/step_by_step/ui_game_user_interface.pot
getting_started/step_by_step/ui_code_a_life_bar.pot
getting_started/step_by_step/splash_screen.pot
getting_started/step_by_step/animations.pot
getting_started/step_by_step/resources.pot
getting_started/step_by_step/filesystem.pot
getting_started/step_by_step/scene_tree.pot
getting_started/step_by_step/singletons_autoload.pot
getting_started/editor/index.pot
getting_started/editor/unity_to_godot.pot
getting_started/editor/command_line_tutorial.pot
getting_started/editor/external_editor.pot
getting_started/scripting/index.pot
getting_started/scripting/gdscript/index.pot
getting_started/scripting/gdscript/gdscript_basics.pot
getting_started/scripting/gdscript/gdscript_advanced.pot
getting_started/scripting/gdscript/gdscript_styleguide.pot
getting_started/scripting/gdscript/gdscript_format_string.pot
getting_started/scripting/visual_script/index.pot
getting_started/scripting/visual_script/what_is_visual_scripting.pot
getting_started/scripting/visual_script/getting_started.pot
getting_started/scripting/visual_script/nodes_purposes.pot
getting_started/scripting/c_sharp/index.pot
getting_started/scripting/c_sharp/c_sharp_basics.pot
getting_started/scripting/c_sharp/c_sharp_features.pot
getting_started/scripting/c_sharp/c_sharp_differences.pot
getting_started/scripting/c_sharp/c_sharp_style_guide.pot
getting_started/workflow/index.pot
getting_started/workflow/project_setup/index.pot
getting_started/workflow/project_setup/project_organization.pot
getting_started/workflow/assets/index.pot
getting_started/workflow/assets/import_process.pot
getting_started/workflow/assets/importing_images.pot
getting_started/workflow/assets/importing_audio_samples.pot
getting_started/workflow/assets/importing_translations.pot
getting_started/workflow/assets/importing_scenes.pot
getting_started/workflow/export/index.pot
getting_started/workflow/export/exporting_projects.pot
getting_started/workflow/export/feature_tags.pot
getting_started/workflow/export/exporting_for_pc.pot
getting_started/workflow/export/exporting_for_ios.pot
getting_started/workflow/export/exporting_for_uwp.pot
getting_started/workflow/export/exporting_for_android.pot
getting_started/workflow/export/exporting_for_web.pot
getting_started/workflow/export/customizing_html5_shell.pot
getting_started/workflow/export/one-click_deploy.pot
getting_started/workflow/export/changing_application_icon_for_windows.pot
tutorials/2d/index.pot
tutorials/2d/canvas_layers.pot
tutorials/2d/2d_transforms.pot
tutorials/2d/using_tilemaps.pot
tutorials/2d/custom_drawing_in_2d.pot
tutorials/2d/particle_systems_2d.pot
tutorials/2d/2d_movement.pot
tutorials/3d/index.pot
tutorials/3d/introduction_to_3d.pot
tutorials/3d/using_transforms.pot
tutorials/3d/3d_performance_and_limitations.pot
tutorials/3d/spatial_material.pot
tutorials/3d/lights_and_shadows.pot
tutorials/3d/reflection_probes.pot
tutorials/3d/gi_probes.pot
tutorials/3d/baked_lightmaps.pot
tutorials/3d/environment_and_post_processing.pot
tutorials/3d/high_dynamic_range.pot
tutorials/3d/using_gridmaps.pot
tutorials/3d/using_multi_mesh_instance.pot
tutorials/3d/working_with_3d_skeletons.pot
tutorials/3d/inverse_kinematics.pot
tutorials/3d/mesh_generation_with_heightmap_and_shaders.pot
tutorials/3d/fps_tutorial/index.pot
tutorials/3d/fps_tutorial/part_one.pot
tutorials/3d/fps_tutorial/part_two.pot
tutorials/3d/fps_tutorial/part_three.pot
tutorials/3d/fps_tutorial/part_four.pot
tutorials/3d/fps_tutorial/part_five.pot
tutorials/3d/fps_tutorial/part_six.pot
tutorials/audio/index.pot
tutorials/audio/audio_buses.pot
tutorials/audio/audio_streams.pot
tutorials/physics/index.pot
tutorials/physics/physics_introduction.pot
tutorials/physics/rigid_body.pot
tutorials/physics/using_kinematic_body_2d.pot
tutorials/physics/ray-casting.pot
tutorials/physics/kinematic_character_2d.pot
tutorials/math/index.pot
tutorials/math/vector_math.pot
tutorials/math/vectors_advanced.pot
tutorials/math/rotations.pot
tutorials/math/matrices_and_transforms.pot
tutorials/animation/index.pot
tutorials/animation/introduction_2d.pot
tutorials/animation/cutout_animation.pot
tutorials/inputs/index.pot
tutorials/inputs/inputevent.pot
tutorials/inputs/mouse_and_input_coordinates.pot
tutorials/inputs/custom_mouse_cursor.pot
tutorials/io/index.pot
tutorials/io/background_loading.pot
tutorials/io/data_paths.pot
tutorials/io/saving_games.pot
tutorials/io/encrypting_save_games.pot
tutorials/i18n/index.pot
tutorials/i18n/internationalizing_games.pot
tutorials/i18n/locales.pot
tutorials/gui/index.pot
tutorials/gui/gui_skinning.pot
tutorials/gui/custom_gui_controls.pot
tutorials/gui/size_and_anchors.pot
tutorials/gui/bbcode_in_richtextlabel.pot
tutorials/viewports/index.pot
tutorials/viewports/viewports.pot
tutorials/viewports/multiple_resolutions.pot
tutorials/shading/index.pot
tutorials/shading/shading_language.pot
tutorials/shading/shader_materials.pot
tutorials/shading/screen-reading_shaders.pot
tutorials/networking/index.pot
tutorials/networking/high_level_multiplayer.pot
tutorials/networking/http_request_class.pot
tutorials/networking/http_client_class.pot
tutorials/networking/ssl_certificates.pot
tutorials/assetlib/index.pot
tutorials/assetlib/what_is_assetlib.pot
tutorials/assetlib/using_assetlib.pot
tutorials/assetlib/uploading_to_assetlib.pot
tutorials/vr/index.pot
tutorials/vr/vr_primer.pot
tutorials/plugins/index.pot
tutorials/plugins/editor/index.pot
tutorials/plugins/editor/making_plugins.pot
tutorials/plugins/editor/import_plugins.pot
tutorials/plugins/gdnative/index.pot
tutorials/plugins/gdnative/gdnative-c-example.pot
tutorials/platform/index.pot
tutorials/platform/android_in_app_purchases.pot
tutorials/platform/services_for_ios.pot
tutorials/platform/consoles.pot
tutorials/misc/index.pot
tutorials/misc/handling_quit_requests.pot
tutorials/misc/pausing_games.pot
tutorials/misc/binary_serialization_api.pot
tutorials/debug/index.pot
tutorials/debug/overview_of_debugging_tools.pot
development/compiling/index.pot
development/compiling/getting_source.pot
development/compiling/introduction_to_the_buildsystem.pot
development/compiling/compiling_for_windows.pot
development/compiling/compiling_for_x11.pot
development/compiling/compiling_for_osx.pot
development/compiling/compiling_for_android.pot
development/compiling/compiling_for_ios.pot
development/compiling/cross-compiling_for_ios_on_linux.pot
development/compiling/compiling_for_uwp.pot
development/compiling/compiling_for_web.pot
development/compiling/compiling_with_mono.pot
development/compiling/packaging_godot.pot
development/cpp/index.pot
development/cpp/introduction_to_godot_development.pot
development/cpp/configuring_an_ide.pot
development/cpp/core_types.pot
development/cpp/variant_class.pot
development/cpp/object_class.pot
development/cpp/inheritance_class_tree.pot
development/cpp/custom_modules_in_cpp.pot
development/cpp/custom_resource_format_loaders.pot
development/cpp/custom_audiostreams.pot
development/cpp/custom_godot_servers.pot
development/cpp/creating_android_modules.pot
development/file_formats/index.pot
development/file_formats/tscn.pot
community/index.pot
community/contributing/index.pot
community/contributing/ways_to_contribute.pot
community/contributing/pr_workflow.pot
community/contributing/code_style_guidelines.pot
community/contributing/bug_triage_guidelines.pot
community/contributing/documentation_guidelines.pot
community/contributing/docs_writing_guidelines.pot
community/contributing/updating_the_class_reference.pot
community/channels.pot
community/tutorials.pot
community/resources.pot

View File

@@ -3,7 +3,10 @@
# Defines
SOURCE_DIR="docs"
SPHINX_TEMPLATES_DIR="sphinx/templates"
SPHINX_TEMPLATES=$(find $SPHINX_TEMPLATES_DIR -type f -name "*.pot")
# This variant comes ordered alphabetically instead of following the TOC, not nice for translators
#SPHINX_TEMPLATES=$(find $SPHINX_TEMPLATES_DIR -type f -name "*.pot")
# This one is manually maintained, see --templates-list switch
SPHINX_TEMPLATES=$(sed -e 's@^@'$SPHINX_TEMPLATES_DIR'/@' templates_list.txt)
SPHINX_PO_DIR="sphinx/po"
WEBLATE_DIR="weblate"
@@ -14,6 +17,7 @@ WEBLATE_POFILES=$(find $WEBLATE_DIR -type f -name "*.po")
LANGS="es fr zh_CN"
# Options
make_templates_list=false
update_sphinx_pot=false
update_sphinx_po=false
update_weblate_pot=false
@@ -23,6 +27,9 @@ add_langs=false
# Command line arguments
while [ $# -gt 0 ]; do
case "$1" in
--templates-list|-tl)
make_templates_list=true
;;
--sphinx-pot|-st)
update_sphinx_pot=true
;;
@@ -58,6 +65,22 @@ while [ $# -gt 0 ]; do
shift
done
# Make ordered list of Sphinx templates based on table of contents in index.html
# This requires having run `make html` in the docs repo and copied the main
# `index.html` over next to this script.
if [ "$make_templates_list" = true ]; then
echo "=== Making ordered list of Sphinx templates based on table of contents ==="
if [ ! -f "index.html" ]; then
echo "Main 'index.html' file is missing, build it with 'make docs' and copy it here."
exit 1
fi
# The strings we are interested in are of the form:
# <li class="toctree-l1"><a class="reference internal" href="about/index.html">About</a><ul>
toc=$(grep "<li class=\"toctree-.*href=\".*.html\">.*" index.html)
templates=$(echo "$toc" | sed -e 's@^.*href="\(.*\)\.html".*@\1.pot@' | awk '!x[$0]++')
echo -e "index.pot\n$templates" > templates_list.txt
fi
# Generate/Update Sphinx template from rst files
if [ "$update_sphinx_pot" = true ]; then
echo "=== Updating Sphinx templates from source rst files ==="
@@ -71,6 +94,7 @@ if [ "$update_weblate_pot" = true ]; then
echo "=== Updating Weblate monolithic template from Sphinx templates ==="
if [ ! -d "$SPHINX_TEMPLATES_DIR" ]; then
echo "Sphinx templates are missing, please run with --sphinx-pot."
exit 1
fi
if [ ! -d "$WEBLATE_DIR" ]; then
mkdir $WEBLATE_DIR