Skip to content

Commit

Permalink
setup docc
Browse files Browse the repository at this point in the history
  • Loading branch information
p-x9 committed Mar 14, 2024
1 parent d3769a7 commit 2b3da5e
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

XCFrameworks/
XCFrameworks/
docs/
symbol-graphs/
3 changes: 3 additions & 0 deletions MachOKit.docc/MachOKit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ``MachOKit``

🔬 A Swift library for parsing MachO files to obtain various information.
3 changes: 3 additions & 0 deletions MachOKit.docc/MachOKitC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ``MachOKitC``

🔬 A Swift library for parsing MachO files to obtain various information.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: xcframework
xcframework:
bash scripts/xcframework.sh

.PHONY: docc
docc:
bash scripts/docc.sh

.PHONY: docc-preview
docc-preview:
bash scripts/docc-preview.sh
16 changes: 16 additions & 0 deletions scripts/docc-preview.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

TARGET='MachOKit'

preview_docc() {
mkdir -p docs

$(xcrun --find docc) preview \
"./${TARGET}.docc" \
--additional-symbol-graph-dir symbol-graphs \
--output-path "docs"
}

sh ./scripts/generate-symbols.sh

preview_docc
18 changes: 18 additions & 0 deletions scripts/docc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

TARGET='MachOKit'
REPO_NAME='MachOKit'

generate_docc() {
mkdir -p docs

$(xcrun --find docc) convert \
"./${TARGET}.docc" \
--output-path "docs" \
--hosting-base-path "${REPO_NAME}" \
--additional-symbol-graph-dir ./symbol-graphs
}

sh ./scripts/generate-symbols.sh

generate_docc
44 changes: 44 additions & 0 deletions scripts/generate-symbols.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

SYMBOL_DIR='./symbol-graphs'

clean_build() {
rm -rf ./.build
}

clean_xcbuild() {
destination=$1
scheme=$2

xcodebuild -scheme "$scheme" \
-destination "generic/platform=${destination}" \
clean
}

clean_symbol() {
rm -rf SYMBOL_DIR
}

generate_symbol_graphs() {
destination=$1
scheme=$2

mkdir -p .build/symbol-graphs
mkdir -p symbol-graphs

xcodebuild clean build -scheme "${scheme}"\
-destination "generic/platform=${destination}" \
OTHER_SWIFT_FLAGS="-emit-extension-block-symbols -emit-symbol-graph -emit-symbol-graph-dir $(pwd)/.build/symbol-graphs"

mv "./.build/symbol-graphs/${scheme}.symbols.json" "${SYMBOL_DIR}/${scheme}_${destination}.symbols.json"
}


clean_build
clean_xcbuild ios MachOKitC
clean_xcbuild ios MachOKit

clean_symbol

generate_symbol_graphs ios MachOKitC
generate_symbol_graphs ios MachOKit

0 comments on commit 2b3da5e

Please sign in to comment.