Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve API docs generation #148

Merged
merged 2 commits into from
Jun 23, 2022
Merged
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
36 changes: 27 additions & 9 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
default_platform :ios

platform :ios do

before_all do
setup_circle_ci
end

desc "Runs all the tests"
desc 'Runs all the tests'
lane :test do |options|
scheme = options[:scheme]
device = options[:device]
Expand All @@ -19,31 +18,50 @@ platform :ios do
)
end

desc "Cocoapods library lint"
desc 'Cocoapods library lint'
lane :pod_lint do
pod_lib_lint(verbose: false, allow_warnings: true)
end

desc "Runs all the tests in a CI environment"
desc 'Runs all the tests in a CI environment'
lane :ci do
# TODO: Run rest of platforms
test
end

desc "Tags the release and pushes the Podspec to CocoaPods"
desc 'Tags the release and pushes the Podspec to CocoaPods'
lane :release do
perform_release target: 'SimpleKeychain-iOS'
publish_release repository: 'SimpleKeychain'
end

desc "Generate API documentation"
desc 'Generate API documentation'
lane :build_docs do
target = 'SimpleKeychain'
docs_dir = 'docs'
docs_archive = 'docs.archive'
redirect_file = <<~HEREDOC
<html>
<head>
<meta http-equiv="refresh" content="0; url=documentation/#{target.downcase}/" />
</head>
<body>
<p>
<a href="documentation/#{target.downcase}/">Redirect</a>
</p>
</body>
</html>
HEREDOC
# Work from project root (defaults to /fastlane)
Dir.chdir("..") do
Dir.chdir('..') do
# Clear existing docs
FileUtils.rm_r(docs_dir)
# Generate the .doccarchive
sh "xcodebuild docbuild -scheme SimpleKeychain-iOS -configuration Release -destination 'generic/platform=iOS' -derivedDataPath docs.archive"
sh "xcodebuild docbuild -scheme #{target}-iOS -configuration Release -destination 'generic/platform=iOS' -derivedDataPath #{docs_archive}"
# Generate the static site
sh "$(xcrun --find docc) process-archive transform-for-static-hosting docs.archive/Build/Products/Release-iphoneos/SimpleKeychain.doccarchive --hosting-base-path SimpleKeychain --output-path docs"
sh "$(xcrun --find docc) process-archive transform-for-static-hosting #{docs_archive}/Build/Products/Release-iphoneos/#{target}.doccarchive --hosting-base-path #{target} --output-path #{docs_dir}"
# Write redirect file
File.write("#{docs_dir}/index.html", redirect_file)
end
end
end