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') 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