Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ on:

workflow_dispatch:

# schedule:
# - cron: '40 11 * * *' # once a day @ 11:40am UTC (4:40am PST)
schedule:
- cron: '40 11 * * *' # once a day @ 11:40am UTC (4:40am PST)

env:
SCHEME: "OSCKit"
Expand Down
10 changes: 5 additions & 5 deletions .spi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ version: 1
builder:
configs:
- platform: macosSpm
scheme: OSCKit-CI
scheme: OSCKit
- platform: macosXcodebuild
scheme: OSCKit-CI
scheme: OSCKit
- platform: iOS
scheme: OSCKit-CI
scheme: OSCKit
- platform: tvOS
scheme: OSCKit-CI
scheme: OSCKit
- platform: watchOS
scheme: NOT-SUPPORTED
- platform: visionOS
scheme: OSCKit-CI
scheme: OSCKit
external_links:
documentation: "https://orchetect.github.io/OSCKit/"
57 changes: 57 additions & 0 deletions Docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# OSCKit DocC Generation

## Build and Publish

The docs generation procedure is mostly automated, but requires a handful of manual procedures that are not yet automated in order to build and publish.

1. Run the `dev/Scripts/build-docc-cached-preview.sh` command from Terminal from within the repo directory

- If any DocC warnings are shown:

1. resolve the issues in the codebase
2. re-run the build script and repeat resolving issues until no more warnings are present
3. make a commit

- When finished the generated docs path will be output to the console, ie:

```
Generated combined documentation archive at:
/var/folders/pk/3smbhvrd0p701_rpq3t0c_2r0000gn/T/tmp.Oq9smpNmnD/docs-webroot/OSCKit
```

As well, a local webserver on port 8080 will run to preview the documentation in a local web browser at this URL:

http://localhost:8080/OSCKit/documentation

2. Press `Ctrl+C` in the Terminal window to shut down the local webserver and return to the shell prompt

3. Navigate to the generated docs path using the path that was output to the console

```bash
cd /var/folders/pk/3smbhvrd0p701_rpq3t0c_2r0000gn/T/tmp.Oq9smpNmnD/docs-webroot/OSCKit
```

Then to open this folder in the Finder:

```bash
open .
```

4. In the local repo `docs` branch:

- remove all files within the `docs` subfolder except `index.html`
- copy all files from the generated docs `except index.html` to replace the old docs that were deleted

5. See the [Post-Build](#Post-Build) section below

6. Commit and push to remote `docs` branch - GitHub Actions will automatically publish the site to GitHub Pages

## Post-Build

The root-level `index.html` file in the local repo `docs` branch needs to edited to include a meta event to redirect to the documentation subpath.

```html
<head>
<!-- ... -->
<meta http-equiv="refresh" content="0; url=documentation/">
```
10 changes: 10 additions & 0 deletions Docs/build-docc-cached-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Build docc documentation

# This invocation provides a stable scrach (build) directory location which allows repeated runs to
# execute faster. This is useful when developing and debugging documentation generation compiler warnings.
#
# After building, a local web server is started to preview the documentation.

REPO_PATH="$(git rev-parse --show-toplevel)"
BUILD_PATH="$REPO_PATH/.build"
./build-docc.sh -w -s "$BUILD_PATH"
10 changes: 10 additions & 0 deletions Docs/build-docc-cached.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Build docc documentation

# This invocation provides a stable scrach (build) directory location which allows repeated runs to
# execute faster. This is useful when developing and debugging documentation generation compiler warnings.
#
# After building, the built documentation folder is opened in the Finder.

REPO_PATH="$(git rev-parse --show-toplevel)"
BUILD_PATH="$REPO_PATH/.build"
./build-docc.sh -o -s "$BUILD_PATH"
99 changes: 99 additions & 0 deletions Docs/build-docc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Build docc documentation

# Arguments:
#
# [-s <path>] Optionally supply a scratch path (a.k.a. build path).
# Defaults to temporary directory, which is unique on every script execution.
# To provide a stable scratch folder, supply this argument with the path to a directory
# (absolute path, or relative path to the current working directory.)
#
# For example, to use the default ".build" folder at the repo's root:
# build-docc -s .build

# Swift-DocC Plugin Documentation:
# https://swiftlang.github.io/swift-docc-plugin/documentation/swiftdoccplugin/

PACKAGE_NAME="OSCKit"

usageAndExit() { echo "$0 usage:" && grep "[[:space:]].)\ #" $0 | sed 's/#//' | sed -r 's/([a-z])\)/-\1/'; exit 0; }

while getopts "s::owh" flag; do
case "${flag}" in
s) # Optionally supply a scratch (build) directory path.
BUILD_PATH="${OPTARG}"
;;
o) # Open folder in the Finder after building.
OPEN_FOLDER_IN_FINDER=1
;;
w) # Start a local webserver to preview documentation after building.
ALLOW_WEBSERVER=1
;;
h) # Display help.
usageAndExit
;;
esac
done

# Provide default(s) for arguments
if [ "$OPEN_FOLDER_IN_FINDER" = "" ]; then OPEN_FOLDER_IN_FINDER=0; fi
if [ "$ALLOW_WEBSERVER" = "" ]; then ALLOW_WEBSERVER=0; fi

# Set up base paths
REPO_PATH="$(git rev-parse --show-toplevel)"
TEMP_WORKING_PATH="$(mktemp -d)"
DOCC_OUTPUT_WEBROOT="$TEMP_WORKING_PATH/docs-webroot"
DOCC_OUTPUT_PATH="$DOCC_OUTPUT_WEBROOT/$PACKAGE_NAME"

echo "Package Name: $PACKAGE_NAME"
echo "Repo Path: $REPO_PATH"
echo "Temporary Working Path: $TEMP_WORKING_PATH"
echo "DocC Output Path: $DOCC_OUTPUT_PATH"

# Create output folders
mkdir "$DOCC_OUTPUT_WEBROOT"
mkdir "$DOCC_OUTPUT_PATH"

cd "$REPO_PATH"

# Set up build paths
if [ "$BUILD_PATH" = "" ]; then BUILD_PATH="$TEMP_WORKING_PATH/build"; fi
echo "Scratch (Build) Path: $BUILD_PATH"
PLUGIN_OUTPUTS_PATH="$BUILD_PATH/plugins/Swift-DocC/outputs"

# Delete old docs from build folder, if any
if [ -d "$PLUGIN_OUTPUTS_PATH" ]; then
echo "Removing old build products..."
rm -r "$PLUGIN_OUTPUTS_PATH"
fi

# Custom env flag that opts-in to using the plugin as a Package dependency
export ENABLE_DOCC_PLUGIN=1

# --disable-indexing: Indexing is only relevant to IDEs like Xcode, and not relevant for hosting online
echo "Compiling docs..."
swift package \
--scratch-path "$BUILD_PATH" \
--disable-sandbox \
--allow-writing-to-directory "$DOCC_OUTPUT_PATH" \
generate-documentation \
--target OSCKit \
--target OSCKitCore \
--disable-indexing \
--output-path "$DOCC_OUTPUT_PATH" \
--transform-for-static-hosting \
--enable-experimental-combined-documentation \
--hosting-base-path "$PACKAGE_NAME"

# Reveal output folder in finder
if [ $OPEN_FOLDER_IN_FINDER == 1 ]; then
echo "Opening built documentation in Finder."
open "$DOCC_OUTPUT_PATH"
fi

# Start local webserver
if [ $ALLOW_WEBSERVER == 1 ]; then
echo Starting localhost webserver on port 8080. Press Ctrl+C to end.
echo Browse: http://localhost:8080/$PACKAGE_NAME/documentation/
cd "$DOCC_OUTPUT_WEBROOT"
ruby -run -ehttpd . -p8080
fi
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
mainGroup = E2D003C8289882820073ED8F;
packageReferences = (
E2D003F2289884030073ED8F /* XCRemoteSwiftPackageReference "CocoaAsyncSocket" */,
E2CE6F062CCF22A800F81BCE /* XCLocalSwiftPackageReference "../../../OSCKit" */,
E2CE6F062CCF22A800F81BCE /* XCLocalSwiftPackageReference "../../" */,
);
productRefGroup = E2D003D2289882820073ED8F /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -379,9 +379,9 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
E2CE6F062CCF22A800F81BCE /* XCLocalSwiftPackageReference "../../../OSCKit" */ = {
E2CE6F062CCF22A800F81BCE /* XCLocalSwiftPackageReference "../../" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../../../OSCKit;
relativePath = ../../;
};
/* End XCLocalSwiftPackageReference section */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
mainGroup = E2D003C8289882820073ED8F;
packageReferences = (
E2D003F2289884030073ED8F /* XCRemoteSwiftPackageReference "CocoaAsyncSocket" */,
E2CE6F092CCF238500F81BCE /* XCLocalSwiftPackageReference "../../../OSCKit" */,
E2CE6F092CCF238500F81BCE /* XCLocalSwiftPackageReference "../../" */,
);
productRefGroup = E2D003D2289882820073ED8F /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -379,9 +379,9 @@
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
E2CE6F092CCF238500F81BCE /* XCLocalSwiftPackageReference "../../../OSCKit" */ = {
E2CE6F092CCF238500F81BCE /* XCLocalSwiftPackageReference "../../" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = ../../../OSCKit;
relativePath = ../../;
};
/* End XCLocalSwiftPackageReference section */

Expand Down
Loading
Loading