From 222bd031978136350fa5fd6c3e0d7d812ffb298f Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Fri, 5 Feb 2021 15:50:49 -0500 Subject: [PATCH] update scripts to maintain multiple versions of the documentation --- etc/docs-main.md | 4 +++- etc/generate-docs.sh | 35 ++++++++++++++--------------------- etc/release.sh | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/etc/docs-main.md b/etc/docs-main.md index 7f1564f0..c769bc8a 100644 --- a/etc/docs-main.md +++ b/etc/docs-main.md @@ -4,4 +4,6 @@ This is the documentation for the official MongoDB Swift BSON library, [swift-bs You can view the README for this project, including installation instructions, [here](https://github.com/mongodb/swift-bson/blob/master/README.md). -The documentation for the official MongoDB Swift driver, which depends on this BSON library, can be found [here](https://mongodb.github.io/mongo-swift-driver/MongoSwift/index.html). +Documentation for other versions of `swift-bson` can be found [here](https://mongodb.github.io/swift-bson/docs). + +The documentation for the official MongoDB Swift driver, which depends on `swift-bson`, can be found [here](https://mongodb.github.io/mongo-swift-driver/MongoSwift/index.html). diff --git a/etc/generate-docs.sh b/etc/generate-docs.sh index e4ba2c10..926a2a7c 100755 --- a/etc/generate-docs.sh +++ b/etc/generate-docs.sh @@ -9,32 +9,25 @@ if ! command -v jazzy > /dev/null; then gem install jazzy || { echo "ERROR: Failed to locate or install jazzy; please install yourself with 'gem install jazzy' (you may need to use sudo)"; exit 1; } fi +if ! command -v sourcekitten > /dev/null; then + echo "ERROR: Failed to locate SourceKitten; please install yourself and/or add to your \$PATH"; exit 1 +fi + version=${1} # Ensure version is non-empty [ ! -z "${version}" ] || { echo "ERROR: Missing version string"; exit 1; } -jazzy \ ---github-file-prefix https://github.com/mongodb/swift-bson/tree/v${version} \ ---module-version "${version}" \ ---output "docs-temp/SwiftBSON" \ ---config .jazzy.yml - -# switch to docs branch to commit and push -git stash -git checkout gh-pages - -rm -rf docs/* -cp -r docs-temp/* docs/ -rm -rf docs-temp - -git add docs/ +jazzy_args=(--clean + --github-file-prefix https://github.com/mongodb/swift-bson/tree/v${version} + --module-version "${version}") -echo '' > docs/index.html -git add docs/index.html +sourcekitten doc --spm --module-name SwiftBSON > swift-bson-docs.json +args=("${jazzy_args[@]}" --output "docs-temp/SwiftBSON" --module "SwiftBSON" --config ".jazzy.yml" + --sourcekitten-sourcefile swift-bson-docs.json + --root-url "https://mongodb.github.io/swift-bson/docs/SwiftBSON/") +jazzy "${args[@]}" -git commit -m "${version} docs" -git push +echo '' > docs-temp/index.html -# go back to wherever we started -git checkout - +rm swift-bson-docs.json diff --git a/etc/release.sh b/etc/release.sh index 063bbf59..917d6971 100755 --- a/etc/release.sh +++ b/etc/release.sh @@ -15,6 +15,23 @@ version=${1} # regenerate documentation with new version string ./etc/generate-docs.sh ${version} +# switch to docs branch to commit and push +git checkout gh-pages + +rm -r docs/current +cp -r docs-temp docs/current +mv docs-temp docs/${version} + +# build up documentation index +python3 ./_scripts/update-index.py + +git add docs/ +git commit -m "${version} docs" +git push + +# go back to wherever we started +git checkout - + # tag release and push tag git tag "v${version}" git push --tags