Files
RTOS/scripts/generate_docs.sh
T
root ca13734bf0 Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers,
middleware (CAN stack, diagnostics, safety), applications, board
support, build/test tooling, and documentation.
2026-08-23 03:35:29 -04:00

271 lines
6.6 KiB
Bash
Executable File

#!/bin/bash
/**
* @file generate_docs.sh
* @brief Generate documentation for Automotive RTOS
*/
set -e
# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Documentation directories
DOCS_DIR="${PROJECT_ROOT}/docs"
BUILD_DOCS_DIR="${PROJECT_ROOT}/build/docs"
DOXYGEN_DIR="${BUILD_DOCS_DIR}/doxygen"
HTML_DIR="${DOXYGEN_DIR}/html"
PDF_DIR="${DOXYGEN_DIR}/pdf"
# Print banner
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} Documentation Generator${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Check for doxygen
check_doxygen() {
if ! command -v doxygen >/dev/null 2>&1; then
echo -e "${YELLOW}Doxygen not found. Installing...${NC}"
sudo apt-get install -y doxygen graphviz
fi
}
# Check for other tools
check_tools() {
# LaTeX for PDF generation
if ! command -v pdflatex >/dev/null 2>&1; then
echo -e "${YELLOW}LaTeX not found. PDF generation will be skipped.${NC}"
GENERATE_PDF=false
else
GENERATE_PDF=true
fi
# Graphviz for diagrams
if ! command -v dot >/dev/null 2>&1; then
echo -e "${YELLOW}Graphviz not found. Installing...${NC}"
sudo apt-get install -y graphviz
fi
}
# Generate doxygen configuration
generate_doxygen_config() {
echo -e "${YELLOW}Generating Doxygen configuration...${NC}"
cat > "${BUILD_DOCS_DIR}/Doxyfile" << EOF
# Doxygen configuration for Automotive RTOS
# Project information
PROJECT_NAME = "Automotive RTOS"
PROJECT_NUMBER = "1.0.0"
PROJECT_BRIEF = "Real-time operating system for automotive applications"
OUTPUT_DIRECTORY = ${DOXYGEN_DIR}
# Source files
INPUT = ${PROJECT_ROOT}/kernel \
${PROJECT_ROOT}/drivers \
${PROJECT_ROOT}/middleware \
${PROJECT_ROOT}/applications \
${PROJECT_ROOT}/config \
${PROJECT_ROOT}/board \
${PROJECT_ROOT}/README.md
# Include paths
INCLUDE_PATH = ${PROJECT_ROOT}/kernel/include \
${PROJECT_ROOT}/drivers/include \
${PROJECT_ROOT}/middleware \
${PROJECT_ROOT}/config
# File patterns
FILE_PATTERNS = *.c *.h *.md
RECURSIVE = YES
# Output formats
GENERATE_HTML = YES
GENERATE_LATEX = ${GENERATE_PDF}
GENERATE_RTF = NO
GENERATE_XML = YES
GENERATE_MAN = NO
# HTML output
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
GENERATE_TREEVIEW = YES
DISPLAY_GRAPH = YES
# LaTeX output
LATEX_OUTPUT = pdf
COMPACT_LATEX = YES
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
# Diagrams
HAVE_DOT = YES
DOT_GRAPH_MAX_NODES = 50
CALL_GRAPH = YES
CALLER_GRAPH = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
# Code documentation
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
# Warnings
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = YES
# Source browser
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
# Search engine
SEARCHENGINE = YES
SERVER_BASED_SEARCH = NO
# Colors
HTML_COLORSTYLE_HUE = 220
HTML_COLORSTYLE_SAT = 100
HTML_COLORSTYLE_GAMMA = 80
EOF
echo -e "${GREEN}✓ Doxygen configuration generated${NC}"
}
# Generate API documentation
generate_api_docs() {
echo -e "${YELLOW}Generating API documentation...${NC}"
mkdir -p "${DOCS_DIR}/api"
# Extract function documentation from headers
for header in "${PROJECT_ROOT}"/kernel/include/*.h; do
if [ -f "$header" ]; then
basename=$(basename "$header" .h)
output="${DOCS_DIR}/api/${basename}.md"
echo "# ${basename} API Documentation" > "$output"
echo "" >> "$output"
echo "Auto-generated documentation for ${header}" >> "$output"
echo "" >> "$output"
# Extract function prototypes
grep -E "^(KernelStatus_t|void|uint|int|bool|float|TaskHandle_t)" "$header" | \
while read -r line; do
echo "\`\`\`c" >> "$output"
echo "$line" >> "$output"
echo "\`\`\`" >> "$output"
echo "" >> "$output"
done
fi
done
echo -e "${GREEN}✓ API documentation generated${NC}"
}
# Generate architecture documentation
generate_architecture_docs() {
echo -e "${YELLOW}Generating architecture documentation...${NC}"
mkdir -p "${DOCS_DIR}/architecture"
cat > "${DOCS_DIR}/architecture/system_overview.md" << 'EOF'
# System Architecture Overview
## Introduction
The Automotive RTOS is designed for safety-critical automotive applications.
It provides deterministic real-time performance with priority-based preemptive scheduling.
## System Layers
1. **Application Layer**
- Engine Control
- Brake Control
- Body Control
- Dashboard
2. **Middleware Layer**
- CAN Stack (ISO 15765-2)
- Network Management
- Diagnostics (UDS, OBD-II)
- Safety Features
3. **Driver Layer**
- CAN Driver
- UART Driver
- SPI Driver
- I2C Driver
- GPIO Driver
- ADC Driver
- PWM Driver
4. **Kernel Layer**
- Task Management
- Scheduler
- Synchronization
- Memory Management
- Interrupt Handling
## Design Principles
- Deterministic scheduling
- Priority inheritance
- Memory protection
- Stack overflow detection
- Fault tolerance
- Watchdog integration
- E2E protection
## Safety Features
- ISO 26262 compliance
- ASIL-D ready
- Redundancy support
- Fault detection
- Safe state management
EOF
echo -e "${GREEN}✓ Architecture documentation generated${NC}"
}
# Generate user guide
generate_user_guide() {
echo -e "${YELLOW}Generating user guide...${NC}"
mkdir -p "${DOCS_DIR}/user_guide"
cat > "${DOCS_DIR}/user_guide/getting_started.md" << 'EOF'
# Getting Started Guide
## Prerequisites
- ARM GCC toolchain
- CMake 3.10+
- Make
- Git
## Installation
1. Clone repository:
```bash
git clone https://github.com/automotive-rtos/rtos.git
cd rtos