Skip to content

Commit 994cbc5

Browse files
authored
Merge pull request #20 from Comfy-Org/feat/update-fix_markdown.sh
Feat/update fix markdown.sh
2 parents be91f10 + e5f1095 commit 994cbc5

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ To ensure minimal consistency across nodes documentation, it is recommended to f
5454
# Run this command: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
5555
npm install -g markdownlint-cli
5656

57-
# Fix linting issues in markdown files, using shell script (Linux)
57+
# Fix linting issues in all markdown files under docs directory,using shell script (Linux)
5858
bash fix_markdown.sh
5959

60+
# Fix linting issues for a specific node's documentation
61+
bash fix_markdown.sh ClipLoader # This will only check files in comfyui_embedded_docs/docs/ClipLoader/
62+
6063
# Or fix linting issues in markdown files, using powershell script (Windows)
6164
powershell -ExecutionPolicy Bypass -File fix_markdown.ps1
6265
```

fix_markdown.sh

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,47 @@
44
# Get the folder path of the script
55
script_folder="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66

7-
# Define the sibling folder containing markdown files
8-
folder_path="$script_folder/comfyui_embedded_docs/docs"
7+
# Set the base path
8+
base_path="$script_folder/comfyui_embedded_docs/docs"
99

10-
# Resolve the full path of the sibling folder
11-
resolved_folder_path="$(realpath "$folder_path")"
10+
# Check if base path exists
11+
if [ ! -d "$base_path" ]; then
12+
echo "Error: Base directory not found"
13+
exit 1
14+
fi
1215

13-
# Find all markdown files in the folder and subfolders
14-
markdown_files=$(find "$resolved_folder_path" -type f -name "*.md")
16+
# Set the target folder path
17+
if [ -n "$1" ]; then
18+
target_folder="$base_path/$1"
19+
if [ ! -d "$target_folder" ]; then
20+
echo "Error: Subdirectory not found"
21+
exit 1
22+
fi
23+
else
24+
target_folder="$base_path"
25+
fi
26+
27+
# Find all markdown files in the target folder and subfolders
28+
markdown_files=$(find "$target_folder" -type f -name "*.md")
29+
30+
# Check if any markdown files were found
31+
if [ -z "$markdown_files" ]; then
32+
echo "No markdown files found"
33+
exit 0
34+
fi
35+
36+
echo "Fixing markdown files..."
1537

1638
# Loop through each markdown file and fix linting issues
1739
for file in $markdown_files; do
18-
echo "Fixing linting issues for: $file"
19-
markdownlint --fix "$file"
40+
# Run markdownlint and capture its output
41+
output=$(markdownlint --fix "$file" 2>&1)
42+
43+
# Only show output if the file was modified
44+
if [ -n "$output" ]; then
45+
relative_path=${file#$base_path/}
46+
echo "Updated: $relative_path"
47+
fi
2048
done
2149

22-
echo "Markdown linting fixes completed!"
50+
echo "Done!"

0 commit comments

Comments
 (0)