diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c9e3a2f3d61..9af86869377 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -6,7 +6,7 @@ labels: bug assignees: '' --- -**Your Godot version:** +**Your Redot version:** **Issue description:** @@ -14,6 +14,6 @@ assignees: '' If you know how to fix the issue you are reporting please consider opening a pull request. We provide a tutorial on -using git here: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html, -writing documentation at https://docs.godotengine.org/en/stable/community/contributing/docs_writing_guidelines.html -and contributing to the class reference here: https://docs.godotengine.org/en/stable/community/contributing/updating_the_class_reference.html +using git here: https://docs.redotengine.org/en/stable/community/contributing/pr_workflow.html, +writing documentation at https://docs.redotengine.org/en/stable/community/contributing/docs_writing_guidelines.html +and contributing to the class reference here: https://docs.redotengine.org/en/stable/community/contributing/updating_the_class_reference.html diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 9b01966e08a..d8eabd1e1d4 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +1,14 @@ blank_issues_enabled: false contact_links: - - name: Godot community channels - url: https://godotengine.org/community + - name: Redot community channels + url: https://redotengine.org/community about: Please ask for technical support on one of the other community channels, not here. - - name: Godot proposals - url: https://github.com/godotengine/godot-proposals - about: Please submit engine feature proposals on the Godot proposals repository, not here. + - name: Redot proposals + url: https://github.com/redot-engine/redot-proposals + about: Please submit engine feature proposals on the Redot proposals repository, not here. - - name: Main Godot repository - url: https://github.com/godotengine/godot - about: Report engine bugs on the main Godot repository + - name: Main Redot repository + url: https://github.com/redot-engine/redot + about: Report engine bugs on the main Redot repository diff --git a/.github/ISSUE_TEMPLATE/enhancement_request.md b/.github/ISSUE_TEMPLATE/enhancement_request.md index d6b2f3caa93..d7c3aed25a6 100644 --- a/.github/ISSUE_TEMPLATE/enhancement_request.md +++ b/.github/ISSUE_TEMPLATE/enhancement_request.md @@ -6,7 +6,7 @@ labels: enhancement assignees: '' --- -**Your Godot version:** +**Your Redot version:** **Issue description:** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 62e3e211d3b..b37c87b763e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,5 +4,5 @@ PRs can target other branches (e.g. `3.2`, `3.5`) if the same change was done in PRs must not target `stable`, as that branch is updated manually. The type of content accepted into the documentation is explained here: -https://docs.godotengine.org/en/latest/community/contributing/content_guidelines.html +https://docs.redotengine.org/en/latest/community/contributing/content_guidelines.html --> diff --git a/.github/workflows/build_offline_docs.yml b/.github/workflows/build_offline_docs.yml index 4499de52bb2..3c7b58ea872 100644 --- a/.github/workflows/build_offline_docs.yml +++ b/.github/workflows/build_offline_docs.yml @@ -26,12 +26,16 @@ jobs: sudo apt update sudo apt install parallel libwebp7 + - name: Migrate to Redot + run: | + python migrate.py . _migrated False + - name: Sphinx - Build HTML - run: make SPHINXOPTS='--color' html + run: make SPHINXOPTS='--color' SPHINXSOURCEDIR='./_migrated' html - uses: actions/upload-artifact@v4 with: - name: godot-docs-html-${{ matrix.branch }} + name: redot-docs-html-${{ matrix.branch }} path: _build/html # Keep the current build and the previous build (in case a scheduled build failed). # This makes it more likely to have at least one successful build available at all times. @@ -46,15 +50,15 @@ jobs: parallel --will-cite sed -i "s/\\.webp$/\\.png/g" ::: {about,community,contributing,getting_started,tutorials}/**/*.rst # Remove banners at the top of each page when building `latest`. - sed -i 's/"godot_is_latest": True/"godot_is_latest": False/' conf.py - sed -i 's/"godot_show_article_status": True/"godot_show_article_status": False/' conf.py + sed -i 's/"redot_is_latest": True/"redot_is_latest": False/' conf.py + sed -i 's/"redot_show_article_status": True/"redot_show_article_status": False/' conf.py - make SPHINXOPTS='--color' epub + make SPHINXOPTS='--color' SPHINXSOURCEDIR='./_migrated' epub - uses: actions/upload-artifact@v4 with: - name: godot-docs-epub-${{ matrix.branch }} - path: _build/epub/GodotEngine.epub + name: redot-docs-epub-${{ matrix.branch }} + path: _build/epub/RedotEngine.epub # Keep the current build and the previous build (in case a scheduled build failed). # This makes it more likely to have at least one successful build available at all times. retention-days: 15 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 028da18569c..51f0b5beaa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,10 @@ jobs: bash _tools/format.sh codespell -I _tools/codespell-ignore.txt -x _tools/codespell-ignore-lines.txt -S tutorials/i18n/locales.rst {about,community,contributing,getting_started,tutorials}/**/*.rst + - name: Migrate to Redot + run: | + python migrate.py . _migrated True + # Use dummy builder to improve performance as we don't need the generated HTML in this workflow. - name: Sphinx build - run: make SPHINXOPTS='--color -W' dummy + run: make SPHINXOPTS='--color -W' SPHINXSOURCEDIR='./_migrated' dummy diff --git a/.github/workflows/sync_class_ref.yml b/.github/workflows/sync_class_ref.yml index fdeb0cedb4d..3acd2ee4413 100644 --- a/.github/workflows/sync_class_ref.yml +++ b/.github/workflows/sync_class_ref.yml @@ -27,7 +27,7 @@ jobs: - name: Checkout the engine repository uses: actions/checkout@v4 with: - repository: 'godotengine/godot' + repository: 'redot-engine/redot-engine' # Use the appropriate branch for the documentation version. ref: ${{ env.engine_rev }} path: './.engine-src' @@ -38,7 +38,7 @@ jobs: cd ./.engine-src hash=$(git rev-parse HEAD) hash_short=$(git rev-parse --short HEAD) - echo "Checked out godotengine/godot at $hash" + echo "Checked out redot-engine/redot at $hash" echo "rev_hash=$hash" >> $GITHUB_OUTPUT echo "rev_hash_short=$hash_short" >> $GITHUB_OUTPUT @@ -59,10 +59,10 @@ jobs: delete-branch: true # Configure the commit author. - author: 'Godot Organization ' - committer: 'Godot Organization ' + author: 'Redot Organization ' + committer: 'Redot Organization ' # Configure the pull-request. title: 'classref: Sync with current ${{ env.engine_rev }} branch (${{ steps.engine.outputs.rev_hash_short }})' - body: 'Update Godot API online class reference to match the engine at https://github.com/godotengine/godot/commit/${{ steps.engine.outputs.rev_hash }} (`${{ env.engine_rev }}`).' + body: 'Update Redot API online class reference to match the engine at https://github.com/redot-engine/redot/commit/${{ steps.engine.outputs.rev_hash }} (`${{ env.engine_rev }}`).' labels: 'area:class reference,bug,enhancement' diff --git a/.gitignore b/.gitignore index b9e2fbe6c42..2e2df35cecf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .env _build/ +_build-old/ +_migrated/ env/ __pycache__ *.pyc diff --git a/README.md b/README.md index fbd2ba22fa5..8f3f8d181e6 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,38 @@ # Redot Engine documentation -This repository contains the source files of [Godot Engine](https://godotengine.org)'s documentation, in reStructuredText markup language (reST). +This repository contains the source files of [Redot Engine](https://redotengine.org)'s documentation, in reStructuredText markup language (reST). -They are meant to be parsed with the [Sphinx](https://www.sphinx-doc.org/) documentation builder to build the HTML documentation on [Godot's website](https://docs.godotengine.org). +They are meant to be parsed with the [Sphinx](https://www.sphinx-doc.org/) documentation builder to build the HTML documentation on [Redot's website](https://docs.redotengine.org). ## Download for offline use To browse the documentation offline, you can download an HTML copy (updated every Monday): -[stable](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-html-stable.zip), -[latest](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-html-master.zip), -[3.6](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-html-3.6.zip). Extract +[stable](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-html-stable.zip), +[latest](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-html-master.zip), +[3.6](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-html-3.6.zip). Extract the ZIP archive then open the top-level `index.html` in a web browser. For mobile devices or e-readers, you can also download an ePub copy (updated every Monday): -[stable](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-epub-stable.zip), -[latest](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-epub-master.zip), -[3.6](https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot-docs-epub-3.6.zip). Extract -the ZIP archive then open the `GodotEngine.epub` file in an e-book reader application. +[stable](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-epub-stable.zip), +[latest](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-epub-master.zip), +[3.6](https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot-docs-epub-3.6.zip). Extract +the ZIP archive then open the `RedotEngine.epub` file in an e-book reader application. + +## Migrating + +We are transitioning from Godot to Redot. In this period, a temporary solution is available. +``` +python migrate.py . _migrated True +``` + +After the docs are converted, you can build with +``` +sphinx-build -b html ./_migrated/ _build/html +``` ## Theming -The Godot documentation uses the default `sphinx_rtd_theme` with many +The Redot documentation uses the default `sphinx_rtd_theme` with many [customizations](_static/) applied on top. It will automatically switch between the light and dark theme depending on your browser/OS' theming preference. @@ -31,22 +43,22 @@ add-on. ## Contributing -All contributors are welcome to help on the Godot documentation. +All contributors are welcome to help on the Redot documentation. -To get started, head to the [Contributing section](https://docs.godotengine.org/en/latest/contributing/ways_to_contribute.html#contributing-to-the-documentation) of the online manual. There, you will find all the information you need to write and submit changes. +To get started, head to the [Contributing section](https://docs.redotengine.org/en/latest/contributing/ways_to_contribute.html#contributing-to-the-documentation) of the online manual. There, you will find all the information you need to write and submit changes. Here are some quick links to the areas you might be interested in: -1. [Contributing to the online manual](https://docs.godotengine.org/en/latest/contributing/documentation/contributing_to_the_documentation.html) -2. [Contributing to the class reference](https://docs.godotengine.org/en/latest/contributing/documentation/updating_the_class_reference.html) -3. [Content guidelines](https://docs.godotengine.org/en/latest/contributing/documentation/content_guidelines.html) -4. [Writing guidelines](https://docs.godotengine.org/en/latest/contributing/documentation/docs_writing_guidelines.html) -5. [Building the manual](https://docs.godotengine.org/en/latest/contributing/documentation/building_the_manual.html) -6. [Translating the documentation](https://docs.godotengine.org/en/latest/contributing/documentation/editor_and_docs_localization.html) +1. [Contributing to the online manual](https://docs.redotengine.org/en/latest/contributing/documentation/contributing_to_the_documentation.html) +2. [Contributing to the class reference](https://docs.redotengine.org/en/latest/contributing/documentation/updating_the_class_reference.html) +3. [Content guidelines](https://docs.redotengine.org/en/latest/contributing/documentation/content_guidelines.html) +4. [Writing guidelines](https://docs.redotengine.org/en/latest/contributing/documentation/docs_writing_guidelines.html) +5. [Building the manual](https://docs.redotengine.org/en/latest/contributing/documentation/building_the_manual.html) +6. [Translating the documentation](https://docs.redotengine.org/en/latest/contributing/documentation/editor_and_docs_localization.html) ## License -With the exception of the `classes/` folder, all the content of this repository is licensed under the Creative Commons Attribution 3.0 Unported license ([CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)) and is to be attributed to "Juan Linietsky, Ariel Manzur and the Godot community". +With the exception of the `classes/` folder, all the content of this repository is licensed under the Creative Commons Attribution 3.0 Unported license ([CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)) and is to be attributed to "Juan Linietsky, Ariel Manzur and the Redot community". See [LICENSE.txt](/LICENSE.txt) for details. -The files in the `classes/` folder are derived from [Godot's main source repository](https://github.com/godotengine/godot) and are distributed under the MIT license, with the same authors as above. +The files in the `classes/` folder are derived from [Redot's main source repository](https://github.com/redot-engine/redot) and are distributed under the MIT license, with the same authors as above. diff --git a/contributing/how_to_contribute.rst b/contributing/how_to_contribute.rst index 47733956731..e9603a72b0e 100644 --- a/contributing/how_to_contribute.rst +++ b/contributing/how_to_contribute.rst @@ -11,26 +11,6 @@ Because contrary to popular opinion, we need more than just programmers on the p Fundraising ----------- -- **Donate** - - We created the non-profit `Godot Foundation `_ to be able to support the Godot Engine in both matters of finance and administration. - In practice, this means the Foundation hires people to work part-time or full-time on the project. - These jobs include engine development as well as related tasks like code reviews, production management, community & marketing efforts, and more. - - With as little as 5 EUR per month, you can help us keep going strong. - Currently, we are intending to hire more core developers, as to cover more ground with full-time specialists that supplement and guide volunteer work. - - `Join the Development Fund `_ - -- **Donation Drives** - Think about your followers on social media, or other communities you are active in. - Use that reach to remind your social environment that even small contributions can make a difference, especially when done by a great number of people at the same time. - - Are you a content creator? Consider adding a link to the `Godot Development Fund `_ to your descriptions. - If you do live streams, perhaps think about organizing a stream with donation incentives. - -.. - **Buy Official Merch** - - **Publish Godot Games.** You heard right, simply publishing a game #MadeWithGodot can positively impact the well-being of this project. Your personal success elevates the engine to a viable alternative for other developers, growing the community further. diff --git a/favicon.png b/favicon.png new file mode 100644 index 00000000000..38cbcdf12df Binary files /dev/null and b/favicon.png differ diff --git a/img/README.md b/img/README.md index 41d69da1f47..b687c6aaaab 100644 --- a/img/README.md +++ b/img/README.md @@ -1,4 +1,4 @@ # Note The images in this folder aren't referenced anywhere in the manual, but are referenced in the -Godot class reference (both in the editor and on the generated online documentation). +Redot class reference (both in the editor and on the generated online documentation). diff --git a/img/docs_logo.svg b/img/docs_logo.svg index fe52d3e695e..f957d787505 100644 --- a/img/docs_logo.svg +++ b/img/docs_logo.svg @@ -1 +1,35 @@ - + + + + diff --git a/migrate.py b/migrate.py new file mode 100644 index 00000000000..217f7bb9071 --- /dev/null +++ b/migrate.py @@ -0,0 +1,316 @@ +""" +## Migrate files from Godot to Redot + +Usage (order is important): +py migrate.py [inputdir] [outputdir] [include unimplemented] + +example: +py migrate.py . _migrated True + +Will replace specific godot strings with redot. It tries to ignore external projects and other things that can't +change. + +A distinction is made between unimplemented instances of the godot keyword (for instance references to the main +website), and implemented ones (like references to github repositories that are already compatible). + +The idea is that, as the project is being migrated to the new name, the unimplemented mappings will gradually move +to the 'normal' mappings. This way the docs can grow along with the project, keeping broken links to a minimum. When +all is done, migrate.py has served its purpose and can be deleted. + +It will recursively traverse all directories, targeting .rst and .md files. It will convert the text and filename +if necessary, and then save them to the output directory (default _migrated) + +From there, the docs can be built in the normal way. +""" + +import fnmatch +import os +from shutil import copyfile +import shutil +import sys +import codecs +from distutils.dir_util import copy_tree + +encoding = 'utf-8' +defaultInputDirectory = '.' +defaultOutputDirectory = '_migrated' +defaultIncludeUnimplemented = False +filename_masks = ['.rst', '.md'] + +# Mappings that will currently lead to nowhere. Can be treated as a todo list. +mappings_unimplemented = [ + # Non existing urls + ('https://hosted.weblate.org/projects/godot-engine/godot-docs', 'https://hosted.weblate.org/projects/redot-engine/redot-docs'), + ('https://hosted.weblate.org/engage/godot-engine/', 'https://hosted.weblate.org/engage/redot-engine/'), + ('https://store.steampowered.com/app/404790/Godot_Engine/', 'https://store.steampowered.com/app/TODO'), + ('https://flathub.org/apps/details/org.godotengine.Godot', 'https://flathub.org/apps/details/org.redot-engine.Redot'), + ('https://godot.foundation', 'https://redot.foundation'), + ('https://hosted.weblate.org/projects/godot-engine/godot/', 'https://hosted.weblate.org/projects/redot-engine/redot/'), + ('https://hosted.weblate.org/projects/godot-engine/', 'https://hosted.weblate.org/projects/redot-engine/'), + ('https://hosted.weblate.org/browse/godot-engine', 'https://hosted.weblate.org/browse/redot-engine'), + ('https://repo1.maven.org/maven2/org/godotengine/godot/', 'https://repo1.maven.org/maven2/org/redot-engine/redot/'), + # Non existing internal urls + ('https://chat.godotengine.org/', 'https://chat.redotengine.org/'), + ('https://editor.godotengine.org', 'https://editor.redotengine.org'), + ('https://forum.godotengine.org/', 'https://forum.redotengine.org/'), + ('https://fund.godotengine.org', 'https://fund.redotengine.org'), + # The following mappings probably require changes to the core engine + ('GodotEngine.epub', 'RedotEngine.epub'), + ('godotengine.org/license', 'redotengine.org/license'), + ('AsGodotDictionary', 'AsRedotDictionary'), + ('GODOT_', 'REDOT_'), + ('-godot-', '-redot-'), + ('project.godot', 'project.redot'), + ('Godot.Collections', 'Redot.Collections'), + ('"Godot"', '"Redot"'), + ('.godot/', '.redot/'), + ('.godot.', '.redot.'), + ('APPDATA%\\Godot\\', 'APPDATA%\\Redot\\'), + ('AppData%\\Godot\\', 'AppData%\\Redot\\'), + ('Caches/Godot/', 'Caches/Redot/'), + ('cache/godot/', 'cache/redot/'), + ('Support/Godot/', 'Support/Redot/'), + ('config/godot/', 'config/redot/'), + ('share/godot/', 'share/redot/'), + (' godot_', ' redot_'), + ('org.godotengine.Godot', 'org.redotengine.Redot'), + ('godot-ios-plugins', 'redot-ios-plugins'), + ('godot-syntax-themes', 'redot-syntax-themes'), + ('godot_skin', 'redot_skin'), + ('godot_scene_node', 'redot_scene_node'), + ('``godotengine/godot', '``redot-engine/redot'), + ('>/Godot/', '>/Redot/'), + ('``.godot``', '``.redot``'), + ('``godot``', '``redot``'), + ('/godot.', '/redot.'), + ('GodotPhysics', 'RedotPhysics'), + ('AsGodotObject', 'AsRedotObject'), + ('non-Godot', 'non-Redot'), + ('Godot-', 'Redot-'), + ('libgodot', 'libredot'), + ('godot.linuxbsd', 'redot.linuxbsd'), + ('Godot.app', 'Redot.app'), + ('MacOS/Godot', 'MacOS/Redot'), + ('C:\\godot', 'C:\\redot'), + ('GodotSharp', 'RedotSharp'), + ('godot.gdkey', 'redot.gdkey'), + ('godot-nir', 'redot-nir'), + ('godot-angle', 'redot-angle'), + ('godot-binary', 'redot-binary'), + ('``Godot', '``Redot'), + ('godot/modules', 'redot/modules'), + ('godot_binary', 'redot_binary'), + ('godotengine.org', 'redotengine.org'), + ('godot-source', 'redot-source'), + ('godot/bin', 'redot/bin'), + ('gdb godot', 'gdb redot'), + ('GODOT', 'REDOT'), + ('USERNAME/godot', 'USERNAME/redot'), + ('godot-xr', 'redot-xr'), + ('godotisawesome', 'redotisawesome'), + ('godot-cpp', 'redot-cpp'), + ('GodotCPP', 'RedotCPP'), + ('namespace godot', 'namespace redot'), + ('godot_cpp', 'redot_cpp'), + ('GodotObject', 'RedotObject'), + ('GodotBot', 'RedotBot'), + ('GodotPlugin', 'RedotPlugin'), + ('org.godotengine', 'org.redotengine'), + ('/godot>', '/redot>'), + ('repos/godotengine/godot', 'repos/redot-engine/redot'), + ('godot demo', 'redot demo'), + ('godotsharp', 'redotsharp'), +] + +# Mappings that should work on first migration +mappings = [ + # Table breakers + ('| ``"Please include this when reporting the bug on: https://github.com/godotengine/godot/issues"`` |', '| ``"Please include this when reporting the bug on: https://github.com/redot-engine/godot/issues"``|'), + ('https://github.com/godotengine/godot/pull/40364>`_ for more. |', 'https://github.com/redot-engine/redot/pull/40364>`_ for more. |'), + # Almost existing urls + ('https://docs.godotengine.org', 'https://docs.redotengine.org'), + ('https://godotengine.org', 'https://redotengine.org'), + # Existing urls + ('https://nightly.link/godotengine/godot-docs/workflows/build_offline_docs/master/godot', 'https://nightly.link/redot-engine/redot-docs/workflows/build_offline_docs/master/redot'), + ('https://github.com/godotengine/godot-docs/issues', 'https://github.com/redot-engine/redot-docs/issues'), + ('https://github.com/godotengine/godot/blob/master', 'https://github.com/redot-engine/redot/blob/master'), + ('https://raw.githubusercontent.com/godotengine/godot/master', 'https://raw.githubusercontent.com/redot-engine/redot/master'), + ('https://github.com/godotengine/godot-demo-projects', 'https://github.com/redot-engine/redot-demo-projects'), + ('https://discord.gg/bdcfAYM4W9', 'https://discord.gg/redot'), + ('https://github.com/godotengine/godot', 'https://github.com/redot-engine/redot'), + ('https://github.com/godotengine/godot-proposals', 'https://github.com/redot-engine/redot-proposals'), + ('https://raw.githubusercontent.com/godotengine/godot-docs', 'https://raw.githubusercontent.com/redot-engine/redot-docs'), + ('https://github.com/godotengine/', 'https://github.com/redot-engine/'), + # Generic replacements + ('GODOT_COPYRIGHT.txt', 'REDOT_COPYRIGHT.txt'), + ('godot-docs', 'redot-docs'), + ('GODOT ENGINE', 'REDOT ENGINE'), + ('/bin/godot', '/bin/redot'), + ('/Applications/Godot.app', '/Applications/Redot.app'), + ('highlight=Godot', 'highlight=Redot'), + ('/godot_', '/redot_'), + ('/godot-', '/redot-'), + ('_godot_', '_redot_'), + ('``godot``', '``redot``'), + ('Godot ', 'Redot '), + (' Godot', ' Redot'), + (' Godot.', ' Redot.'), + (' Godot?', ' Redot?'), + ('Godot\'', 'Redot\''), + ('Godot,', 'Redot,'), + ('Godot:', 'Redot:'), + (' godot ', ' redot '), + ('\nGodot.', '\nRedot.'), + ('_godot\n', '_redot\n'), + ('godot.gif', 'redot.gif'), + ('godot.jpg', 'redot.jpg'), + ('godot.png', 'redot.png'), + ('"godot_', '"redot_'), + ('"godotengine"', '"redotengine"'), + ('GodotEngine', 'RedotEngine'), + ('godot-giscus', 'redot-giscus'), + ('"godotengine/', '"redotengine/'), + ('godot_is_latest', 'redot_is_latest'), + ('godot-edit-guideline', 'redot-edit-guideline'), + ('_godot_', '_redot_'), + ('to_godot', 'to_redot'), + ('godot.html', 'redot.html'), + ('by-godot', 'by-redot'), +] + +filename_mappings = [ + ('godot', 'redot'), +] + +static_dirs = [ + '**/img', + '**/files', + '_extensions', + '_static', + '_styleguides', + '_templates', + '_tools', +] + +alphanumeric = [ + 'py', + 'md', + 'css', + 'txt', + 'css', + 'js', + 'html', + 'csv', + 'rst', +] + +# force stdout encoding so it won't fail on print statements +if (sys.stdout.encoding != encoding): + sys.stdout = codecs.getwriter(encoding)(sys.stdout.buffer, 'strict') + sys.stdout.encoding = encoding + +def is_target(filename): + return any(filename.lower().endswith(m) for m in filename_masks) + +def generateOutputName(root, fileName, outputDirectory): + on = os.path.join('.', outputDirectory, root, fileName) + on = convertContent(on, filename_mappings) + ensureDirExists(on) + return on + +def convertContent(content, mappings): + for mapping in mappings: + search, replace = mapping + if (search != ''): + content = content.replace(search, replace) + return content + +def ensureDirExists(outputName): + dirname = os.path.dirname(outputName) + try: + os.makedirs(dirname) + except FileExistsError: + pass + +def copyFile(root, filename, outputDirectory): + inputName = os.path.join(root, filename) + outputName = generateOutputName(root, inputName.replace('.\\', '').replace('./', ''), outputDirectory) + + print(f'Copying "{inputName}" to "{outputName}"') + shutil.copyfile(inputName, outputName) + +def convertFile(root, filename, outputDirectory, includeUnimplemented): + inputName = os.path.join(root, filename) + outputName = generateOutputName(root, filename, outputDirectory) + + print(f'Converting "{inputName}" to "{outputName}"') + with open(inputName, mode = 'r', encoding = encoding) as input: + data = input.read() + + if (includeUnimplemented): + data = convertContent(data, mappings_unimplemented) + data = convertContent(data, mappings) + ensureDirExists(outputName) + with open(outputName, mode = 'w', encoding = encoding) as output: + output.write(data) + +def copyGlobalDir(inputDirectory, inputMask, outputDirectory): + for root, dirs, files in os.walk(inputDirectory): + if (inputMask in root and outputDirectory not in root): + for f in files: + inputName = os.path.join(root, f) + outputName = generateOutputName(root, f, outputDirectory) + ensureDirExists(outputName) + print(f"Copying {inputName} to {outputName}") + copyfile(inputName, outputName) + +def convertStaticDir(inputDirectory, outputDirectory): + for root, dirs, files in os.walk(inputDirectory): + if (outputDirectory not in root and '__' not in root): + for f in files: + if (f.split('.')[1] in alphanumeric): + convertFile(root, f, outputDirectory, True) + else: + copyFile(root, f, outputDirectory) + +def migrate(inputDirectory, outputDirectory, includeUnimplemented): + outputsig = os.path.join('.', outputDirectory) + for root, dirs, files in os.walk(inputDirectory): + # ignore output path + if (root.startswith(outputsig)): + continue + + items = filter(is_target, files) + for item in items: + convertFile(root, item, outputDirectory, includeUnimplemented) + +inputDir = defaultInputDirectory +outputDir = defaultOutputDirectory +includeUnimplemented = defaultIncludeUnimplemented +if (len(sys.argv) > 1): + inputDir = sys.argv[1] +if (len(sys.argv) > 2): + outputDir = sys.argv[2] +if (len(sys.argv) > 3): + includeUnimplemented = sys.argv[3] + +print(f"Simple rst migrator. Uses str.replace to map from Godot to Redot.") +print(f"Usage: py migrate.py [inputDir] [outputDir] [includeUnimplemented], example: py migrate.py . _mymigration True") +print(f"Author: @Craptain on X") +print(f"Input directory: {inputDir}, output directory: {outputDir}, include unimplemented: {includeUnimplemented}") + +migrate(inputDir, outputDir, includeUnimplemented) + +print("Copying config files...") +convertFile(inputDir, 'conf.py', outputDir, includeUnimplemented) +convertFile(inputDir, 'robots.txt', outputDir, includeUnimplemented) +print("Copying static directories...") + +for dir in static_dirs: + if ('**' in dir): + print(f"Copying dirs with mask {dir}") + copyGlobalDir(inputDir, dir.split('/')[1], outputDir) + else: + print(f"Converting dir {dir}") + convertStaticDir(dir, outputDir) +print("Done")