Skip to content

Commit

Permalink
Fix v2 doc collisions with v1. Make protoc multithreaded for doc gene…
Browse files Browse the repository at this point in the history
…ration. (#1096)

Signed-off-by: Cody Littley <[email protected]>
  • Loading branch information
cody-littley authored Jan 10, 2025
1 parent 8b99abc commit 3d1d2bf
Show file tree
Hide file tree
Showing 21 changed files with 1,832 additions and 551 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Auto-generated files should not be rendered in diffs.
api/docs/*.md linguist-generated=true
api/docs/*.html linguist-generated=true
*.pb.go linguist-generated=true
inabox/deploy/env_vars.go linguist-generated=true
# contracts/bindings/*.go linguist-generated=true Enable once bindings are checked in CI
107 changes: 69 additions & 38 deletions api/builder/generate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,92 @@ done
# Sort the proto files alphabetically. Required for deterministic output.
IFS=$'\n' PROTO_FILES=($(sort <<<"${PROTO_FILES[*]}")); unset IFS

# Generate unified HTML doc
echo "Generating unified HTML documentation..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${PROTO_FILES[@]}" \
--doc_opt=html,eigenda-protos.html 2>/dev/null

if [ $? -ne 0 ]; then
echo "Failed to generate unified HTML documentation."
exit 1
fi
PID_LIST=()

# Generate unified markdown doc
echo "Generating unified markdown documentation..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${PROTO_FILES[@]}" \
--doc_opt=markdown,eigenda-protos.md 2>/dev/null

if [ $? -ne 0 ]; then
echo "Failed to generate unified markdown documentation."
exit 1
fi
# Generate unified HTML doc
generateUnifiedHTML() {
echo "Generating unified HTML documentation..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${PROTO_FILES[@]}" \
--doc_opt=html,eigenda-protos.html 2>/dev/null &

# Generate individual markdown/HTML docs
for PROTO_FILE in "${PROTO_FILES[@]}"; do
PROTO_NAME=$(basename "${PROTO_FILE}" .proto)
if [ $? -ne 0 ]; then
echo "Failed to generate unified HTML documentation."
exit 1
fi
}
generateUnifiedHTML &
PID_LIST+=($!)

echo "Generating markdown documentation for ${PROTO_NAME}..."
# Generate unified markdown doc
generateUnifiedMD() {
echo "Generating unified markdown documentation..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${PROTO_FILE}" \
--doc_opt=markdown,"${PROTO_NAME}.md" 2>/dev/null
"${PROTO_FILES[@]}" \
--doc_opt=markdown,eigenda-protos.md 2>/dev/null

if [ $? -ne 0 ]; then
echo "Failed to generate documentation for ${PROTO_NAME}."
echo "Failed to generate unified markdown documentation."
exit 1
fi
}
generateUnifiedMD &
PID_LIST+=($!)

echo "Generating HTML documentation for ${PROTO_NAME}..."
# Generate markdown docs for a proto file. First argument is the name of the proto file, second is the path.
generateMD() {
echo "Generating markdown documentation for ${1}..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${PROTO_FILE}" \
--doc_opt=html,"${PROTO_NAME}.html" 2>/dev/null
"${2}" \
--doc_opt=markdown,"${1}.md" 2>/dev/null

if [ $? -ne 0 ]; then
echo "Failed to generate documentation for ${PROTO_NAME}."
echo "Failed to generate documentation for ${1}."
exit 1
fi
done
}

# Generate HTML docs for a proto file. First argument is the name of the proto file, second is the path.
generateHTML() {
echo "Generating HTML documentation for ${1}..."
docker run --rm \
-v "${DOCS_DIR}":/out \
-v "${PROTO_DIR}":/protos \
pseudomuto/protoc-gen-doc \
"${2}" \
--doc_opt=html,"${1}.html" 2>/dev/null

if [ $? -ne 0 ]; then
echo "Failed to generate documentation for ${1}."
exit 1
fi
}

# Generate individual markdown/HTML docs
for PROTO_FILE in "${PROTO_FILES[@]}"; do
PROTO_NAME=$(basename "${PROTO_FILE}" .proto)

generateMD "${PROTO_NAME}" "${PROTO_FILE}" &
PID_LIST+=($!)

generateHTML "${PROTO_NAME}" "${PROTO_FILE}" &
PID_LIST+=($!)
done

# Wait for all processes to finish
for PID in "${PID_LIST[@]}"; do
wait $PID
if [ $? -ne 0 ]; then
echo "Failed to wait for process $PID."
exit 1
fi
done
109 changes: 41 additions & 68 deletions api/docs/common.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3d1d2bf

Please sign in to comment.