Skip to content

Commit 7ebc292

Browse files
committed
update docs
1 parent a5e77a4 commit 7ebc292

File tree

3 files changed

+157
-52
lines changed

3 files changed

+157
-52
lines changed

docs/de/book/differences-scratch.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ lang: de
88

99
Die wahrscheinlich auffallensten Unterschiede sind die folgenden:
1010

11-
- Das Koordinatensystem startet in der oberen linken Ecke und **nicht** im Zentrum
1211
- Es existiert kein Warte-Block, du musst [Timer](/reference/sprite/sensing/getTimer) verwenden.
1312

1413
Wenn du etwas ähnlich wie folgende erreichen möchtest:

docs/en/book/differences-scratch.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ index: 3
77

88
Probably the most noticeable differences to Scratch are the following:
99

10-
- The coordinated start in the top left hand side corner and **not** in the center.
1110
- There is not wait-block on a Sprite-level, you need to use [Timers](/reference/sprite/sensing/getTimer).
1211

1312
If you want to achieve something like this inside a Sprite:

s4j

Lines changed: 157 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ fi
2020
RED='\033[0;31m'
2121
GREEN='\033[0;32m'
2222
YELLOW='\033[1;33m'
23+
BLUE='\033[0;34m'
2324
NC='\033[0m' # No Color
2425

2526
# Counters
2627
total_classes=0
2728
documented_classes=0
2829
total_methods=0
2930
documented_methods=0
30-
missing_docs=()
31+
missing_docs_en=()
32+
missing_docs_de=()
3133

3234
echo "Documentation Coverage Checker"
3335
echo "=============================="
@@ -90,6 +92,7 @@ EOF
9092
echo -e " ${GREEN}Created:${NC} $index_file"
9193
done
9294
}
95+
9396
is_public_class() {
9497
local java_file="$1"
9598
local class_name=$(get_class_name "$java_file")
@@ -100,6 +103,7 @@ is_public_class() {
100103
grep -q "^\s*public\s\+enum\s\+$class_name" "$java_file" ||
101104
grep -q "^\s*public\s\+abstract\s\+class\s\+$class_name" "$java_file"
102105
}
106+
103107
get_qualified_class_name() {
104108
local java_file="$1"
105109

@@ -156,53 +160,151 @@ extract_public_methods() {
156160
sort -u
157161
}
158162

159-
# Function to check if documentation exists for a method
160-
check_method_documentation() {
163+
# Function to check if documentation exists for a method in a specific language
164+
check_method_documentation_lang() {
161165
local java_file="$1"
162166
local method_name="$2"
167+
local docs_dir="$3"
163168
local doc_folder=$(get_doc_folder "$java_file")
164169

165-
# Check in all documentation directories
166-
for docs_dir in "${DOCS_DIRS[@]}"; do
167-
local doc_path="$docs_dir/$doc_folder/$method_name.md.json"
170+
# First check if method documentation exists directly in class folder
171+
local doc_path="$docs_dir/$doc_folder/$method_name.md.json"
172+
if [ -f "$doc_path" ]; then
173+
return 0
174+
fi
168175

169-
# First check if method documentation exists directly in class folder
170-
if [ -f "$doc_path" ]; then
171-
return 0
176+
# For specific classes (Sprite, Stage, Window), also check subfolders
177+
local class_name=$(get_class_name "$java_file")
178+
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
179+
# Check common subfolders for these classes
180+
local subfolders=("events" "looks" "motion" "sensing" "sound" "control" "operators" "variables")
181+
182+
for subfolder in "${subfolders[@]}"; do
183+
local subfolder_path="$docs_dir/$doc_folder/$subfolder/$method_name.md.json"
184+
if [ -f "$subfolder_path" ]; then
185+
return 0
186+
fi
187+
done
188+
fi
189+
190+
return 1
191+
}
192+
193+
# Function to check if documentation exists for a method (returns status for each language)
194+
check_method_documentation() {
195+
local java_file="$1"
196+
local method_name="$2"
197+
local en_exists=false
198+
local de_exists=false
199+
200+
# Check English documentation
201+
if check_method_documentation_lang "$java_file" "$method_name" "${DOCS_DIRS[0]}"; then
202+
en_exists=true
203+
fi
204+
205+
# Check German documentation
206+
if check_method_documentation_lang "$java_file" "$method_name" "${DOCS_DIRS[1]}"; then
207+
de_exists=true
208+
fi
209+
210+
# Return 0 if exists in at least one language for overall count
211+
if [ "$en_exists" = true ] || [ "$de_exists" = true ]; then
212+
# Store missing language-specific documentation
213+
if [ "$en_exists" = false ]; then
214+
local doc_folder=$(get_doc_folder "$java_file")
215+
local qualified_name=$(get_qualified_class_name "$java_file")
216+
local class_name=$(get_class_name "$java_file")
217+
218+
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
219+
missing_docs_en+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json (or in subfolders: events/, looks/, motion/, etc.)")
220+
else
221+
missing_docs_en+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json")
222+
fi
223+
fi
224+
225+
if [ "$de_exists" = false ]; then
226+
local doc_folder=$(get_doc_folder "$java_file")
227+
local qualified_name=$(get_qualified_class_name "$java_file")
228+
local class_name=$(get_class_name "$java_file")
229+
230+
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
231+
missing_docs_de+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json (or in subfolders: events/, looks/, motion/, etc.)")
232+
else
233+
missing_docs_de+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json")
234+
fi
172235
fi
173236

174-
# For specific classes (Sprite, Stage, Window), also check subfolders
237+
return 0
238+
else
239+
# Add to both missing lists if missing in both languages
240+
local doc_folder=$(get_doc_folder "$java_file")
241+
local qualified_name=$(get_qualified_class_name "$java_file")
175242
local class_name=$(get_class_name "$java_file")
176-
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
177-
# Check common subfolders for these classes
178-
local subfolders=("events" "looks" "motion" "sensing" "sound" "control" "operators" "variables")
179243

180-
for subfolder in "${subfolders[@]}"; do
181-
local subfolder_path="$docs_dir/$doc_folder/$subfolder/$method_name.md.json"
182-
if [ -f "$subfolder_path" ]; then
183-
return 0
184-
fi
185-
done
244+
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
245+
missing_docs_en+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json (or in subfolders: events/, looks/, motion/, etc.)")
246+
missing_docs_de+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json (or in subfolders: events/, looks/, motion/, etc.)")
247+
else
248+
missing_docs_en+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json")
249+
missing_docs_de+=("METHOD: $qualified_name.$method_name -> $doc_folder/$method_name.md.json")
186250
fi
187-
done
188251

252+
return 1
253+
fi
254+
}
255+
256+
# Function to check if documentation exists for a class in a specific language
257+
check_class_documentation_lang() {
258+
local java_file="$1"
259+
local docs_dir="$2"
260+
local doc_folder=$(get_doc_folder "$java_file")
261+
local doc_dir="$docs_dir/$doc_folder"
262+
263+
if [ -d "$doc_dir" ]; then
264+
return 0
265+
fi
189266
return 1
190267
}
191268

192-
# Function to check if documentation exists for a class
269+
# Function to check if documentation exists for a class (returns status for each language)
193270
check_class_documentation() {
194271
local java_file="$1"
195-
local doc_folder=$(get_doc_folder "$java_file")
272+
local en_exists=false
273+
local de_exists=false
196274

197-
# Check in all documentation directories
198-
for docs_dir in "${DOCS_DIRS[@]}"; do
199-
local doc_dir="$docs_dir/$doc_folder"
200-
if [ -d "$doc_dir" ]; then
201-
return 0
275+
# Check English documentation
276+
if check_class_documentation_lang "$java_file" "${DOCS_DIRS[0]}"; then
277+
en_exists=true
278+
fi
279+
280+
# Check German documentation
281+
if check_class_documentation_lang "$java_file" "${DOCS_DIRS[1]}"; then
282+
de_exists=true
283+
fi
284+
285+
# Return 0 if exists in at least one language for overall count
286+
if [ "$en_exists" = true ] || [ "$de_exists" = true ]; then
287+
# Store missing language-specific documentation
288+
local qualified_name=$(get_qualified_class_name "$java_file")
289+
local doc_folder=$(get_doc_folder "$java_file")
290+
291+
if [ "$en_exists" = false ]; then
292+
missing_docs_en+=("CLASS: $qualified_name -> $doc_folder/")
202293
fi
203-
done
204294

205-
return 1
295+
if [ "$de_exists" = false ]; then
296+
missing_docs_de+=("CLASS: $qualified_name -> $doc_folder/")
297+
fi
298+
299+
return 0
300+
else
301+
# Add to both missing lists if missing in both languages
302+
local qualified_name=$(get_qualified_class_name "$java_file")
303+
local doc_folder=$(get_doc_folder "$java_file")
304+
missing_docs_en+=("CLASS: $qualified_name -> $doc_folder/")
305+
missing_docs_de+=("CLASS: $qualified_name -> $doc_folder/")
306+
return 1
307+
fi
206308
}
207309

208310
# Main processing
@@ -225,6 +327,7 @@ while IFS= read -r -d '' java_file; do
225327
if ! is_public_class "$java_file"; then
226328
continue
227329
fi
330+
228331
class_name=$(get_class_name "$java_file")
229332
qualified_name=$(get_qualified_class_name "$java_file")
230333
((total_classes++))
@@ -237,7 +340,6 @@ while IFS= read -r -d '' java_file; do
237340
echo -e " ${GREEN}${NC} Class folder exists"
238341
else
239342
echo -e " ${RED}${NC} Missing class folder: $(get_doc_folder "$java_file")"
240-
missing_docs+=("CLASS: $qualified_name -> $(get_doc_folder "$java_file")/")
241343

242344
# Create missing class documentation if flag is set
243345
if [ "$CREATE_MISSING" = true ]; then
@@ -259,15 +361,6 @@ while IFS= read -r -d '' java_file; do
259361
echo -e " ${GREEN}${NC} Documentation exists"
260362
else
261363
echo -e " ${RED}${NC} Missing documentation"
262-
doc_folder=$(get_doc_folder "$java_file")
263-
class_name=$(get_class_name "$java_file")
264-
265-
# Provide helpful suggestion for Sprite, Stage, Window classes
266-
if [[ "$class_name" == "Sprite" || "$class_name" == "Stage" || "$class_name" == "Window" ]]; then
267-
missing_docs+=("METHOD: $qualified_name.$method -> $doc_folder/$method.md.json (or in subfolders: events/, looks/, motion/, etc.)")
268-
else
269-
missing_docs+=("METHOD: $qualified_name.$method -> $doc_folder/$method.md.json")
270-
fi
271364

272365
# Create missing method documentation if flag is set
273366
if [ "$CREATE_MISSING" = true ]; then
@@ -289,24 +382,38 @@ echo "=============================="
289382
echo "Classes: $documented_classes/$total_classes documented"
290383
echo "Methods: $documented_methods/$total_methods documented"
291384

292-
if [ ${#missing_docs[@]} -gt 0 ]; then
385+
# Show language-specific missing documentation
386+
if [ ${#missing_docs_en[@]} -gt 0 ] || [ ${#missing_docs_de[@]} -gt 0 ]; then
293387
echo ""
294388
if [ "$CREATE_MISSING" = true ]; then
295389
echo -e "${GREEN}CREATED MISSING DOCUMENTATION FILES${NC}"
296390
echo "===================================="
297-
echo -e "${GREEN}Created ${#missing_docs[@]} missing documentation files!${NC}"
391+
total_missing=$((${#missing_docs_en[@]} + ${#missing_docs_de[@]}))
392+
echo -e "${GREEN}Created $total_missing missing documentation files!${NC}"
298393
echo ""
299394
echo "Note: All created files use template placeholders."
300395
echo "Please review and update the content as needed."
301396
else
302-
echo -e "${RED}MISSING DOCUMENTATION:${NC}"
303-
echo "======================="
304-
for missing in "${missing_docs[@]}"; do
305-
echo -e "${YELLOW}$missing${NC}"
306-
done
307-
echo ""
308-
echo -e "${RED}Total missing: ${#missing_docs[@]}${NC}"
309-
echo ""
397+
if [ ${#missing_docs_en[@]} -gt 0 ]; then
398+
echo -e "${RED}MISSING ENGLISH DOCUMENTATION:${NC}"
399+
echo "==============================="
400+
for missing in "${missing_docs_en[@]}"; do
401+
echo -e "${YELLOW}$missing${NC}"
402+
done
403+
echo -e "${RED}Total missing EN: ${#missing_docs_en[@]}${NC}"
404+
echo ""
405+
fi
406+
407+
if [ ${#missing_docs_de[@]} -gt 0 ]; then
408+
echo -e "${RED}MISSING GERMAN DOCUMENTATION:${NC}"
409+
echo "=============================="
410+
for missing in "${missing_docs_de[@]}"; do
411+
echo -e "${YELLOW}$missing${NC}"
412+
done
413+
echo -e "${RED}Total missing DE: ${#missing_docs_de[@]}${NC}"
414+
echo ""
415+
fi
416+
310417
echo "To create missing files automatically, run with --create flag:"
311418
echo " $0 --create"
312419
fi
@@ -316,6 +423,6 @@ if [ ${#missing_docs[@]} -gt 0 ]; then
316423
fi
317424
else
318425
echo ""
319-
echo -e "${GREEN}All public classes and methods are documented! ✓${NC}"
426+
echo -e "${GREEN}All public classes and methods are documented in both languages! ✓${NC}"
320427
exit 0
321428
fi

0 commit comments

Comments
 (0)