Skip to content

Commit 0fb1d3e

Browse files
authored
fix: Polish docs scripts (#1775)
1 parent 1363521 commit 0fb1d3e

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

scripts/docs_generate_api_docs_from_openapi.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#!/bin/bash
33

4-
cd ../docs;
4+
cd $(dirname "$0")/../docs;
55

66
# Before running this script, make sure you have update the openapi.json from the backend & backend is in the latest state.
77
printf "Fetching the latest openapi.json."
@@ -15,5 +15,8 @@ fi
1515

1616
echo "Successfully downloaded openapi.json"
1717

18-
python3 $(dirname "$0")/docs_openapi_converter.py --source ./openapi.json --dest ./openapi.json
19-
npx @mintlify/scraping@latest openapi-file ./openapi.json -o $(dirname "$0")/../docs/api-ref
18+
python3 ../scripts/docs_openapi_converter.py --source ./openapi.json --dest ./openapi.json
19+
npx @mintlify/scraping@latest openapi-file ./openapi.json -o api-ref
20+
21+
echo "Checking mint.json for missing files..."
22+
./../scripts/docs_validate_navigation.sh

scripts/docs_validate_navigation.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

3-
cd ../docs;
3+
cd "$(dirname "$0")/../docs"
44

55
# Define the JSON file
6-
MINT_JSON="../docs/mint.json"
6+
MINT_JSON="mint.json"
77

88
# Define the exclusion lists
99
EXCLUDE_LIST=("node_modules")
@@ -30,8 +30,6 @@ is_excluded() {
3030

3131
# Check if the exact file is in the file exclusion list
3232
for exclude_file in "${EXCLUDE_FILE_LIST[@]}"; do
33-
# echo "exclude_file: $exclude_file"
34-
# echo "file_path: $file_path"
3533
if [[ $file_path == "$exclude_file" ]]; then
3634
return 0 # The file is in the exclusion file list
3735
fi
@@ -42,8 +40,10 @@ is_excluded() {
4240

4341
echo "Checking for missing files in mint.json..."
4442

43+
is_missing=0
44+
4545
# Go over each .mdx file in all subdirectories within the current directory
46-
find . -mindepth 2 -type f -name "*.mdx" | sort | while read -r file; do
46+
while IFS= read -r -d '' file; do
4747
# Check if the file is in the exclusion list
4848
if is_excluded "$file"; then
4949
continue
@@ -58,9 +58,14 @@ find . -mindepth 2 -type f -name "*.mdx" | sort | while read -r file; do
5858
# echo "File $relative_path is listed in mint.json"
5959
:
6060
else
61-
echo "🔴🔴🔴 \"$relative_path\" is missing in docs/mint.json. That's a file responsible for rendering docs navigation."
62-
echo "Please add the new docs page there or to the EXCLUDE_FILE_LIST of the current script."
63-
echo "Otherwise the page will be really hard to navigate to :)"
64-
exit 1 # Exit with an error code to fail the CI/CD process
61+
echo "\"$relative_path\","
62+
is_missing=1
6563
fi
66-
done
64+
done < <(find . -mindepth 2 -type f -name "*.mdx" -print0 | sort -z)
65+
66+
if [[ $is_missing -ne 0 ]]; then
67+
echo "🔴🔴🔴 👆 those files are missing in docs/mint.json. That's a file responsible for rendering docs navigation."
68+
echo "Please add the new docs page there or to the EXCLUDE_FILE_LIST of the current script."
69+
echo "Otherwise the page will be really hard to navigate to :)"
70+
exit 1 # Exit with an error code to fail the CI/CD process
71+
fi

0 commit comments

Comments
 (0)