-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathprocess-passport-tutorials.sh
More file actions
executable file
·71 lines (55 loc) · 2.25 KB
/
Copy pathprocess-passport-tutorials.sh
File metadata and controls
executable file
·71 lines (55 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
set -x
# Directory where docs repo is cloned
DOCS_REPO_DIR="${CLONE_DIR:-"./imx-docs"}"
# Root of the Passport features
PASSPORT_ROOT="./sample/Assets/Scripts/Passport"
TUTORIALS_DIR="${PASSPORT_ROOT}/_tutorials~"
echo "Processing Passport tutorials..."
FEATURES_JSON="${PASSPORT_ROOT}/features.json"
if [ ! -f "${FEATURES_JSON}" ]; then
echo "Error: features.json not found at ${FEATURES_JSON}"
exit 1
fi
# Base directory for usage guides in the docs repo
DOCS_USAGE_GUIDES_DIR="${DOCS_REPO_DIR}/docs/main/build/unity/usage/passport"
# Check if _tutorials~ directory exists
if [ ! -d "${TUTORIALS_DIR}" ]; then
echo "Warning: _tutorials~ directory not found at ${TUTORIALS_DIR}"
else
# Process each feature group directory in _tutorials~
find "${TUTORIALS_DIR}" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' GROUP_DIR; do
echo "Processing feature group: ${GROUP_DIR}"
# Extract feature group name from directory
GROUP_NAME=$(basename "${GROUP_DIR}")
# Tutorial file path
TUTORIAL_FILE="${GROUP_DIR}/tutorial.md"
if [ -f "${TUTORIAL_FILE}" ]; then
echo "Found tutorial for ${GROUP_NAME}"
# Define the destination directory for this feature group
DEST_GROUP_DIR="${DOCS_USAGE_GUIDES_DIR}/_tutorials"
mkdir -p "${DEST_GROUP_DIR}"
# Use the folder name directly for the destination filename
OUTPUT_FILENAME="${GROUP_NAME}.md"
# Copy the tutorial file to its new group directory
cp "${TUTORIAL_FILE}" "${DEST_GROUP_DIR}/${OUTPUT_FILENAME}"
echo "Copied ${TUTORIAL_FILE} to ${DEST_GROUP_DIR}/${OUTPUT_FILENAME}"
else
echo "Warning: No tutorial.md found for feature group ${GROUP_NAME}"
fi
done
fi
# Copy the generated JSON file
JSON_FILE="./_parsed/passport-features.json"
if [ -f "${JSON_FILE}" ]; then
# Create directory for JSON file if it doesn't exist
JSON_DIR="${DOCS_REPO_DIR}/docs/main/build/unity/usage/passport"
mkdir -p "${JSON_DIR}"
# Copy JSON file
cp "${JSON_FILE}" "${JSON_DIR}/passport-examples.json"
echo "Copied ${JSON_FILE} to ${JSON_DIR}/passport-examples.json"
else
echo "Warning: No passport-features.json found at ${JSON_FILE}"
fi
echo "Passport tutorial processing complete."