|
1 | | -# ROS 2 Medkit Gateway - Architecture Documentation |
| 1 | +# Documentation Development Guide |
2 | 2 |
|
3 | | -This directory contains design documentation for the ros2_medkit_gateway project. |
| 3 | +This directory contains the Sphinx-based documentation for the `ros2_medkit` project. |
4 | 4 |
|
5 | | -## Architecture Diagram |
| 5 | +## Prerequisites |
6 | 6 |
|
7 | | -The `architecture.puml` file contains a PlantUML class diagram showing the relationships between the main components of the gateway. |
| 7 | +* **Python 3.12+** |
| 8 | +* **PlantUML** and **Graphviz** (for generating diagrams) |
8 | 9 |
|
9 | | -### Main Components |
| 10 | +### Installing System Dependencies (Ubuntu/Debian) |
10 | 11 |
|
11 | | -1. **GatewayNode** - The main ROS 2 node that orchestrates the system |
12 | | - - Extends `rclcpp::Node` |
13 | | - - Manages periodic discovery and cache refresh |
14 | | - - Runs the REST server in a separate thread |
15 | | - - Provides thread-safe access to the entity cache |
| 12 | +```bash |
| 13 | +sudo apt-get update |
| 14 | +sudo apt-get install -y graphviz plantuml |
| 15 | +``` |
16 | 16 |
|
17 | | -2. **DiscoveryManager** - Discovers ROS 2 entities and maps them to the SOVD hierarchy |
18 | | - - Discovers Areas from node namespaces |
19 | | - - Discovers Components from nodes, topics, and services |
20 | | - - Extracts the entity hierarchy from the ROS 2 graph |
| 17 | +## Setup |
21 | 18 |
|
22 | | -3. **RESTServer** - Provides the HTTP/REST API |
23 | | - - Serves endpoints: `/health`, `/`, `/areas`, `/components`, `/areas/{area_id}/components` |
24 | | - - Retrieves cached entities from the GatewayNode |
25 | | - - Runs on configurable host and port |
| 19 | +It is recommended to use a virtual environment for building the documentation. |
26 | 20 |
|
27 | | -4. **Data Models** - Entity representations |
28 | | - - `Area` - Physical or logical domain |
29 | | - - `Component` - Hardware or software component |
30 | | - - `EntityCache` - Thread-safe cache of discovered entities |
31 | | - |
| 21 | +1. Create a virtual environment: |
| 22 | + ```bash |
| 23 | + python3 -m venv .venv |
| 24 | + source .venv/bin/activate |
| 25 | + ``` |
| 26 | + |
| 27 | +2. Install Python dependencies: |
| 28 | + ```bash |
| 29 | + pip install -e .[dev] |
| 30 | + ``` |
| 31 | + |
| 32 | +## Building Documentation |
| 33 | + |
| 34 | +To build the HTML documentation, run the following command from the `docs` directory: |
| 35 | + |
| 36 | +```bash |
| 37 | +sphinx-build -b html . _build/html |
| 38 | +``` |
| 39 | + |
| 40 | +The generated HTML files will be located in `_build/html/index.html`. |
| 41 | + |
| 42 | +## Live Preview (Development Mode) |
| 43 | + |
| 44 | +For a better development experience, you can use `sphinx-autobuild` to automatically rebuild the documentation and refresh your browser when you make changes. |
| 45 | + |
| 46 | +1. Ensure you are in the `docs` directory and your virtual environment is activated: |
| 47 | + |
| 48 | + ```bash |
| 49 | + # Assuming you are in the project root |
| 50 | + cd docs |
| 51 | + source .venv/bin/activate |
| 52 | + ``` |
| 53 | + |
| 54 | +2. Run the auto-build server: |
| 55 | + |
| 56 | + ```bash |
| 57 | + sphinx-autobuild . _build/html --port 8000 --host 0.0.0.0 |
| 58 | + ``` |
| 59 | + |
| 60 | +Then open [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser. |
| 61 | + |
| 62 | +## Directory Structure |
| 63 | + |
| 64 | +* `pyproject.toml`: Project configuration and dependencies. |
| 65 | +* `conf.py`: Sphinx configuration file. |
| 66 | +* `index.rst`: Main entry point for the documentation. |
| 67 | +* `requirements/`: Contains requirements specifications (split by category). |
| 68 | +* `design/`: Contains design documentation and PlantUML diagrams. |
| 69 | +* `_static/`: Custom static files (CSS, JS). |
| 70 | +* `_templates/`: Custom templates. |
| 71 | + |
| 72 | +## Adding New Requirements |
| 73 | + |
| 74 | +Requirements are managed using `sphinx-needs`. To add a new requirement: |
| 75 | + |
| 76 | +1. Identify the appropriate file in `requirements/` (e.g., `core.rst`, `system.rst`). |
| 77 | +2. Add a new `.. req::` directive: |
| 78 | + |
| 79 | + ```rst |
| 80 | + .. req:: Requirement Title |
| 81 | + :id: REQ_CATEGORY_XXX |
| 82 | + :status: open |
| 83 | + :tags: P |
| 84 | +
|
| 85 | + Description of the requirement. |
| 86 | + ``` |
| 87 | + |
| 88 | +## CI/CD |
| 89 | + |
| 90 | +The documentation is automatically built and deployed to GitHub Pages via GitHub Actions. The workflow is defined in `.github/workflows/docs.yml`. |
0 commit comments