Skip to content

Commit

Permalink
docs: script and warning fixups
Browse files Browse the repository at this point in the history
* use OTHER_DOCC_FLAGS flag to bypass process-archive call

* add single script for static doc generation and post-processing

* fix docc warnings
  • Loading branch information
andrewjl-mux committed Jul 10, 2024
1 parent b42788f commit f35d281
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 112 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/docc-static-site-deployment.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Foundation

extension DirectUpload {

/// Initializes a DirectUpload from an ``AVAsset``
/// Initializes a DirectUpload from an `AVAsset`.
///
/// - Parameters:
/// - uploadURL: the URL of your direct upload, see
Expand Down
6 changes: 3 additions & 3 deletions Sources/MuxUploadSDK/PublicAPI/DirectUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public typealias DirectUploadResult = Result<DirectUpload.SuccessDetails, Direct
///
/// Uploads created by this SDK are globally managed by default,
/// and can be resumed after failures or after an application
/// restart or termination. For more see ``UploadManager``.
/// restart or termination. For more see ``MuxUploadSDK/DirectUploadManager``.
public final class DirectUpload {

var input: UploadInput {
Expand All @@ -72,7 +72,7 @@ public final class DirectUpload {
public enum InputStatus {
/// Upload initialized and not yet started
case ready(AVAsset)
/// Upload started by a call to ``DirectUpload.start(forceRestart:)``
/// Upload started by a call to ``MuxUploadSDK/DirectUpload/start(forceRestart:)``
case started(AVAsset)
/// Upload is being prepared for transport to the
/// server. If input standardization was requested,
Expand Down Expand Up @@ -176,7 +176,7 @@ public final class DirectUpload {

/// Sets a handler that will be executed by the SDK
/// when input standardization doesn't succeed. Return
/// <doc:true> to continue the upload
/// `true` to continue the upload
public var nonStandardInputHandler: NonStandardInputHandler?

private let manageBySDK: Bool
Expand Down
12 changes: 6 additions & 6 deletions Sources/MuxUploadSDK/PublicAPI/Options/DirectUploadOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public struct DirectUploadOptions {
/// If requested the SDK will attempt to detect
/// non-standard input formats and if so detected
/// will attempt to standardize to a standard input
/// format. ``true`` by default
/// format. `true` by default
public var isRequested: Bool = true

/// Preset to control the maximum resolution of a
Expand Down Expand Up @@ -121,7 +121,7 @@ public struct DirectUploadOptions {
/// Example 1: a direct upload input with 1440 x 1080
/// resolution encoded using Apple ProRes and with
/// no other non-standard input parameters with
/// ``MaximumResolution.default`` selected.
/// ``MuxUploadSDK/DirectUploadOptions/InputStandardization-swift.struct/MaximumResolution-swift.enum/default`` selected.
///
/// If input standardization is requested, the SDK
/// will attempt standardize the input into an H.264
Expand All @@ -131,7 +131,7 @@ public struct DirectUploadOptions {
/// Example 2: a direct upload input with 1440 x 1080
/// resolution encoded using H.264 and with no other
/// non-standard input format parameters with
/// ``MaximumResolution.preset1280x720`` selected.
/// ``MuxUploadSDK/DirectUploadOptions/InputStandardization-swift.struct/MaximumResolution-swift.enum/preset1280x720`` selected.
///
/// If input standardization is requested, the SDK
/// will attempt standardize the input into an H.264
Expand Down Expand Up @@ -226,7 +226,7 @@ public struct DirectUploadOptions {
/// standardization. Input standardization is requested
/// by default.
/// To skip input standardization pass in
/// ``DirectUploadOptions.InputStandardization.skipped``.
/// ``MuxUploadSDK/DirectUploadOptions/InputStandardization/skipped``.
/// - transport: options for transporting the
/// direct upload input to Mux
/// - eventTracking: event tracking options for the
Expand All @@ -250,7 +250,7 @@ public struct DirectUploadOptions {
/// standardization. Input standardization is requested
/// by default.
/// To skip input standardization pass in
/// ``DirectUploadOptions.InputStandardization.skipped``.
/// ``MuxUploadSDK/DirectUploadOptions/InputStandardization/skipped``.
/// - chunkSize: The size of each file chunk sent by
/// the SDK during an upload. Defaults to 8MB.
/// - retryLimitPerChunk: number of retry attempts
Expand Down Expand Up @@ -278,7 +278,7 @@ public struct DirectUploadOptions {
/// standardization. Input standardization is requested
/// by default.
/// To skip input standardization pass in
/// ``DirectUploadOptions.InputStandardization.skipped``.
/// ``MuxUploadSDK/DirectUploadOptions/InputStandardization/skipped``.
/// - chunkSizeInBytes: The size of each file chunk
/// in bytes sent by the SDK during an upload.
/// Defaults to 8MB.
Expand Down
72 changes: 4 additions & 68 deletions scripts/create-docc-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
readonly XCODE=$(xcodebuild -version | grep Xcode | cut -d " " -f2)

#readonly TOP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
readonly TOP_DIR=`pwd`
readonly TOP_DIR=$PWD
readonly BUILD_DIR="${TOP_DIR}/.build"
readonly DOCUMENTATION_DIR="${BUILD_DIR}/docs"

readonly SCHEME=${target_scheme}
readonly DOCC_ARCHIVE_NAME="${SCHEME}.doccarchive"
readonly DOCC_ARCHIVE_PATH="${BUILD_DIR}/${DOCC_ARCHIVE_NAME}"

# Subdirectory of the devdocs S3 bucket where SDK static docs are stored
# in a directory corresponding to the SDKs version. Ex: "${DOCS_ROOT_DIR}/1.0.0"
readonly DOCS_ROOT_DIR=${devdocs_bucket}
readonly DOCUMENTATION_DIR=".build/docs"
readonly SCHEME=MuxUploadSDK

if ! command -v xcbeautify &> /dev/null
then
Expand All @@ -35,66 +28,9 @@ xcodebuild docbuild -scheme $SCHEME \
-destination 'generic/platform=iOS' \
-sdk iphoneos \
-derivedDataPath "${DOCUMENTATION_DIR}" \
OTHER_DOCC_FLAGS="--transform-for-static-hosting --hosting-base-path swift-upload-sdk --output-path docs" \
| xcbeautify

cd ${BUILD_DIR}

echo "▸ Finished building Documentation Archive"

echo "▸ Searching for ${DOCC_ARCHIVE_NAME} inside ${DOCUMENTATION_DIR}"
docc_built_archive_path=$(find docs -type d -name "${DOCC_ARCHIVE_NAME}")

if [ -z "${docc_built_archive_path}" ]
then
echo -e "\033[1;31m ERROR: Failed to locate Documentation Archive \033[0m"
exit 1
else
echo "▸ Located documentation archive at ${docc_built_archive_path}"
#mv ${docc_built_archive_path} ${BUILD_DIR}
cp -r ${docc_built_archive_path} ${BUILD_DIR}
zip -qry "${DOCC_ARCHIVE_NAME}.zip" "${DOCC_ARCHIVE_NAME}"
fi

# When deploying a new version the contents of the latest subdirectory
# gets replaced with the generated documentation from the new version
latest_subdirectory_name="latest"

static_documentation_versioned_path="${DOCS_ROOT_DIR}/${sdk_semantic_version}"

source_archive_path=${DOCC_ARCHIVE_PATH}
output_path=$sdk_semantic_version
hosting_base_path=$static_documentation_versioned_path

echo "▸ Processing documentation archive with source archive path: ${source_archive_path} hosting base path: ${hosting_base_path} output path: ${output_path}"

mkdir -p $output_path

$(xcrun --find docc) process-archive transform-for-static-hosting "${source_archive_path}" \
--output-path "${output_path}" \
--hosting-base-path "${hosting_base_path}"

# Replace index.html with a redirect to documentation/your-lib-name/ for your version
sed -e "s/__VERSION__/${sdk_semantic_version}/g" \
-e "s/__SLUG__/${DOCS_ROOT_DIR}/g" \
"scripts/docc-files/index.html.template" > ${output_path}/index.html

mkdir -p $DOCS_ROOT_DIR

mkdir -p $DOCS_ROOT_DIR/$latest_subdirectory_name

# Replace index.html with a redirect to documentation/your-lib-name/ for 'latest'
sed -e "s/__VERSION__/${latest_subdirectory_name}/" \
-e "s/__SLUG__/${DOCS_ROOT_DIR}/g" \
"scripts/docc-files/index.html.template" > $DOCS_ROOT_DIR/${latest_subdirectory_name}/index.html

# For the record this overwrites our faked index.html but that helps it work
cp -r ./$output_path/. ./$DOCS_ROOT_DIR/$latest_subdirectory_name


mv $output_path $DOCS_ROOT_DIR

zip -qry "${DOCS_ROOT_DIR}.zip" "${DOCS_ROOT_DIR}"

cd ..

exit
12 changes: 12 additions & 0 deletions scripts/generate-static-documentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

readonly DOCUMENTATION_TOP_LEVEL_SLUG=swift-upload-sdk
readonly DOCUMENTATION_TARGET_SLUG=muxuploadsdk

echo "▸ Creating docc static archive"
./scripts/create-docc-archive.sh

echo "▸ Preparing docc static archive for deployment"
echo "▸ Top level slug: ${DOCUMENTATION_TOP_LEVEL_SLUG} Target slug: ${DOCUMENTATION_TARGET_SLUG}"

./scripts/post-process-docc-archive.sh $DOCUMENTATION_TOP_LEVEL_SLUG $DOCUMENTATION_TARGET_SLUG
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ then
fi

echo "▸ Adding redirect from the docc static archive root"
echo "▸ with path structure: ${1}/documentation/${2}"

output_path="docs"

Expand All @@ -27,3 +28,7 @@ cat ${output_path}/index.html
echo "▸ Copy theme settings to static archive"

cp scripts/docc-files/theme-settings.json docs

echo "▸ Copied theme settings content"

cat docs/theme-settings.json

0 comments on commit f35d281

Please sign in to comment.