Skip to content

Commit 80032e4

Browse files
authored
add docs (#5)
* add docs * update to ParseSwift 4.9.3 * update ParseSwift and CI
1 parent 2b6cbc4 commit 80032e4

15 files changed

+706
-13
lines changed

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
branches: '*'
77
env:
8-
CI_XCODE_13: '/Applications/Xcode_13.4.app/Contents/Developer'
8+
CI_XCODE: '/Applications/Xcode_14.0.app/Contents/Developer'
99

1010
jobs:
1111
spm-test:
@@ -25,27 +25,27 @@ jobs:
2525
env:
2626
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}
2727
- name: Prepare codecov
28-
uses: sersoft-gmbh/swift-coverage-action@v2
28+
uses: sersoft-gmbh/swift-coverage-action@v3
2929
id: coverage-files
3030
with:
3131
format: lcov
3232
search-paths: ./.build
3333
env:
34-
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}
34+
DEVELOPER_DIR: ${{ env.CI_XCODE }}
3535
- name: Upload coverage to Codecov
36-
uses: codecov/codecov-action@v2
36+
uses: codecov/codecov-action@v3
3737
with:
3838
files: ${{join(fromJSON(steps.coverage-files.outputs.files), ',')}}
3939
env_vars: SPM
4040
fail_ci_if_error: true
4141
env:
42-
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}
42+
DEVELOPER_DIR: ${{ env.CI_XCODE }}
4343

4444
linux:
4545
runs-on: ubuntu-18.04
4646
steps:
4747
- uses: actions/checkout@v3
48-
- uses: sersoft-gmbh/SwiftyActions@v1
48+
- uses: sersoft-gmbh/SwiftyActions@v2
4949
with:
5050
release-version: "5"
5151
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
llvm-cov export -format="lcov" .build/x86_64-unknown-linux-gnu/debug/ParseServerSwiftPackageTests.xctest -instr-profile .build/x86_64-unknown-linux-gnu/debug/codecov/default.profdata > info_linux.lcov
5757
- name: Upload coverage to Codecov
58-
uses: codecov/codecov-action@v2
58+
uses: codecov/codecov-action@v3
5959
with:
6060
env_vars: LINUX
6161
fail_ci_if_error: true

.github/workflows/release.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: release
2+
on:
3+
release:
4+
types: [published]
5+
env:
6+
CI_XCODE_VER: '/Applications/Xcode_12.app/Contents/Developer'
7+
CI_XCODE_13: '/Applications/Xcode_13.4.1.app/Contents/Developer'
8+
9+
jobs:
10+
docs:
11+
runs-on: macos-12
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Use multiple cores
15+
run: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1
16+
- name: Build and Deploy Docs
17+
run: set -o pipefail && env NSUnbufferedIO=YES Scripts/update-gh-pages-documentation-site
18+
env:
19+
CURRENT_BRANCH_NAME: release
20+
DEVELOPER_DIR: ${{ env.CI_XCODE_13 }}

.spi.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- platform: macos-spm
5+
documentation_targets: [ParseServerSwift]

Package.resolved

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"repositoryURL": "https://github.com/parse-community/Parse-Swift.git",
6161
"state": {
6262
"branch": null,
63-
"revision": "15d1724e84d4ee8f819bc5a1efc7efa0427db3e3",
64-
"version": "4.9.1"
63+
"revision": "e54a22c392c803d8827dc9a449d534a992e76484",
64+
"version": "4.13.1"
6565
}
6666
},
6767
{

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let package = Package(
1414
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.65.1")),
1515
.package(url: "https://github.com/vapor/leaf.git", .upToNextMajor(from: "4.2.1")),
1616
.package(url: "https://github.com/parse-community/Parse-Swift.git",
17-
.upToNextMajor(from: "4.9.1"))
17+
.upToNextMajor(from: "4.13.1")),
1818
],
1919
targets: [
2020
.target(

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2Fparse-server-swift%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/netreconlab/parse-server-swift)
66
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fnetreconlab%2Fparse-server-swift%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/netreconlab/parse-server-swift)
77

8-
Write Cloud Code in Swift!
8+
Write Parse Cloud Code in Swift!
99

1010
What is Cloud Code? For complex apps, sometimes you just need logic that isn’t running on a mobile device. Cloud Code makes this possible.
1111
Cloud Code in ParseServerSwift is easy to use because it’s built using [Parse-Swift](https://github.com/parse-community/Parse-Swift)
@@ -29,7 +29,7 @@ app.http.server.configuration.tlsConfiguration = .none
2929
```
3030

3131
### Parse Swift SDK
32-
Configure the SDK as described in the [documentation](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/parseswift/initialize(configuration:)).
32+
Configure the SDK as described in the [documentation](https://parseplatform.org/Parse-Swift/release/documentation/parseswift/).
3333

3434
```swift
3535
// Required: Change to your Parse Server serverURL.

Scripts/generate-documentation

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2022, Apple Inc. All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without modification,
6+
# are permitted provided that the following conditions are met:
7+
#
8+
# 1. Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
#
11+
# 2. Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation and/or
13+
# other materials provided with the distribution.
14+
#
15+
# 3. Neither the name of the copyright holder(s) nor the names of any contributors
16+
# may be used to endorse or promote products derived from this software without
17+
# specific prior written permission. No license is granted to the trademarks of
18+
# the copyright holders even if such marks are included in this software.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
# A `realpath` alternative using the default C implementation.
32+
filepath() {
33+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
34+
}
35+
36+
# First get the absolute path to this file so we can get the absolute file path to the Swift-DocC root source dir.
37+
PROJECT_ROOT="$(dirname $(dirname $(filepath $0)))"
38+
DOCS_DIR="$PROJECT_ROOT/.build/swift-docc"
39+
SGFS_DIR="$DOCS_DIR/symbol-graph-files"
40+
TEMP_WORKSPACE_DIR="$DOCS_DIR/temporary-workspace-holding-directory"
41+
42+
DOCC_CMD=convert
43+
OUTPUT_PATH="$DOCS_DIR/ParseServerSwift.doccarchive"
44+
HOSTING_BASE_PATH=""
45+
PUBLISH="NO"
46+
47+
# Process command line arguments
48+
OUTPUT_PATH_PROCESSED=0
49+
HOSTING_BASE_PATH_PROCESSED=0
50+
while test $# -gt 0; do
51+
case "$1" in
52+
--help)
53+
echo "Usage: $(basename $0) [<output-path>] [<hosting-base-path>] [--preview] [--publish] [--help]"
54+
echo
55+
echo "Builds ParseServerSwift and generates or previews the Swift-DocC documentation."
56+
echo
57+
echo " --preview: Starts a preview server after generating documentation."
58+
echo " --publish: Configures the documentation build for publishing on GitHub pages."
59+
echo
60+
exit 0
61+
;;
62+
--preview)
63+
DOCC_CMD=preview
64+
shift
65+
;;
66+
--publish)
67+
PUBLISH="YES"
68+
shift
69+
;;
70+
*)
71+
if [ ${OUTPUT_PATH_PROCESSED} -eq 0 ]; then
72+
OUTPUT_PATH="$1"
73+
OUTPUT_PATH_PROCESSED=1
74+
elif [ ${HOSTING_BASE_PATH_PROCESSED} -eq 0 ]; then
75+
HOSTING_BASE_PATH="$1"
76+
HOSTING_BASE_PATH_PROCESSED=1
77+
else
78+
echo "Unrecognised argument \"$1\""
79+
exit 1
80+
fi
81+
;;
82+
esac
83+
shift
84+
done
85+
86+
if [ "$PUBLISH" = "YES" ]; then
87+
if [ ${HOSTING_BASE_PATH_PROCESSED} -eq 0 ]; then
88+
echo "A hosting base path must be provided if the '--publish' flag is passed."
89+
echo "See '--help' for details."
90+
exit 1
91+
fi
92+
fi
93+
94+
# Create the output directory for the symbol graphs if needed.
95+
mkdir -p "$DOCS_DIR"
96+
mkdir -p "$SGFS_DIR"
97+
rm -f $SGFS_DIR/*.*
98+
99+
cd "$PROJECT_ROOT"
100+
101+
# Temporarily move the Xcode workspace aside so that xcodebuild uses the Swift package directly
102+
mkdir "$TEMP_WORKSPACE_DIR"
103+
mv Parse.xcworkspace "$TEMP_WORKSPACE_DIR/Parse.xcworkspace"
104+
105+
xcodebuild clean build -scheme ParseServerSwift\ \(iOS\) \
106+
-destination generic/platform=iOS \
107+
OTHER_SWIFT_FLAGS="-emit-symbol-graph -emit-symbol-graph-dir '$SGFS_DIR'" | xcpretty
108+
109+
mv "$TEMP_WORKSPACE_DIR/Parse.xcworkspace" ./Parse.xcworkspace
110+
rm -r "$TEMP_WORKSPACE_DIR"
111+
112+
# Pretty print DocC JSON output so that it can be consistently diffed between commits
113+
export DOCC_JSON_PRETTYPRINT="YES"
114+
115+
# By default pass the --index flag so we produce a full DocC archive.
116+
EXTRA_DOCC_FLAGS="--index"
117+
118+
# If building for publishing, don't pass the --index flag but pass additional flags for
119+
# static hosting configuration.
120+
if [ "$PUBLISH" = "YES" ]; then
121+
EXTRA_DOCC_FLAGS="--transform-for-static-hosting --hosting-base-path Parse-Swift/$HOSTING_BASE_PATH"
122+
fi
123+
124+
# Handle the case where a DocC catalog does not exist in the ParseServerSwift repo
125+
if [ -d Sources/ParseServerSwift/Documentation.docc ]; then
126+
# The DocC catalog exists, so pass it to the docc invocation.
127+
DOCC_CMD="$DOCC_CMD Sources/ParseServerSwift/Documentation.docc"
128+
fi
129+
130+
xcrun docc $DOCC_CMD \
131+
--additional-symbol-graph-dir "$SGFS_DIR" \
132+
--output-path "$OUTPUT_PATH" $EXTRA_DOCC_FLAGS \
133+
--fallback-display-name ParseServerSwift \
134+
--fallback-bundle-identifier edu.uky.cs.netreconlab.ParseServerSwift \
135+
--fallback-bundle-version 1.0.0
136+
137+
if [[ "$DOCC_CMD" == "convert"* ]]; then
138+
echo
139+
echo "Generated DocC archive at: $OUTPUT_PATH"
140+
fi
141+
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (c) 2022, Apple Inc. All rights reserved.
4+
#
5+
# Redistribution and use in source and binary forms, with or without modification,
6+
# are permitted provided that the following conditions are met:
7+
#
8+
# 1. Redistributions of source code must retain the above copyright notice, this
9+
# list of conditions and the following disclaimer.
10+
#
11+
# 2. Redistributions in binary form must reproduce the above copyright notice,
12+
# this list of conditions and the following disclaimer in the documentation and/or
13+
# other materials provided with the distribution.
14+
#
15+
# 3. Neither the name of the copyright holder(s) nor the names of any contributors
16+
# may be used to endorse or promote products derived from this software without
17+
# specific prior written permission. No license is granted to the trademarks of
18+
# the copyright holders even if such marks are included in this software.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
24+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
set -eu
32+
33+
# A `realpath` alternative using the default C implementation.
34+
filepath() {
35+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
36+
}
37+
38+
PROJECT_ROOT="$(dirname $(dirname $(filepath $0)))"
39+
40+
# Set current directory to the repository root
41+
cd "$PROJECT_ROOT"
42+
43+
# Use git worktree to checkout the gh-pages branch of this repository in a gh-pages sub-directory
44+
git fetch
45+
git worktree add --checkout gh-pages origin/gh-pages
46+
47+
# Get the name of the current branch to use as the subdirectory for the deployment
48+
if [ -z ${CURRENT_BRANCH_NAME+x} ]; then
49+
CURRENT_BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
50+
fi
51+
52+
# Replace any forward slashes in the current branch name with dashes
53+
DEPLOYMENT_SUBDIRECTORY=${CURRENT_BRANCH_NAME//\//-}
54+
55+
# Create a subdirectory for the current branch name if it doesn't exist
56+
mkdir -p "./gh-pages/$DEPLOYMENT_SUBDIRECTORY"
57+
58+
# Generate documentation output it
59+
# to the /docs subdirectory in the gh-pages worktree directory.
60+
./Scripts/generate-documentation "$PROJECT_ROOT/gh-pages/$DEPLOYMENT_SUBDIRECTORY" "$DEPLOYMENT_SUBDIRECTORY" --publish
61+
62+
# Save the current commit we've just built documentation from in a variable
63+
CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`
64+
65+
# Commit and push our changes to the gh-pages branch
66+
cd gh-pages
67+
git add "$DEPLOYMENT_SUBDIRECTORY"
68+
69+
if [ -n "$(git status --porcelain)" ]; then
70+
echo "Documentation changes found. Commiting the changes to the 'gh-pages' branch and pushing to origin."
71+
git commit -m "Update documentation to $CURRENT_COMMIT_HASH on '$CURRENT_BRANCH_NAME'"
72+
git push origin HEAD:gh-pages
73+
else
74+
# No changes found, nothing to commit.
75+
echo "No documentation changes found."
76+
fi
77+
78+
# Delete the git worktree we created
79+
cd ..
80+
git worktree remove gh-pages
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@Tutorial(time: 3) {
2+
@Intro(title: "Adding ParseObjects") {
3+
The ParseObject models in your server should mirror the same models in your client applications.
4+
}
5+
6+
@Section(title: "Example Models") {
7+
@Steps {
8+
@Step {
9+
It is recommended to add all of your `ParseObject`'s to [ParseServerSwift/Sources/ParseServerSwift/Models](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/Models).
10+
11+
@Code(name: "GameScore Model", file: GameScore.swift)
12+
}
13+
14+
@Step {
15+
Be sure to add all of the additional properties you have in your `_User` class to the `User` model which is located at [ParseServerSwift/Sources/ParseServerSwift/Models/User.swift](https://github.com/netreconlab/ParseServerSwift/blob/main/Sources/ParseServerSwift/Models/User.swift).
16+
17+
@Code(name: "User Model", file: GameScore.swift)
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)