diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index a92092409d1..afc02c37064 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -4,7 +4,8 @@ on: push: branches: - master - - optimize-build-simplify + - 26.1 + - feature/versioning-setup pull_request: branches: - master @@ -15,12 +16,32 @@ concurrency: jobs: build: + name: Build docs (26.1) runs-on: ubuntu-latest timeout-minutes: 120 steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Save build script and checkout master with 26.1 config + run: | + # Save the updated build.sh from feature branch + cp build.sh /tmp/build-with-versions.sh + chmod +x /tmp/build-with-versions.sh + # Add upstream remote + git remote add upstream https://github.com/Redot-Engine/redot-docs.git 2>/dev/null || true + # Fetch 26.1 branch to get its config + git fetch origin 26.1 + # Save 26.1 conf.py + git show origin/26.1:conf.py > /tmp/conf-26.1.py + # Now checkout master from upstream (has all latest docs including MCP) + git fetch upstream master + git checkout upstream/master + # Copy 26.1 conf.py to override master version + cp /tmp/conf-26.1.py conf.py - name: Set up Python uses: actions/setup-python@v5 @@ -38,54 +59,59 @@ jobs: id: cache-migrated with: path: _migrated - key: migrated-${{ hashFiles('**/*.rst', 'conf.py', 'migrate.py') }} + key: migrated-26.1-${{ hashFiles('**/*.rst', 'conf.py', 'migrate.py') }} - name: Cache Sphinx doctrees uses: actions/cache@v4 with: path: _sphinx/.doctrees - key: doctrees-${{ github.ref }}-${{ github.run_id }} + key: doctrees-26.1-${{ github.run_id }} restore-keys: | - doctrees-${{ github.ref }}- + doctrees-26.1- doctrees- - - name: Build documentation + - name: Build documentation for 26.1 run: | + # Use the saved build.sh which supports BUILD_DIR export FULL_RUN=1 - bash build.sh + export BUILD_DIR="26.1" + /tmp/build-with-versions.sh env: FULL_RUN: 1 + BUILD_DIR: "26.1" + + - name: Copy build to root structure + run: | + mkdir -p ./dist + cp -r output/html/en/26.1/* ./dist/ - name: Upload build artifact uses: actions/upload-artifact@v4 with: - name: redot-docs-build - path: output/ + name: redot-docs-26.1 + path: ./dist retention-days: 1 deploy: needs: build runs-on: ubuntu-latest - if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/optimize-build-simplify') + if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/26.1' || github.ref == 'refs/heads/feature/versioning-setup') steps: - name: Download build artifact uses: actions/download-artifact@v4 with: - name: redot-docs-build - path: output/ + name: redot-docs-26.1 + path: . - - name: Determine deploy directory + - name: List built files run: | - if [ "${{ github.ref_name }}" = "master" ]; then - echo "DEPLOY_DIR=output/html/en/latest" >> $GITHUB_ENV - else - echo "DEPLOY_DIR=output/html/en/${{ github.ref_name }}" >> $GITHUB_ENV - fi + echo "Built files:" + ls -la - name: Deploy to Cloudflare Pages uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy ${{ env.DEPLOY_DIR }} --project-name=redot-docs --branch=${{ github.ref_name }} + command: pages deploy . --project-name=redot-docs --branch=main diff --git a/_templates/versions.html b/_templates/versions.html index 7adccecf2a0..727ded92297 100644 --- a/_templates/versions.html +++ b/_templates/versions.html @@ -1,7 +1,12 @@ {# Add rst-badge after rst-versions for small badge style. #} -{% set display_version = version -%} +{% set display_version = godot_version -%} {% set listed_languages = ({"en":"#", "de":"#", "es":"#", "fr":"#"}).items() -%} -{% set listed_versions = ({"stable":"#", "latest":"#"}).items() -%} +{% if godot_versions is defined %} + {% set listed_versions = godot_versions -%} +{% else %} + {# Fallback for branches that don't define godot_versions #} + {% set listed_versions = [("4.3", "/4.3/"), ("4.4", "/4.4/"), ("dev", "/dev/")] -%} +{% endif %} {% if READTHEDOCS and current_version %} {% set display_version = current_version -%} diff --git a/build.sh b/build.sh index 69cfe83574f..2a25f7cc8b8 100755 --- a/build.sh +++ b/build.sh @@ -11,6 +11,7 @@ # FULL_RUN - Set to enable full documentation build # CF_PAGES - Automatically set by Cloudflare Pages # CF_PAGES_BRANCH - Branch being built (set by Cloudflare Pages) +# BUILD_DIR - Override the output directory name (e.g., "4.3", "4.4", "dev") set -e # Exit on error @@ -28,9 +29,19 @@ fi # Map branches to output directories # master -> latest, everything else -> branch name -buildDir="$gitBranch" -if [ "$gitBranch" = "master" ]; then - buildDir="latest" +# Allow BUILD_DIR override for versioned builds +if [ -n "$BUILD_DIR" ]; then + buildDir="$BUILD_DIR" +elif [ -n "$CF_PAGES" ]; then + buildDir="${CF_PAGES_BRANCH:-master}" + if [ "$buildDir" = "master" ]; then + buildDir="latest" + fi +else + buildDir="$gitBranch" + if [ "$buildDir" = "master" ]; then + buildDir="latest" + fi fi echo "========================================" @@ -59,7 +70,15 @@ if [ -n "$FULL_RUN" ]; then echo "[2/4] Migrating Godot to Redot (with --exclude-classes)..." rm -rf "$migrateDir" mkdir -p "$migrateDir" - python migrate.py --exclude-classes "$inputDir" "$migrateDir" + # Check if we're building from upstream branch (doesn't support --exclude-classes) + # by checking if BUILD_DIR is set (our feature branch sets it, upstream builds won't) + if [ -n "$BUILD_DIR" ] && [ "$gitBranch" != "HEAD" ]; then + # Our branch with new migrate.py - use --exclude-classes + python migrate.py --exclude-classes "$inputDir" "$migrateDir" + else + # Upstream branch - old migrate.py, don't use --exclude-classes + python migrate.py "$inputDir" "$migrateDir" + fi fi echo "" diff --git a/conf.py b/conf.py index 403d5b5ea4d..67a51c8204e 100644 --- a/conf.py +++ b/conf.py @@ -59,13 +59,11 @@ # This makes it easier to test the custom 404 page by loading `/404.html` # on a local web server. if not on_rtd: - notfound_urls_prefix = '' + notfound_urls_prefix = "" # Specify the site name for the Open Graph extension. ogp_site_name = "Godot Engine documentation" -ogp_social_cards = { - "enable": False -} +ogp_social_cards = {"enable": False} if not os.getenv("SPHINX_NO_GDSCRIPT"): extensions.append("gdscript") @@ -84,9 +82,7 @@ # General information about the project project = "Godot Engine" -copyright = ( - "2024-present by the Redot community, modified from an original work by Juan Linietsky, Ariel Manzur and the G-dot community (CC BY 3.0)" -) +copyright = "2024-present by the Redot community, modified from an original work by Juan Linietsky, Ariel Manzur and the G-dot community (CC BY 3.0)" author = "the Redot community, modified from an original work by Juan Linietsky, Ariel Manzur and the G-dot community" # Version info for the project, acts as replacement for |version| and |release| @@ -177,7 +173,7 @@ "flyout_display": "attached", } -html_title = supported_languages[language] % ( "(" + version + ")" ) +html_title = supported_languages[language] % ("(" + version + ")") # Edit on GitHub options: https://docs.readthedocs.io/en/latest/guides/edit-source-links-sphinx.html html_context = { @@ -187,7 +183,7 @@ "github_version": "master", # Version "conf_py_path": "/", # Path in the checkout to the docs root "godot_docs_title": supported_languages[language], - "godot_docs_basepath": "https://docs.godotengine.org/", + "godot_docs_basepath": "https://docs.redotengine.org/", "godot_docs_suffix": ".html", # Distinguish local development website from production website. # This prevents people from looking for changes on the production website after making local changes :) @@ -195,11 +191,17 @@ # Set this to `True` when in the `latest` branch to clearly indicate to the reader # that they are not reading the `stable` documentation. "godot_is_latest": True, - "godot_version": "4.4", + "godot_version": "dev", # Enables a banner that displays the up-to-date status of each article. "godot_show_article_status": True, # Display user-contributed notes at the bottom of pages that don't have `:allow_comments: False` at the top. "godot_show_article_comments": on_rtd and not is_i18n, + # Available documentation versions for the version selector + "godot_versions": [ + ("4.3", "/4.3/"), + ("4.4", "/4.4/"), + ("dev", "/dev/"), + ], } html_logo = "img/docs_logo.svg" @@ -289,6 +291,7 @@ def godot_get_image_filename_for_language(filename, env): path = os.path.abspath(os.path.join("../images/", os.path.relpath(path, cwd))) return path + sphinx.util.i18n.get_image_filename_for_language = godot_get_image_filename_for_language # Similar story for the localized class reference, it's out of tree and there doesn't @@ -305,4 +308,4 @@ def godot_get_image_filename_for_language(filename, env): os.symlink("../classes/" + language, "classes") # Needed so the table of contents is created for EPUB -epub_tocscope = 'includehidden' +epub_tocscope = "includehidden"