From db379ca07d793073bceb304befe2c844e62f53a0 Mon Sep 17 00:00:00 2001 From: Joshua Batty Date: Thu, 11 Sep 2025 12:28:31 +1000 Subject: [PATCH 1/2] Merge module maps and all docs links without overwriting existing entries, ensuring deduplication of links. --- forc-plugins/forc-doc/src/render/mod.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/forc-plugins/forc-doc/src/render/mod.rs b/forc-plugins/forc-doc/src/render/mod.rs index fec8c7db838..14b11cf187c 100644 --- a/forc-plugins/forc-doc/src/render/mod.rs +++ b/forc-plugins/forc-doc/src/render/mod.rs @@ -120,11 +120,29 @@ impl RenderedDocumentation { for (rendered_doc, local_module_map, local_all_docs) in rendered_results? { rendered_docs.0.push(rendered_doc); + // Merge module maps without overwriting existing categories; append and dedup links. for (key, value) in local_module_map { - module_map.entry(key).or_default().extend(value); + let entry = module_map.entry(key).or_default(); + for (block, mut links) in value { + let list = entry.entry(block).or_default(); + // Append new links while avoiding duplicates. + for link in links.drain(..) { + if !list.contains(&link) { + list.push(link); + } + } + } } - all_docs.links.extend(local_all_docs.links); + // Merge "all docs" links similarly, preserving existing items. + for (block, mut links) in local_all_docs.links { + let list = all_docs.links.entry(block).or_default(); + for link in links.drain(..) { + if !list.contains(&link) { + list.push(link); + } + } + } } // ProjectIndex From 4bd84bdd4be2f94303aa27b5f2a0d4c4f642bd4a Mon Sep 17 00:00:00 2001 From: Joshua Batty Date: Thu, 11 Sep 2025 12:41:31 +1000 Subject: [PATCH 2/2] Reverts workflow changes that moved static.files and search.js into std/ and rewrote HTML paths --- .github/workflows/gh-pages.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 96f0c442641..bd4ffc8f6d2 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -55,20 +55,12 @@ jobs: - name: Build Sway std library run: forc doc --path ./sway-lib-std - - name: Move assets into std directory - run: | - mv ./sway-lib-std/out/doc/static.files ./sway-lib-std/out/doc/std/ - mv ./sway-lib-std/out/doc/search.js ./sway-lib-std/out/doc/std/ - # Fix relative paths in HTML files - find ./sway-lib-std/out/doc/std -name "*.html" -type f -exec sed -i 's|../static\.files/|static.files/|g' {} \; - find ./sway-lib-std/out/doc/std -name "*.html" -type f -exec sed -i 's|../search\.js|search.js|g' {} \; - - name: Deploy master std uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./sway-lib-std/out/doc/std - destination_dir: master/std + publish_dir: ./sway-lib-std/out/doc + destination_dir: master if: github.ref == 'refs/heads/master' - name: Deploy master book @@ -133,7 +125,7 @@ jobs: uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./sway-lib-std/out/doc + publish_dir: ./sway-lib-std/out/doc/std destination_dir: ${{ steps.branch_name.outputs.BRANCH_NAME }}/std if: startsWith(github.ref, 'refs/tags')