From e9b7fa7a862b8354a3f22c2998d3c9b7e4b7eac1 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 4 Sep 2023 16:34:10 +1200 Subject: [PATCH 1/5] inject simple analytics --- .gitlab/pipeline/build.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.gitlab/pipeline/build.yml b/.gitlab/pipeline/build.yml index 636f7e47afad8..d8ef50225507f 100644 --- a/.gitlab/pipeline/build.yml +++ b/.gitlab/pipeline/build.yml @@ -117,6 +117,25 @@ build-rustdoc: - time cargo doc --workspace --no-deps - rm -f ./target/doc/.lock - mv ./target/doc ./crate-docs + # Inject Simple Analytics (https://www.simpleanalytics.com/) privacy preserving tracker into + # all .html files + - | + inject_simple_analytics() { + local path="$1" + local script_content="" + + # Define a function that injects our script into the head of an html file. + process_file() { + local file="$1" + echo "Adding Simple Analytics script to $file" + sed -i "s||$script_content|" "$file" + } + export -f process_file + + # Locate all .html files under the documentation root and use xargs to process in parallel. + find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {} + } + inject_simple_analytics "./crate-docs" # FIXME: remove me after CI image gets nonroot - chown -R nonroot:nonroot ./crate-docs - echo "" > ./crate-docs/index.html From d66176639e99b7e38d7a0749ba4f5cbbfc1ea4e5 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 4 Sep 2023 16:39:41 +1200 Subject: [PATCH 2/5] comments --- .gitlab/pipeline/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/pipeline/build.yml b/.gitlab/pipeline/build.yml index d8ef50225507f..31bdf616a987b 100644 --- a/.gitlab/pipeline/build.yml +++ b/.gitlab/pipeline/build.yml @@ -124,7 +124,7 @@ build-rustdoc: local path="$1" local script_content="" - # Define a function that injects our script into the head of an html file. + # Function that inject script into the head of an html file using sed. process_file() { local file="$1" echo "Adding Simple Analytics script to $file" @@ -132,7 +132,7 @@ build-rustdoc: } export -f process_file - # Locate all .html files under the documentation root and use xargs to process in parallel. + # Locate all .html files under the documentation root and use xargs to modify them in parallel. find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {} } inject_simple_analytics "./crate-docs" From 3fb3b91eb87dcb1f37b237defc1717084df233cc Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 4 Sep 2023 16:40:26 +1200 Subject: [PATCH 3/5] fix chown --- .gitlab/pipeline/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/pipeline/build.yml b/.gitlab/pipeline/build.yml index 31bdf616a987b..e434deb6b9f62 100644 --- a/.gitlab/pipeline/build.yml +++ b/.gitlab/pipeline/build.yml @@ -117,6 +117,8 @@ build-rustdoc: - time cargo doc --workspace --no-deps - rm -f ./target/doc/.lock - mv ./target/doc ./crate-docs + # FIXME: remove me after CI image gets nonroot + - chown -R nonroot:nonroot ./crate-docs # Inject Simple Analytics (https://www.simpleanalytics.com/) privacy preserving tracker into # all .html files - | @@ -136,8 +138,6 @@ build-rustdoc: find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {} } inject_simple_analytics "./crate-docs" - # FIXME: remove me after CI image gets nonroot - - chown -R nonroot:nonroot ./crate-docs - echo "" > ./crate-docs/index.html build-implementers-guide: From 64353349caa90cd4739edd17976b011e7181c694 Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 4 Sep 2023 16:53:36 +1200 Subject: [PATCH 4/5] comments --- .gitlab/pipeline/build.yml | 2 +- substrate/.maintain/rustdocs-release.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab/pipeline/build.yml b/.gitlab/pipeline/build.yml index e434deb6b9f62..1724a5704959c 100644 --- a/.gitlab/pipeline/build.yml +++ b/.gitlab/pipeline/build.yml @@ -134,7 +134,7 @@ build-rustdoc: } export -f process_file - # Locate all .html files under the documentation root and use xargs to modify them in parallel. + # Modify .html files in parallel using xargs, otherwise it can take a long time. find "$path" -name '*.html' | xargs -I {} -P "$(nproc)" bash -c 'process_file "$@"' _ {} } inject_simple_analytics "./crate-docs" diff --git a/substrate/.maintain/rustdocs-release.sh b/substrate/.maintain/rustdocs-release.sh index 2a1e141e63ad2..091f9289e4e34 100755 --- a/substrate/.maintain/rustdocs-release.sh +++ b/substrate/.maintain/rustdocs-release.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # set -x -# This script manages the deployment of Substrate rustdocs to https://paritytech.github.io/substrate/. +# This script used to manage the deployment of Substrate rustdocs to https://paritytech.github.io/substrate/. +# It is no longer used anywhere, and only here for historical/demonstration purposes. # - With `deploy` sub-command, it will checkout the passed-in branch/tag ref, build the rustdocs # locally (this takes some time), update the `index.html` index page, and push it to remote # `gh-pages` branch. So users running this command need to have write access to the remote From d96856bc950fe33e81657991a5220fbf0615e42d Mon Sep 17 00:00:00 2001 From: Liam Aharon Date: Mon, 4 Sep 2023 17:00:24 +1200 Subject: [PATCH 5/5] doc features --- .gitlab/pipeline/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/pipeline/build.yml b/.gitlab/pipeline/build.yml index 1724a5704959c..20fed5df3dfd9 100644 --- a/.gitlab/pipeline/build.yml +++ b/.gitlab/pipeline/build.yml @@ -114,7 +114,7 @@ build-rustdoc: script: # FIXME: it fails with `RUSTDOCFLAGS="-Dwarnings"` and `--all-features` # FIXME: return to stable when https://github.com/rust-lang/rust/issues/96937 gets into stable - - time cargo doc --workspace --no-deps + - time cargo doc --features try-runtime,experimental --workspace --no-deps - rm -f ./target/doc/.lock - mv ./target/doc ./crate-docs # FIXME: remove me after CI image gets nonroot