From 4b53ec4bcfb8f7adcac67bcabf0e1520cf834055 Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Thu, 4 Feb 2021 17:23:10 -0500 Subject: [PATCH 1/2] fix docs generation on linux --- etc/generate-docs.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/etc/generate-docs.sh b/etc/generate-docs.sh index a31787f06..e002610b0 100755 --- a/etc/generate-docs.sh +++ b/etc/generate-docs.sh @@ -23,14 +23,15 @@ jazzy_args=(--clean --module-version "${version}") # Generate MongoSwift docs +sourcekitten doc --spm --module-name MongoSwift > mongoswift-docs.json args=("${jazzy_args[@]}" --output "docs-temp/MongoSwift" --module "MongoSwift" --config ".jazzy.yml" + --sourcekitten-sourcefile mongoswift-docs.json --root-url "https://mongodb.github.io/mongo-swift-driver/docs/MongoSwift/") jazzy "${args[@]}" # Generate MongoSwiftSync docs # we have to do some extra work to get re-exported symbols to show up -sourcekitten doc --spm --module-name MongoSwift > mongoswift-docs.json python3 etc/filter_sourcekitten_output.py sourcekitten doc --spm --module-name MongoSwiftSync > mongoswiftsync-docs.json From b5c5139733d3d9e040a654f43a5c05d30d272521 Mon Sep 17 00:00:00 2001 From: Patrick Freed Date: Thu, 4 Feb 2021 19:20:36 -0500 Subject: [PATCH 2/2] update documentation generation to keep old versions --- etc/docs-main.md | 2 ++ etc/release.sh | 9 ++++++--- etc/update-index.py | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 etc/update-index.py diff --git a/etc/docs-main.md b/etc/docs-main.md index 60cf35bc2..830b6a51b 100644 --- a/etc/docs-main.md +++ b/etc/docs-main.md @@ -5,4 +5,6 @@ The MongoDB Swift driver contains two modules: - [MongoSwift](../MongoSwift/index.html), containing an asynchronous API and a BSON library - [MongoSwiftSync](../MongoSwiftSync/index.html), containing a synchronous wrapper of the API in `MongoSwift` +See [here](https://mongodb.github.io/mongo-swift-driver/docs) for documentation of other versions of the driver. + The driver relies on our [official Swift BSON library](https://github.com/mongodb/swift-bson), with API documentation available [here](https://mongodb.github.io/swift-bson). diff --git a/etc/release.sh b/etc/release.sh index 5141f102e..6f48231af 100755 --- a/etc/release.sh +++ b/etc/release.sh @@ -18,9 +18,12 @@ version=${1} # commit/push docs to the gh-pages branch git checkout gh-pages -rm -rf docs/* -mv docs-temp/* docs/ -rm -d docs-temp +rm -r docs/current +cp -r docs-temp docs/current +mv docs-temp docs/${version} + +# build up documentation index +python3 ./etc/update-index.py git add docs/ git commit -m "${version} docs" diff --git a/etc/update-index.py b/etc/update-index.py new file mode 100644 index 000000000..fe1c31a13 --- /dev/null +++ b/etc/update-index.py @@ -0,0 +1,17 @@ +import os + +first=True +with open('./docs/index.md', 'w') as f: + f.write('# MongoSwift Documentation Index\n') + + for dir in sorted(os.listdir('./docs'), reverse=True): + if not dir[0].isdigit(): + continue + + version_str = dir + if first: + version_str += ' (current)' + dir = 'current' + first = False + + f.write('- [{}]({}/MongoSwift/index.html)\n'.format(version_str, dir))