diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2023-12-17 02:28:31 -0700 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2023-12-17 02:28:31 -0700 |
commit | b9c9b05ab48828575ae2574aa46644c612d4971d (patch) | |
tree | a5f20cf899c9ec63cd51241506ef6f42f458a74f /generate_docs.sh | |
parent | 695d64d350ea889446445c1eeccfa6b54f3ecf4d (diff) |
generate docs
Diffstat (limited to 'generate_docs.sh')
-rwxr-xr-x | generate_docs.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/generate_docs.sh b/generate_docs.sh new file mode 100755 index 0000000..d301d04 --- /dev/null +++ b/generate_docs.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +mkdir -p docs/ + +for target in "$@" +do + echo "Generating docs for $target" + swift package --allow-writing-to-directory "$target-docs" generate-documentation --disable-indexing --transform-for-static-hosting --hosting-base-path swift-gopher --output-path "$target-docs" --target "$target" + cp -r $target-docs/* docs/ + modified_target=$(echo $target | tr '-' '_' | tr '[:upper:]' '[:lower:]') + cp -r $target-docs/index/index.json "docs/index/$modified_target.json" +done + +echo "<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=/swift-gopher/documentation/\" /></head><body><ol>" > docs/index.html + +for target in "$@" +do + cp -R $target-docs/data/documentation/* docs/data/documentation/ + cp -R $target-docs/documentation/* docs/documentation/ + rm -r "$target-docs" + modified_target=$(echo $target | tr '-' '_' | tr '[:upper:]' '[:lower:]') + echo "<li><a href=\"/swift-gopher/documentation/$modified_target/\">$target</a></li>" >> docs/index.html +done + +echo "</ol></body></html>" >> docs/index.html + +custom_javascript="window.location.pathname.split('documentation/')[1].split('/')[0]" +file_to_modify=$(ls docs/js/documentation-topic\~topic\~tutorials-overview.*.js) + +sed -i '' 's/"index.json"/window.location.pathname.split("documentation\/")[1].split("\/")[0]+".json"/g' $file_to_modify +echo "Modified $file_to_modify" |