Skip to content

Commit

Permalink
remove gradle dep when running gen-swagger-docs.sh (#3390)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Henriksen <[email protected]>
  • Loading branch information
mhenriks authored Aug 17, 2024
1 parent 6269010 commit d68f59e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
2 changes: 1 addition & 1 deletion hack/build/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FUNC_TEST_PROXY="cdi-func-test-proxy"
FUNC_TEST_POPULATOR="cdi-func-test-sample-populator"

# update this whenever new builder tag is created
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2408131802-67ef11da7}
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2408160841-626901083}

BINARIES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_REGISTRY_INIT} tools/${FUNC_TEST_BAD_WEBSERVER} tools/${FUNC_TEST_PROXY} tools/${FUNC_TEST_POPULATOR}"
CDI_PKGS="cmd/ pkg/ test/"
Expand Down
37 changes: 0 additions & 37 deletions hack/gen-swagger-doc/build.gradle

This file was deleted.

17 changes: 12 additions & 5 deletions hack/gen-swagger-doc/gen-swagger-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@ if [ "$OUTPUT_FORMAT" = "html" ]; then
LINK1_TEMPLATE="\* \<\<\${VERSION}.\$m\>\>"
LINK_DEFINITIONS="* link:./definitions.html[Types Definition]"
LINK_OPERATIONS="* link:./operations.html[Operations]"
GRADLE_EXTRA_PARAMS=""
elif [ "$OUTPUT_FORMAT" = "markdown" ]; then
SUFFIX="md"
HEADER="#"
LINK1_TEMPLATE="\* [\${VERSION}.\$m]\(definitions.md#\${VERSION}-\${m,,}\)"
LINK_DEFINITIONS="* [Types Definition](definitions.md)"
LINK_OPERATIONS="* [Operations](operations.md)"
GRADLE_EXTRA_PARAMS="-PmarkupLanguage=MARKDOWN"
else
echo "Unknown OUTPUT_FORMAT=${OUTPUT_FORMAT}"
exit 1
fi
WORKDIR="hack/gen-swagger-doc"
GRADLE_BUILD_FILE="$WORKDIR/build.gradle"
SWAGGER_JSON="api/openapi-spec/swagger.json"

# Generate *.adoc files from swagger.json
gradle -b $GRADLE_BUILD_FILE $GRADLE_EXTRA_PARAMS convertSwagger2markup --info --stacktrace
java -jar /opt/swagger2markup-cli/swagger2markup-cli-1.3.3.jar convert -i $SWAGGER_JSON -d $WORKDIR/

#insert a TOC for top level API objects
buf="${HEADER}${HEADER} Top Level API Objects\n\n"
Expand Down Expand Up @@ -86,7 +84,16 @@ if [ "$OUTPUT_FORMAT" = "html" ]; then
"$WORKDIR/overview.adoc"

# Generate *.html files from *.adoc
gradle -b $GRADLE_BUILD_FILE asciidoctor --info
rm -rf "$WORKDIR/html5" && mkdir -p "$WORKDIR/html5"
adoc_files=("definitions.adoc" "overview.adoc" "security.adoc" "operations.adoc")
for html_file in ${adoc_files[@]}; do
asciidoctor \
--failure-level INFO \
--attribute toc=right \
--destination-dir $WORKDIR/html5 \
$PWD/$WORKDIR/$html_file
done

rm -rf "$WORKDIR/html5/content" && mkdir "$WORKDIR/html5/content" && mv -f "$WORKDIR/html5/"*.html "$WORKDIR/html5/content"
mv -f "$WORKDIR/html5/content/overview.html" "$WORKDIR/html5/content/index.html"
elif [ "$OUTPUT_FORMAT" = "markdown" ]; then
Expand Down
1 change: 0 additions & 1 deletion hack/gen-swagger-doc/gradle.properties

This file was deleted.

0 comments on commit d68f59e

Please sign in to comment.