-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_wandb_sdk_docs.sh
More file actions
91 lines (78 loc) · 2.68 KB
/
create_wandb_sdk_docs.sh
File metadata and controls
91 lines (78 loc) · 2.68 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
TEMP_DIR=wandb_sdk_docs
DESTINATION_DIR=python
JSON_OUTPUT_DIR=logs
PARENT_DOCS_DIR="../docs"
DOCS_JSON_FILE="$PARENT_DOCS_DIR/docs.json"
# Parse command line arguments
CHECK_DOCS_JSON=false
while [[ $# -gt 0 ]]; do
case $1 in
--check-docs-json)
CHECK_DOCS_JSON=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--check-docs-json]"
exit 1
;;
esac
done
# Check if the directory exists, if it does, remove it else create it
if [ -d "$TEMP_DIR" ]; then
echo "Directory '$TEMP_DIR' already exists. Removing it."
rm -rf "$TEMP_DIR"
else
echo "Directory '$TEMP_DIR' does not exist. Creating it."
mkdir -p "$TEMP_DIR"
fi
# Check if the destination directory exists, if it does, remove it else create it
if [ -d "$DESTINATION_DIR" ]; then
echo "Directory '$DESTINATION_DIR' already exists. Removing it."
rm -rf "$DESTINATION_DIR"
else
echo "Directory '$DESTINATION_DIR' does not exist. Creating it."
mkdir -p "$DESTINATION_DIR"
fi
# Check if the destination directory exists, if it does, remove it else create it
if [ -d "$JSON_OUTPUT_DIR" ]; then
echo "Directory '$JSON_OUTPUT_DIR' already exists. Removing it."
rm -rf "$JSON_OUTPUT_DIR"
else
echo "Directory '$JSON_OUTPUT_DIR' does not exist. Creating it."
mkdir -p "$JSON_OUTPUT_DIR"
fi
# Generate SDK docs using lazydocs
python generate_sdk_docs.py --temp_output_directory=$TEMP_DIR
# Process output doc created by lazydocs so it works with Docusaurus
python process_sdk_markdown.py --markdown_directory=$TEMP_DIR
# Make destination directory
mkdir -p $DESTINATION_DIR
# Sort and create subdirectories based on API or DataType
python sort_markdown_files.py --source_directory=$TEMP_DIR --destination_directory=$DESTINATION_DIR
# Clean up the directory: add admonitions, extract mdx files, etc.
python cleanup_directory.py --directory=$DESTINATION_DIR --json-output=$JSON_OUTPUT_DIR
# Optionally copy docs.json and run comparison check
if [ "$CHECK_DOCS_JSON" = true ]; then
if [ -d "$PARENT_DOCS_DIR" ]; then
echo "Found '$PARENT_DOCS_DIR' directory."
if [ -f "$DOCS_JSON_FILE" ]; then
echo "Copying docs.json to current directory..."
cp "$DOCS_JSON_FILE" .
echo "Done. docs.json copied successfully."
else
echo "Error: docs.json not found in '$PARENT_DOCS_DIR'."
exit 1
fi
else
echo "Error: '$PARENT_DOCS_DIR' directory does not exist."
exit 1
fi
# Compare generated .mdx files with docs.json
python check_mdx_vs_docsjson.py --mdx-list=$JSON_OUTPUT_DIR/mdx_file_list.json \
--docs-json=$DOCS_JSON_FILE \
--output-report-dir=$JSON_OUTPUT_DIR
else
echo "Skipping docs.json check. Use --check-docs-json to enable."
fi