Skip to content

Commit 3b3347f

Browse files
authored
Merge pull request #2829 from jaidev17/spell-check-implementation
Spelling check workflow - exclude all Draft LPs and install guides
2 parents 7e64e91 + 4e8cf95 commit 3b3347f

4 files changed

Lines changed: 151 additions & 2 deletions

File tree

.github/workflows/spell-and-link-check.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ jobs:
5353
path: htmltest.log
5454
retention-days: 5
5555

56+
- name: Generate spell check configuration
57+
run: tools/generate-spellcheck-non-draft.sh
58+
5659
- name: Spell check
5760
id: spellcheck
5861
continue-on-error: true
5962
uses: rojopolis/spellcheck-github-actions@0.40.0
6063
with:
61-
config_path: .spellcheck.yml
64+
config_path: .spellcheck-non-draft.yml
6265
task_name: Markdown
6366
output_file: spellcheck-output.txt
6467

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ z_local_saved/
2323
*.xml
2424

2525
# CTags symbol index
26-
tags
26+
tags
27+
28+
# Generated spell check config
29+
.spellcheck-non-draft.yml

.wordlist.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ ArmIE
253253
armiotcosmosdb
254254
armiotstorage
255255
armips
256+
armbaseline
256257
armkeil
257258
armlearningpaths
258259
armlink
@@ -731,6 +732,7 @@ ClassName
731732
CLCD
732733
cli
733734
CLI
735+
CLIs
734736
ClickBench
735737
clickhouse
736738
ClickHouse
@@ -1595,6 +1597,7 @@ gcov
15951597
gcovr
15961598
gcp
15971599
GCP
1600+
gcpuser
15981601
GCs
15991602
GCT
16001603
gdb
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/bin/bash
2+
# Generate a spell check configuration that only includes non-draft files
3+
# This script finds all markdown files EXCEPT those in draft Learning Paths
4+
5+
cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" || exit 1
6+
7+
output_config=".spellcheck-non-draft.yml"
8+
9+
# Arrays to collect draft files
10+
draft_lp_dirs=()
11+
draft_install_guides=()
12+
draft_lp_files=()
13+
14+
# Find draft Learning Path directories (those with cascade directive)
15+
echo "Finding draft Learning Paths with cascade directive..."
16+
draft_file_list=$(find content/learning-paths -type f -name "_index.md" -exec grep -l "^draft: true" {} \; 2>/dev/null)
17+
while IFS= read -r file; do
18+
[ -z "$file" ] && continue
19+
# Only mark entire directory as draft if it has cascade directive
20+
if grep -q "^cascade:" "$file" 2>/dev/null; then
21+
dir=$(dirname "$file")
22+
draft_lp_dirs+=("$dir")
23+
echo " - $dir/"
24+
fi
25+
done <<< "$draft_file_list"
26+
echo "Found ${#draft_lp_dirs[@]} draft Learning Path director(ies) with cascade"
27+
echo ""
28+
29+
# Find draft install guides
30+
echo "Finding draft install guides..."
31+
while IFS= read -r file; do
32+
[ -z "$file" ] && continue
33+
if grep -q "^draft: true[[:space:]]*$" "$file" 2>/dev/null; then
34+
draft_install_guides+=("$file")
35+
echo " - $file"
36+
fi
37+
done < <(find content/install-guides -name "*.md" -type f | sort)
38+
echo "Found ${#draft_install_guides[@]} draft install guide(s)"
39+
echo ""
40+
41+
# Find individual draft Learning Path files (not in cascade directories)
42+
echo "Finding individual draft Learning Path files..."
43+
while IFS= read -r file; do
44+
[ -z "$file" ] && continue
45+
46+
# Check if this file is in a cascade-draft directory
47+
in_draft_dir=0
48+
for draft_dir in "${draft_lp_dirs[@]}"; do
49+
if [[ "$file" == "$draft_dir"* ]]; then
50+
in_draft_dir=1
51+
break
52+
fi
53+
done
54+
55+
# If not in draft directory, check if individually marked as draft
56+
if [ $in_draft_dir -eq 0 ] && grep -q "^draft: true[[:space:]]*$" "$file" 2>/dev/null; then
57+
draft_lp_files+=("$file")
58+
echo " - $file"
59+
fi
60+
done < <(find content/learning-paths -name "*.md" -type f | sort)
61+
echo "Found ${#draft_lp_files[@]} individual draft Learning Path file(s)"
62+
echo ""
63+
64+
# Write base config template
65+
cat > "$output_config" << 'EOF'
66+
matrix:
67+
- name: Markdown
68+
expect_match: false
69+
apsell:
70+
mode: en
71+
dictionary:
72+
wordlists:
73+
- .wordlist.txt
74+
output: wordlist.dic
75+
encoding: utf-8
76+
pipeline:
77+
- pyspelling.filters.markdown:
78+
markdown_extensions:
79+
- markdown.extensions.extra:
80+
- pyspelling.filters.html:
81+
comments: false
82+
attributes:
83+
- alt
84+
ignores:
85+
- ':matches(code, pre)'
86+
- 'code'
87+
- 'pre'
88+
- 'blockquote'
89+
sources:
90+
EOF
91+
92+
echo "Building sources list (excluding drafts)..."
93+
94+
# Collect and add install guide files (excluding drafts)
95+
install_count=0
96+
while IFS= read -r file; do
97+
[ -z "$file" ] && continue
98+
# Check if this install guide is marked as draft (allowing trailing whitespace)
99+
if ! grep -q "^draft: true[[:space:]]*$" "$file" 2>/dev/null; then
100+
echo " - '$file'" >> "$output_config"
101+
((install_count++))
102+
fi
103+
done < <(find content/install-guides -name "*.md" -type f | sort)
104+
echo "Found $install_count non-draft install guide(s)"
105+
106+
# Collect and add non-draft learning path files
107+
lp_count=0
108+
while IFS= read -r file; do
109+
[ -z "$file" ] && continue
110+
# Check if this file is in a cascade-draft directory
111+
is_draft=0
112+
for draft_dir in "${draft_lp_dirs[@]}"; do
113+
if [[ "$file" == "$draft_dir"* ]]; then
114+
is_draft=1
115+
break
116+
fi
117+
done
118+
119+
# Also check if this individual file is marked as draft (allowing trailing whitespace)
120+
if [ $is_draft -eq 0 ] && grep -q "^draft: true[[:space:]]*$" "$file" 2>/dev/null; then
121+
is_draft=1
122+
fi
123+
124+
if [ $is_draft -eq 0 ]; then
125+
echo " - '$file'" >> "$output_config"
126+
((lp_count++))
127+
fi
128+
done < <(find content/learning-paths -name "*.md" -type f | sort)
129+
echo "Found $lp_count non-draft Learning Path source file(s)"
130+
131+
if [ ! -f "$output_config" ]; then
132+
echo "Error: Failed to create $output_config" >&2
133+
exit 1
134+
fi
135+
136+
echo ""
137+
echo "Generated spell check configuration: $output_config"
138+
echo " Install guides: $install_count"
139+
echo " Learning Path source files: $lp_count"
140+
echo " File size: $(wc -c < "$output_config") bytes"

0 commit comments

Comments
 (0)