Skip to content

Commit 3b1bdbd

Browse files
amiclausbuha
authored andcommitted
ci: documentation: Fix project directory structure handling
The documentation check script incorrectly assumed both drivers and projects follow the same directory structure. Projects are organized directly under projects/ but their documentation is categorized under subdirectories in doc/sphinx/source/projects/, while drivers follow the expected structure of drivers/category/driver_name/. This fix handles projects separately by: - Finding the .rst file anywhere under doc/sphinx/source/projects/ - Extracting the category from the actual file location - Checking the appropriate wildcard pattern in projects_doc.rst Fixes: 77d5a55 ("doc: reorganize sphinx docs with subdir categories") Signed-off-by: Alexandra Miclaus <alexandra.miclaus@analog.com>
1 parent f8cc86e commit 3b1bdbd

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

ci/documentation.sh

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,45 @@ check_sphinx_doc() {
6767
local top_dir=$(echo "$file" | cut -d'/' -f1)
6868
local second_dir=$(echo "$file" | cut -d'/' -f2)
6969

70-
# Check if the corresponding .rst file exists in the expected subdirectory
71-
if [ -f "$sphinx_path/$top_dir/$second_dir/$fn_dir.rst" ]; then
72-
# File exists in the expected subdirectory, now check if category is in toctree
73-
wildcard_pattern="$top_dir/$second_dir/\*"
74-
if ! grep -q "$wildcard_pattern" "$sphinx_path/${top_dir}_doc.rst"; then
75-
echo_red "Missing wildcard pattern '$wildcard_pattern' in $sphinx_path/${top_dir}_doc.rst"
70+
# Handle different directory structures for drivers vs projects
71+
if [ "$top_dir" = "projects" ]; then
72+
# Projects are directly under projects/ but docs are categorized
73+
# Find the .rst file anywhere under doc/sphinx/source/projects/
74+
if find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | grep -q .; then
75+
# File exists, find its category and check if wildcard is in toctree
76+
actual_location=$(find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | head -1)
77+
category_dir=$(basename "$(dirname "$actual_location")")
78+
wildcard_pattern="$top_dir/$category_dir/\*"
79+
if ! grep -q "$wildcard_pattern" "$sphinx_path/${top_dir}_doc.rst"; then
80+
echo_red "Missing wildcard pattern '$wildcard_pattern' in $sphinx_path/${top_dir}_doc.rst"
81+
exit 1
82+
fi
83+
else
84+
# File doesn't exist at all
85+
echo_red "Missing $fn_dir.rst file under $sphinx_path/$top_dir"
7686
exit 1
7787
fi
78-
elif find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | grep -q .; then
79-
# File exists but in wrong subdirectory
80-
actual_location=$(find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | head -1)
81-
expected_location="$sphinx_path/$top_dir/$second_dir/$fn_dir.rst"
82-
echo_red "File $fn_dir.rst found at $actual_location but expected at $expected_location"
83-
exit 1
8488
else
85-
# File doesn't exist at all
86-
echo_red "Missing $fn_dir.rst file under $sphinx_path/$top_dir"
87-
exit 1
89+
# For drivers and other top-level directories, use the original logic
90+
# Check if the corresponding .rst file exists in the expected subdirectory
91+
if [ -f "$sphinx_path/$top_dir/$second_dir/$fn_dir.rst" ]; then
92+
# File exists in the expected subdirectory, now check if category is in toctree
93+
wildcard_pattern="$top_dir/$second_dir/\*"
94+
if ! grep -q "$wildcard_pattern" "$sphinx_path/${top_dir}_doc.rst"; then
95+
echo_red "Missing wildcard pattern '$wildcard_pattern' in $sphinx_path/${top_dir}_doc.rst"
96+
exit 1
97+
fi
98+
elif find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | grep -q .; then
99+
# File exists but in wrong subdirectory
100+
actual_location=$(find "$sphinx_path/$top_dir" -name "$fn_dir.rst" -type f | head -1)
101+
expected_location="$sphinx_path/$top_dir/$second_dir/$fn_dir.rst"
102+
echo_red "File $fn_dir.rst found at $actual_location but expected at $expected_location"
103+
exit 1
104+
else
105+
# File doesn't exist at all
106+
echo_red "Missing $fn_dir.rst file under $sphinx_path/$top_dir"
107+
exit 1
108+
fi
88109
fi
89110
fi
90111
done

0 commit comments

Comments
 (0)