|
30 | 30 |
|
31 | 31 | COMMIT_RANGE="$1" |
32 | 32 |
|
| 33 | +################################################################# |
| 34 | +# Check if new drivers/projects have README.rst files |
| 35 | +################################################################# |
| 36 | +check_new_components_readme() { |
| 37 | + echo_green "Checking for new drivers/projects and their README.rst files..." |
| 38 | + |
| 39 | + # Get all added files only |
| 40 | + git diff --name-only --diff-filter=A $COMMIT_RANGE | while read -r file; do |
| 41 | + # Check if this is a file in drivers/ or projects/ directory |
| 42 | + if [[ "$file" == drivers/*/* ]] || [[ "$file" == projects/* ]]; then |
| 43 | + local top_dir=$(echo "$file" | cut -d'/' -f1) |
| 44 | + local component_dir="" |
| 45 | + |
| 46 | + if [ "$top_dir" = "drivers" ]; then |
| 47 | + # For drivers: drivers/category/driver_name/... |
| 48 | + local category=$(echo "$file" | cut -d'/' -f2) |
| 49 | + component_dir=$(echo "$file" | cut -d'/' -f3) |
| 50 | + local component_path="drivers/$category/$component_dir" |
| 51 | + elif [ "$top_dir" = "projects" ]; then |
| 52 | + # For projects: projects/project_name/... |
| 53 | + component_dir=$(echo "$file" | cut -d'/' -f2) |
| 54 | + local component_path="projects/$component_dir" |
| 55 | + fi |
| 56 | + |
| 57 | + # Skip if we can't determine component directory |
| 58 | + if [ -z "$component_dir" ]; then |
| 59 | + continue |
| 60 | + fi |
| 61 | + |
| 62 | + # Check if this appears to be a new component (has source files) |
| 63 | + if [[ "$file" == *".c" ]] || [[ "$file" == *".h" ]] || [[ "$file" == "Makefile" ]]; then |
| 64 | + # Check if README.rst exists in the component directory |
| 65 | + local readme_path="$component_path/README.rst" |
| 66 | + |
| 67 | + if [ ! -f "$readme_path" ]; then |
| 68 | + echo_red "ERROR: New component '$component_dir' in '$top_dir' is missing README.rst file" |
| 69 | + echo_red "Please add a README.rst file at: $readme_path" |
| 70 | + exit 1 |
| 71 | + else |
| 72 | + echo_green "Found README.rst for new component: $component_dir" |
| 73 | + fi |
| 74 | + fi |
| 75 | + fi |
| 76 | + done |
| 77 | +} |
| 78 | + |
33 | 79 | ################################################################# |
34 | 80 | # Check if the sphinx documentation is properly linked to the ToC |
35 | 81 | ################################################################# |
@@ -173,6 +219,8 @@ update_gh_pages() { |
173 | 219 |
|
174 | 220 | parse_commit_range |
175 | 221 |
|
| 222 | +check_new_components_readme |
| 223 | + |
176 | 224 | check_sphinx_doc |
177 | 225 |
|
178 | 226 | build_doxygen |
|
0 commit comments