Skip to content

Commit

Permalink
DocC Improvements (#2111)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Feb 14, 2024
1 parent 8e5fc4c commit 17e6e7c
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 121 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ios-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ jobs:
- if: github.event_name == 'pull_request'
uses: ./.github/actions/save-pr-number

- name: Build DocC documentation main branch
if: github.ref == 'refs/heads/main'
- name: Build DocC documentation
working-directory: .
run: |
scripts/docc.sh
HOSTING_BASE_PATH="maplibre-native/ios/latest" platform/ios/scripts/docc.sh
- name: Deploy DocC documentation (main) 🚀
if: github.ref == 'refs/heads/main'
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: platform/ios/build/docs
folder: build/docs
target-folder: ios/latest/

# Make Metal XCFramework release
Expand Down
16 changes: 1 addition & 15 deletions platform/ios/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,9 @@ filegroup(
visibility = ["//visibility:public"],
)

# this can be removed once the legacy renderer is removed completely for iOS
genrule(
name = "umbrella_header",
srcs = ["src/Mapbox.template.h"],
outs = ["src/Mapbox.h"],
cmd = select({
"//:metal_renderer": """
echo "#define MLN_RENDER_BACKEND_METAL 1" > $@;
cat $(location src/Mapbox.template.h) >> $@;
""",
"//conditions:default": "cat $(location src/Mapbox.template.h) >> $@",
}),
)

filegroup(
name = "ios_public_hdrs",
srcs = MLN_IOS_PUBLIC_HEADERS + [":umbrella_header"],
srcs = MLN_IOS_PUBLIC_HEADERS,
visibility = ["//visibility:public"],
)

Expand Down
5 changes: 0 additions & 5 deletions platform/ios/Documentation.docc/Documentation.md

This file was deleted.

4 changes: 4 additions & 0 deletions platform/ios/MapLibre.docc/MapLibre.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Powerful, free and open-source mapping toolkit with full control over data sourc

### Map

- ``MLNSettings``
- ``MLNMapCamera``
- ``MLNMapViewDelegate``
- ``MLNMapView``
- ``MLNUserTrackingMode``

### Style Layers

Expand Down
20 changes: 20 additions & 0 deletions platform/ios/MapLibre.docc/theme-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"theme": {
"color": {
"documentation-intro-fill": "#111725",
"documentation-intro-accent": "#1058c0",
"link": {
"light": "#1058c0",
"dark": "#82b4fe"
},
"button-background": {
"light": "#1058c0",
"dark": "#82b4fe"
},
"fill-blue": {
"light": "#1058c0",
"dark": "#82b4fe"
}
}
}
}
1 change: 1 addition & 0 deletions platform/ios/bazel/files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ MLN_IOS_SDK_HEADERS = [
]

MLN_IOS_PUBLIC_HEADERS = [
"src/Mapbox.h",
]

MLN_IOS_PRIVATE_HEADERS = [
Expand Down
53 changes: 40 additions & 13 deletions platform/ios/scripts/docc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# $ python3 -m http.server
# Go to http://localhost:8000/documentation/maplibre/

set -e
shopt -s extglob

cmd="convert"
if [[ "$1" == "preview" ]]; then
cmd="preview"
Expand All @@ -21,41 +24,65 @@ SDK_PATH=$(xcrun -sdk iphoneos --show-sdk-path)
build_dir=build

rm -rf "$build_dir"/symbol-graphs
rm -rf "$build_dir"/headers/MapLibre
rm -rf "$build_dir"/MapLibre.xcframework
rm -rf "$build_dir"/headers

mkdir -p "$build_dir"/symbol-graphs
mkdir -p "$build_dir"/headers/MapLibre
mkdir -p "$build_dir"/headers

bazel build --//:renderer=metal //platform/darwin:generated_style_public_hdrs

public_headers=$(bazel query 'kind("source file", deps(//platform:ios-sdk, 2))' --output location | grep ".h$" | sed -r 's#.*/([^:]+).*#\1#')
style_headers=$(bazel cquery --//:renderer=metal //platform/darwin:generated_style_public_hdrs --output=files)

cp $style_headers "$build_dir"/headers

filter_filenames() {
local prefix="$1"
local filenames="$2"
local filtered_filenames=""

for filename in $filenames; do
local prefixed_filename="$prefix/$filename"

if [ -f "$prefixed_filename" ]; then
filtered_filenames="$filtered_filenames $prefixed_filename"
fi
done

# unzip built XCFramework in build dir
unzip ../../bazel-bin/platform/ios/MapLibre.dynamic.xcframework.zip -d "$build_dir"
echo "$filtered_filenames"
}

# copy all public headers from XCFramework
cp "$build_dir"/MapLibre.xcframework/ios-arm64/MapLibre.framework/Headers/*.h "$build_dir"/headers/MapLibre
ios_headers=$(filter_filenames "platform/ios/src" "$public_headers")
darwin_headers=$(filter_filenames "platform/darwin/src" "$public_headers")

xcrun --toolchain swift clang \
for header in $ios_headers $darwin_headers $style_headers; do
xcrun --toolchain swift clang \
-extract-api \
--product-name=MapLibre \
-isysroot $SDK_PATH \
-F "$SDK_PATH"/System/Library/Frameworks \
-I "$PWD" \
-I "$(realpath ../darwin/src)" \
-I "$build_dir"/headers \
-I platform/darwin/src \
-x objective-c-header \
-o "$build_dir"/symbol-graphs/MapLibre.symbols.json \
"$build_dir"/headers/MapLibre/*.h
-o "$build_dir"/symbol-graphs/$(basename $header).symbols.json \
$header
done

export DOCC_HTML_DIR=$(dirname $(xcrun --toolchain swift --find docc))/../share/docc/render
$(xcrun --find docc) "$cmd" MapLibre.docc \
$(xcrun --find docc) "$cmd" platform/ios/MapLibre.docc \
--fallback-display-name "MapLibre Native for iOS" \
--fallback-bundle-identifier org.swift.MyProject \
--fallback-bundle-version 0.0.1 \
--additional-symbol-graph-dir "$build_dir"/symbol-graphs \
--source-service github \
--source-service-base-url https://github.com/maplibre/maplibre-native/blob/main \
--checkout-path $(realpath .) \
--output-path "$build_dir"/MapLibre.doccarchive

if [[ "$cmd" == "convert" ]]; then
rm -rf build/docs
$(xcrun --find docc) process-archive transform-for-static-hosting "$build_dir"/MapLibre.doccarchive \
--hosting-base-path maplibre-native/ios/latest \ # remove for local builds
${HOSTING_BASE_PATH:+--hosting-base-path "$HOSTING_BASE_PATH"} \
--output-path build/docs
fi
Loading

0 comments on commit 17e6e7c

Please sign in to comment.