Skip to content

Commit

Permalink
Script updates for generating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kistler committed Aug 8, 2018
1 parent 7c96ed2 commit 4acb143
Showing 2 changed files with 34 additions and 31 deletions.
16 changes: 8 additions & 8 deletions Scripts/generate-documentation-resources/index-prefix
Original file line number Diff line number Diff line change
@@ -2,25 +2,25 @@
<html lang="en">
<head>
<title> Reference</title>
<link rel="stylesheet" type="text/css" href="swift-api/css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="swift-api/css/highlight.css" />
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="swift-api/js/jquery.min.js" defer></script>
<script src="swift-api/js/jazzy.js" defer></script>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>

</head>
<body>
<a title=" Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a></p>
<p class="header-right"><a href="https://github.com/watson-developer-cloud/swift-sdk"><img src="swift-api/img/gh.png"/>View on GitHub</a></p>
<p class="header-right"><a href="https://github.com/watson-developer-cloud/swift-sdk"><img src="img/gh.png"/>View on GitHub</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html"> Reference</a>
<img id="carat" src="swift-api/img/carat.png" />
<img id="carat" src="img/carat.png" />
Reference
</p>
</div>
@@ -29,7 +29,7 @@
<article class="main-content">
<section>
<section class="section">

<a href='#watson-developer-cloud-swift-sdk' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h1 id='watson-developer-cloud-swift-sdk'>Watson Developer Cloud Swift SDK</h1>

<a href='#table-of-contents' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h2 id='table-of-contents'>Table of Contents</h2>
49 changes: 26 additions & 23 deletions Scripts/generate-documentation.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# Set the output directory
outdir=${1:-gh-pages}

################################################################################
# Define list of services
################################################################################
@@ -8,7 +11,7 @@ services=(
AssistantV1
ConversationV1
DiscoveryV1
LanguageTranslatorV2
LanguageTranslatorV3
NaturalLanguageClassifierV1
NaturalLanguageUnderstandingV1
PersonalityInsightsV3
@@ -32,25 +35,25 @@ cd ..
# Create folder for generated documentation
################################################################################

if [ -d "docs/swift-api" ]; then
echo "The docs/swift-api directory already exists."
if [ -d "${outdir}" ]; then
echo "The output directory ${outdir} already exists."
echo "Please remove the directory and try again."
exit
fi

mkdir docs/swift-api
mkdir docs/swift-api/services
mkdir ${outdir}
mkdir ${outdir}/services

################################################################################
# Run Jazzy to generate documentation
################################################################################

for service in ${services[@]}; do
mkdir docs/swift-api/services/${service}
mkdir ${outdir}/services/${service}
xcodebuild_arguments=-project,WatsonDeveloperCloud.xcodeproj,-scheme,${service}
jazzy \
--xcodebuild-arguments $xcodebuild_arguments \
--output docs/swift-api/services/${service} \
--output ${outdir}/services/${service} \
--clean \
--github_url https://github.com/watson-developer-cloud/ios-sdk \
--hide-documentation-coverage
@@ -60,36 +63,36 @@ done
# Generate index.html and copy supporting files
################################################################################

cp Scripts/generate-documentation-resources/index-prefix docs/index.html
cp Scripts/generate-documentation-resources/index-prefix ${outdir}/index.html
for service in ${services[@]}; do
html="<li><a target="_blank" href="./swift-api/services/${service}/index.html">${service}</a></li>"
echo ${html} >> docs/index.html
html="<li><a target="_blank" href="./services/${service}/index.html">${service}</a></li>"
echo ${html} >> ${outdir}/index.html
done
cat Scripts/generate-documentation-resources/index-postfix >> docs/index.html
cat Scripts/generate-documentation-resources/index-postfix >> ${outdir}/index.html

cp -r Scripts/generate-documentation-resources/* docs/swift-api
rm docs/swift-api/index-prefix docs/swift-api/index-postfix
cp -r Scripts/generate-documentation-resources/* ${outdir}
rm ${outdir}/index-prefix ${outdir}/index-postfix

################################################################################
# Collect undocumented.json files
################################################################################

touch docs/swift-api/undocumented.json
echo "[" >> docs/swift-api/undocumented.json
touch ${outdir}/undocumented.json
echo "[" >> ${outdir}/undocumented.json

declare -a undocumenteds
undocumenteds=($(ls -r docs/swift-api/services/*/undocumented.json))
undocumenteds=($(ls -r ${outdir}/services/*/undocumented.json))

if [ ${#undocumenteds[@]} -gt 0 ]; then
echo -e -n "\t" >> docs/swift-api/undocumented.json
cat "${undocumenteds[0]}" >> docs/swift-api/undocumented.json
echo -e -n "\t" >> ${outdir}/undocumented.json
cat "${undocumenteds[0]}" >> ${outdir}/undocumented.json
unset undocumenteds[0]
for f in "${undocumenteds[@]}"; do
echo "," >> docs/swift-api/undocumented.json
echo -e -n "\t" >> docs/swift-api/undocumented.json
cat "$f" >> docs/swift-api/undocumented.json
echo "," >> ${outdir}/undocumented.json
echo -e -n "\t" >> ${outdir}/undocumented.json
cat "$f" >> ${outdir}/undocumented.json
done
fi

echo "" >> docs/swift-api/undocumented.json
echo "]" >> docs/swift-api/undocumented.json
echo "" >> ${outdir}/undocumented.json
echo "]" >> ${outdir}/undocumented.json

0 comments on commit 4acb143

Please sign in to comment.