Skip to content

Commit fd2c969

Browse files
committed
ci: documentation: Add README.rst validation for new components
Add check_new_components_readme function to validate that new drivers and projects include proper README.rst documentation files. The check examines newly added source files and ensures corresponding README.rst files exist in the component directory structure. Signed-off-by: Antoniu Miclaus <[email protected]>
1 parent 47196a3 commit fd2c969

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

ci/documentation.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,52 @@
3030

3131
COMMIT_RANGE="$1"
3232

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+
3379
#################################################################
3480
# Check if the sphinx documentation is properly linked to the ToC
3581
#################################################################
@@ -173,6 +219,8 @@ update_gh_pages() {
173219

174220
parse_commit_range
175221

222+
check_new_components_readme
223+
176224
check_sphinx_doc
177225

178226
build_doxygen

0 commit comments

Comments
 (0)