@@ -8,33 +8,50 @@ set -euo pipefail
88ROOTS=(modules/core modules/contracts)
99MISS=0
1010echo " 🔎 Doc lint: scanning for missing Scaladoc on public declarations"
11- for r in " ${ROOTS[@]} " ; do
12- while IFS= read -r -d ' ' f; do
13- lines=()
14- while IFS= read -r line; do
15- lines+=(" $line " )
16- done < <( nl -ba " $f " )
17- for (( i= 0 ; i< ${# lines[@]} ; i++ )) ; do
18- L=" ${lines[$i]} "
19- # Match top-level public declarations (very simple heuristic)
20- if [[ " $L " =~ [[:space:]]+[0-9]+[[:space:]]+ (trait| class| object)[[:space:]]+[A-Z][A-Za-z0-9_]* [[:space:]]* \{ ? ]]; then
21- # Look back a few lines for a /** ... */ opener
22- hasdoc=0
23- for b in 1 2 3 4 5; do
24- j=$(( i- b))
25- if (( j >= 0 )) ; then
26- if [[ " ${lines[$j]} " =~ \/\*\* ]]; then hasdoc=1; break ; fi
27- if [[ " ${lines[$j]} " =~ ^[[:space:]]* $ ]]; then continue ; fi
28- fi
29- done
30- if (( hasdoc == 0 )) ; then
31- echo " ⚠️ Missing Scaladoc: $f :${L%% $' \t ' * } "
32- (( MISS++ ))
11+ scan_file () {
12+ local f=" $1 "
13+ lines=()
14+ while IFS= read -r line; do
15+ lines+=(" $line " )
16+ done < <( nl -ba " $f " )
17+ for (( i= 0 ; i< ${# lines[@]} ; i++ )) ; do
18+ L=" ${lines[$i]} "
19+ # Match top-level public declarations (very simple heuristic)
20+ if [[ " $L " =~ [[:space:]]+[0-9]+[[:space:]]+ (trait| class| object)[[:space:]]+[A-Z][A-Za-z0-9_]* [[:space:]]* \{ ? ]]; then
21+ # Look back a few lines for a /** ... */ opener
22+ hasdoc=0
23+ for b in 1 2 3 4 5; do
24+ j=$(( i- b))
25+ if (( j >= 0 )) ; then
26+ if [[ " ${lines[$j]} " =~ \/\*\* ]]; then hasdoc=1; break ; fi
27+ if [[ " ${lines[$j]} " =~ ^[[:space:]]* $ ]]; then continue ; fi
3328 fi
29+ done
30+ if (( hasdoc == 0 )) ; then
31+ echo " ⚠️ Missing Scaladoc: $f :${L%% $' \t ' * } "
32+ (( MISS++ ))
3433 fi
35- done
36- done < <( find " $r " -type f -path " */src/main/*" -name " *.scala" -print0)
37- done
34+ fi
35+ done
36+ }
37+
38+ if [[ -n " ${DOC_LINT_FILES:- } " ]]; then
39+ while IFS= read -r f; do
40+ [[ -z " $f " ]] && continue
41+ [[ ! -f " $f " ]] && continue
42+ case " $f " in
43+ modules/core/src/main/* |modules/contracts/src/main/* )
44+ scan_file " $f "
45+ ;;
46+ esac
47+ done <<< " ${DOC_LINT_FILES}"
48+ else
49+ for r in " ${ROOTS[@]} " ; do
50+ while IFS= read -r -d ' ' f; do
51+ scan_file " $f "
52+ done < <( find " $r " -type f -path " */src/main/*" -name " *.scala" -print0)
53+ done
54+ fi
3855
3956echo " Doclint: $MISS items missing Scaladoc"
4057if (( MISS > 0 )) ; then
0 commit comments