Skip to content

Commit b4a8357

Browse files
authored
SWIFT-734 Update scripts to maintain multiple versions of the documentation (#601)
1 parent 917e177 commit b4a8357

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

etc/docs-main.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ The MongoDB Swift driver contains two modules:
55
- [MongoSwift](../MongoSwift/index.html), containing an asynchronous API and a BSON library
66
- [MongoSwiftSync](../MongoSwiftSync/index.html), containing a synchronous wrapper of the API in `MongoSwift`
77

8+
See [here](https://mongodb.github.io/mongo-swift-driver/docs) for documentation of other versions of the driver.
9+
810
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).

etc/generate-docs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ jazzy_args=(--clean
2323
--module-version "${version}")
2424

2525
# Generate MongoSwift docs
26+
sourcekitten doc --spm --module-name MongoSwift > mongoswift-docs.json
2627
args=("${jazzy_args[@]}" --output "docs-temp/MongoSwift" --module "MongoSwift" --config ".jazzy.yml"
28+
--sourcekitten-sourcefile mongoswift-docs.json
2729
--root-url "https://mongodb.github.io/mongo-swift-driver/docs/MongoSwift/")
2830
jazzy "${args[@]}"
2931

3032
# Generate MongoSwiftSync docs
3133

3234
# we have to do some extra work to get re-exported symbols to show up
33-
sourcekitten doc --spm --module-name MongoSwift > mongoswift-docs.json
3435
python3 etc/filter_sourcekitten_output.py
3536

3637
sourcekitten doc --spm --module-name MongoSwiftSync > mongoswiftsync-docs.json

etc/release.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ version=${1}
1818
# commit/push docs to the gh-pages branch
1919
git checkout gh-pages
2020

21-
rm -rf docs/*
22-
mv docs-temp/* docs/
23-
rm -d docs-temp
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 ./etc/update-index.py
2427

2528
git add docs/
2629
git commit -m "${version} docs"

etc/update-index.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
first=True
4+
with open('./docs/index.md', 'w') as f:
5+
f.write('# MongoSwift Documentation Index\n')
6+
7+
for dir in sorted(os.listdir('./docs'), reverse=True):
8+
if not dir[0].isdigit():
9+
continue
10+
11+
version_str = dir
12+
if first:
13+
version_str += ' (current)'
14+
dir = 'current'
15+
first = False
16+
17+
f.write('- [{}]({}/MongoSwift/index.html)\n'.format(version_str, dir))

0 commit comments

Comments
 (0)