From e72fb62303fa164ea8b2bc081e98e41e596f0f47 Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Fri, 21 Jun 2024 18:16:18 +0530 Subject: [PATCH 1/7] added script and html for Documenter Navigation --- assets/scripts/insert_navbar.sh | 29 ++ assets/scripts/navbar.html | 461 ++++++++++++++++++++++++++++++++ 2 files changed, 490 insertions(+) create mode 100644 assets/scripts/insert_navbar.sh create mode 100644 assets/scripts/navbar.html diff --git a/assets/scripts/insert_navbar.sh b/assets/scripts/insert_navbar.sh new file mode 100644 index 000000000..1665d3972 --- /dev/null +++ b/assets/scripts/insert_navbar.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# URL of the navigation bar HTML file +NAVBAR_URL="https://raw.githubusercontent.com/shravanngoswamii/experimental/main/test/navbar.html" + +# Directory containing HTML files (passed as the first argument to the script) +HTML_DIR=$1 + +# Download the navigation bar HTML content +NAVBAR_HTML=$(curl -s $NAVBAR_URL) + +# Check if the download was successful +if [ -z "$NAVBAR_HTML" ]; then + echo "Failed to download navbar HTML" + exit 1 +fi + +# Process each HTML file in the directory +for file in $(find $HTML_DIR -name "*.html"); do + # Read the contents of the HTML file + file_contents=$(cat "$file") + + # Insert the navbar HTML after the tag + updated_contents="${file_contents/$''/$'\n'$NAVBAR_HTML}" + + # Write the updated contents back to the file + echo "$updated_contents" > "$file" + echo "Updated $file" +done \ No newline at end of file diff --git a/assets/scripts/navbar.html b/assets/scripts/navbar.html new file mode 100644 index 000000000..fe33d85cf --- /dev/null +++ b/assets/scripts/navbar.html @@ -0,0 +1,461 @@ + + + From 7d7f89b0d596b947506a350457dd890ecca41c8a Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Fri, 21 Jun 2024 18:42:47 +0530 Subject: [PATCH 2/7] fixed NAVBAR URL --- assets/scripts/insert_navbar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/insert_navbar.sh b/assets/scripts/insert_navbar.sh index 1665d3972..8e3a9f73c 100644 --- a/assets/scripts/insert_navbar.sh +++ b/assets/scripts/insert_navbar.sh @@ -1,7 +1,7 @@ #!/bin/bash # URL of the navigation bar HTML file -NAVBAR_URL="https://raw.githubusercontent.com/shravanngoswamii/experimental/main/test/navbar.html" +NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/navbar.html" # Directory containing HTML files (passed as the first argument to the script) HTML_DIR=$1 From d1da75528a82d424d4d65ba17234817fa708276b Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:09:21 +0100 Subject: [PATCH 3/7] Update assets/scripts/insert_navbar.sh --- assets/scripts/insert_navbar.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/scripts/insert_navbar.sh b/assets/scripts/insert_navbar.sh index 8e3a9f73c..50bc7a131 100644 --- a/assets/scripts/insert_navbar.sh +++ b/assets/scripts/insert_navbar.sh @@ -1,5 +1,10 @@ #!/bin/bash + +# This script inserts a top navigation bar (e.g., `navbar.html`) into Documenter.jl generated sites. +# The resulting output is similar to MultiDocumenter's navigation menu. The navigation menu is +# hard-coded at the moment, which could be improved in the future. + # URL of the navigation bar HTML file NAVBAR_URL="https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/navbar.html" From b087373aa0d35685e4a14a26df57b871a323c408 Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:14:42 +0100 Subject: [PATCH 4/7] Create README.md --- assets/scripts/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 assets/scripts/README.md diff --git a/assets/scripts/README.md b/assets/scripts/README.md new file mode 100644 index 000000000..1282532a9 --- /dev/null +++ b/assets/scripts/README.md @@ -0,0 +1,4 @@ +This `scripts` folder contains utilities for building Turing language satellite packages' documentation. + +- `insert_navbar.sh`: This function inserts a MultiDocumenter-style top navigation bar to `Documenter.jl` generated sites. +- `navbar.html`: the content of the top navigation bar inserted by `insert_navbar.sh`. From 8eacc92086bfd1ec9903b768ba557bae65ecd77d Mon Sep 17 00:00:00 2001 From: Shravan Goswami Date: Fri, 21 Jun 2024 19:49:17 +0530 Subject: [PATCH 5/7] removed extra line --- assets/scripts/insert_navbar.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/scripts/insert_navbar.sh b/assets/scripts/insert_navbar.sh index 50bc7a131..127574093 100644 --- a/assets/scripts/insert_navbar.sh +++ b/assets/scripts/insert_navbar.sh @@ -1,6 +1,5 @@ #!/bin/bash - # This script inserts a top navigation bar (e.g., `navbar.html`) into Documenter.jl generated sites. # The resulting output is similar to MultiDocumenter's navigation menu. The navigation menu is # hard-coded at the moment, which could be improved in the future. From 5d575458d6685ee262a8b4445edb2f056f00c9ed Mon Sep 17 00:00:00 2001 From: Shravan Goswami <123811742+shravanngoswamii@users.noreply.github.com> Date: Fri, 21 Jun 2024 19:50:00 +0530 Subject: [PATCH 6/7] Update assets/scripts/navbar.html Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com> --- assets/scripts/navbar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/scripts/navbar.html b/assets/scripts/navbar.html index fe33d85cf..7a9bb74cf 100644 --- a/assets/scripts/navbar.html +++ b/assets/scripts/navbar.html @@ -265,7 +265,7 @@
  • AbstractMCMC
  • - +
  • ThermodynamicIntegration
  • From 90db7d857c3cae3fe83265752b66aebb572a9eb6 Mon Sep 17 00:00:00 2001 From: Hong Ge <3279477+yebai@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:24:21 +0100 Subject: [PATCH 7/7] Update README.md --- assets/scripts/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/assets/scripts/README.md b/assets/scripts/README.md index 1282532a9..7bdf2798b 100644 --- a/assets/scripts/README.md +++ b/assets/scripts/README.md @@ -1,4 +1,15 @@ This `scripts` folder contains utilities for building Turing language satellite packages' documentation. - `insert_navbar.sh`: This function inserts a MultiDocumenter-style top navigation bar to `Documenter.jl` generated sites. -- `navbar.html`: the content of the top navigation bar inserted by `insert_navbar.sh`. +- `navbar.html`: the content of the top navigation bar inserted by `insert_navbar.sh`. + +## How to use + +Add the following line after `makedocs()` function in `docs/make.jl` of each package: + +```julia +# Insert navbar in each html file +run(`sh -c "curl -s https://raw.githubusercontent.com/TuringLang/turinglang.github.io/main/assets/scripts/insert_navbar.sh | bash -s docs/build"`) +``` + +See https://github.com/TuringLang/AbstractMCMC.jl/pull/141 for an example.