Skip to content

Commit 6aeef24

Browse files
authored
SWIFT-734 Update scripts to maintain multiple versions of the documentation (#58)
1 parent 536781f commit 6aeef24

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

etc/docs-main.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ This is the documentation for the official MongoDB Swift BSON library, [swift-bs
44

55
You can view the README for this project, including installation instructions, [here](https://github.com/mongodb/swift-bson/blob/master/README.md).
66

7-
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).
7+
Documentation for other versions of `swift-bson` can be found [here](https://mongodb.github.io/swift-bson/docs).
8+
9+
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).

etc/generate-docs.sh

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,25 @@ if ! command -v jazzy > /dev/null; then
99
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; }
1010
fi
1111

12+
if ! command -v sourcekitten > /dev/null; then
13+
echo "ERROR: Failed to locate SourceKitten; please install yourself and/or add to your \$PATH"; exit 1
14+
fi
15+
1216
version=${1}
1317

1418
# Ensure version is non-empty
1519
[ ! -z "${version}" ] || { echo "ERROR: Missing version string"; exit 1; }
1620

17-
jazzy \
18-
--github-file-prefix https://github.com/mongodb/swift-bson/tree/v${version} \
19-
--module-version "${version}" \
20-
--output "docs-temp/SwiftBSON" \
21-
--config .jazzy.yml
22-
23-
# switch to docs branch to commit and push
24-
git stash
25-
git checkout gh-pages
26-
27-
rm -rf docs/*
28-
cp -r docs-temp/* docs/
29-
rm -rf docs-temp
30-
31-
git add docs/
21+
jazzy_args=(--clean
22+
--github-file-prefix https://github.com/mongodb/swift-bson/tree/v${version}
23+
--module-version "${version}")
3224

33-
echo '<html><head><meta http-equiv="refresh" content="0; url=BSON/index.html" /></head></html>' > docs/index.html
34-
git add docs/index.html
25+
sourcekitten doc --spm --module-name SwiftBSON > swift-bson-docs.json
26+
args=("${jazzy_args[@]}" --output "docs-temp/SwiftBSON" --module "SwiftBSON" --config ".jazzy.yml"
27+
--sourcekitten-sourcefile swift-bson-docs.json
28+
--root-url "https://mongodb.github.io/swift-bson/docs/SwiftBSON/")
29+
jazzy "${args[@]}"
3530

36-
git commit -m "${version} docs"
37-
git push
31+
echo '<html><head><meta http-equiv="refresh" content="0; url=SwiftBSON/index.html" /></head></html>' > docs-temp/index.html
3832

39-
# go back to wherever we started
40-
git checkout -
33+
rm swift-bson-docs.json

etc/release.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ version=${1}
1515
# regenerate documentation with new version string
1616
./etc/generate-docs.sh ${version}
1717

18+
# switch to docs branch to commit and push
19+
git checkout gh-pages
20+
21+
rm -r docs/current
22+
cp -r docs-temp docs/current
23+
mv docs-temp docs/${version}
24+
25+
# build up documentation index
26+
python3 ./_scripts/update-index.py
27+
28+
git add docs/
29+
git commit -m "${version} docs"
30+
git push
31+
32+
# go back to wherever we started
33+
git checkout -
34+
1835
# tag release and push tag
1936
git tag "v${version}"
2037
git push --tags

0 commit comments

Comments
 (0)