### Quick Start for Local Development and Viewing Docs Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/README.md Steps to install dependencies using uv, build the documentation, and open the generated HTML files. Includes commands for both macOS and Linux to open the built documentation. ```bash # Install dependencies uv sync # Build documentation cd docs uv run sphinx-build -b html . _build/html # View the built docs open _build/html/index.html # macOS xdg-open _build/html/index.html # Linux ``` -------------------------------- ### Install Project Dependencies (Shell) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Commands to install project dependencies using pip or uv. These commands are used in conjunction with the pyproject.toml file to set up the Python environment for the documentation project. ```shell pip install . ``` ```shell uv sync ``` -------------------------------- ### Sphinx-Needs Demo: Use needflow for traceability tree Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This example shows how to generate a traceability tree using the '.. needflow::' directive. It is configured to display outgoing links starting from the root ID 'NEED_001' and shows link names. ```default .. needflow:: :root_id: NEED_001 :root_direction: outgoing :show_link_names: ``` -------------------------------- ### Build Sphinx HTML and PDF Documentation (Bash) Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Commands to build HTML and PDF documentation using Sphinx. It covers installation, basic HTML build, force rebuild, viewing the documentation, and building PDF documentation. Uses 'uv' for dependency management. ```bash # Install dependencies using uv uv sync # Build HTML documentation cd docs uv run sphinx-build -b html . _build/html # Build with clean slate (force rebuild) uv run sphinx-build -a -E -b html . _build/html # View generated documentation open _build/html/index.html # macOS xdg-open _build/html/index.html # Linux firefox _build/html/index.html # Windows/Linux # Build PDF documentation env PDF=1 uv run sphinx-build -b simplepdf . _build/pdf # Run with validation enabled uv run sphinx-build -W -b html . _build/html # Warnings as errors ``` -------------------------------- ### Sphinx-Needs Demo: Define a requirement with 'req' directive Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This example shows how to define a requirement using the '.. req::' directive. It includes a custom ID 'REQ_FIRST' for the requirement. ```default .. req:: My requirement :id: REQ_FIRST ``` -------------------------------- ### Define Reusable Schema Components (JSON Schema) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/SCHEMA_VALIDATION.md This JSON snippet shows how to define reusable schema components within the `$defs` section of your `schemas.json`. These definitions, like a common pattern for status enums, can be referenced from other parts of the schema using `$ref`, promoting consistency and reducing redundancy. This example defines a reusable schema for `status` properties. ```json { "$defs": { "my-common-pattern": { "properties": { "status": { "enum": ["open", "closed"] } } } } } ``` -------------------------------- ### Run Sphinx Build with Schema Validation (Bash) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/SCHEMA_VALIDATION.md This bash command executes the Sphinx build process, which includes running schema validation checks. Schema violations and warnings will be displayed in the console output during the build. The `uv run` command suggests the use of a virtual environment manager like `uv`. ```bash cd docs uv run sphinx-build -b html . _build/html ``` -------------------------------- ### Sphinx-Needs Demo: Modify needflow root direction Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This snippet is a modification of the previous 'needflow' example. It changes the 'root_direction' to 'incoming' to visualize incoming links to the specified root ID. ```default .. needflow:: :root_id: NEED_001 :root_direction: incoming :show_link_names: ``` -------------------------------- ### Define Sphinx-Needs Requirements (RST) Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Example of defining requirements, architecture, implementation, and test directives using reStructuredText syntax for Sphinx-Needs. Each directive includes an ID, status, and links to related items, facilitating traceability. ```rst .. req:: Lane Keeping Assistance System :id: SWREQ_001 :status: closed :release: REL_1_0 :asil: B :author: PETER The system shall detect lane markings using forward-facing camera and provide steering assistance to keep the vehicle centered in the lane. .. swarch:: Lane Detection Architecture :id: SWARCH_001 :links: SWREQ_001, SWREQ_002, SWREQ_003 :status: closed Camera input processing pipeline with image segmentation, edge detection, and lane boundary extraction algorithms. .. impl:: Lane Marking Detection Algorithm :id: IMPL_001 :links: SWREQ_001, SWARCH_001 Implements the lane marking detection algorithm using camera inputs. Located in automotive_adas.py:LaneDetection.detect_lane_markings() .. test:: Lane Detection Unit Test :id: TEST_001 :links: SWREQ_001, SWARCH_001 :author: THOMAS Unit tests verify lane marking detection accuracy across various road conditions and lighting scenarios. ``` -------------------------------- ### Build Documentation with uv and sphinx-build Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/README.md Commands to build the documentation locally using uv for dependency management and sphinx-build for rendering HTML output. These commands can be executed from the 'docs' directory or the project root. ```bash # From the docs directory (recommended for development) cd docs uv run sphinx-build -b html . _build/html # Or using the full path from project root uv run sphinx-build -a -E docs docs/_build/html ``` -------------------------------- ### Pedestrian Detection Unit Tests Setup Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/automotive-adas/swe_4_unit_tests.md This snippet represents the setup for unit tests of pedestrian detection functionalities. It is part of the TestCase class and is used to define and organize test cases for the ADAS system. ```python class automotive_adas_tests.TestPedestrianDetection(TestCase): # ... (implementation details) pass ``` -------------------------------- ### Configure PlantUML Integration (Python) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Sets up the configuration for Sphinxcontrib-PlantUML, specifying the local path to the PlantUML JAR file and the desired output format. This allows for the rendering of PlantUML diagrams directly within the Sphinx documentation. ```python local_plantuml_path = os.path.join( os.path.dirname(__file__), "utils", "plantuml-1.2022.14.jar" ) plantuml = f"java -Djava.awt.headless=true -jar {local_plantuml_path}" plantuml_output_format = "svg_img" ``` -------------------------------- ### Configure Preview Features (Python) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Sets up configuration for Sphinx preview features, allowing users to 'sneak' into links. It defines selectors for adding preview icons and excludes specific elements where icons are not desired. The configuration includes options for icon display, click behavior, and dimensions. ```python preview_config = { "selector": "div.md-content a", "not_selector": "div.needs_head a, h1 a, h2 a, a.headerlink, a.md-content__button, a.image-reference, em.sig-param a, a.paginate_button, a.sd-btn", "set_icon": True, "icon_only": True, "icon_click": True, "icon": "🔍", "width": 600, "height": 400, "offset": {"left": 0, "top": 0}, "timeout": 0, } ``` -------------------------------- ### Sphinx Project Configuration (conf.py) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md The main Sphinx configuration file. It sets up project metadata, loads extensions, and configures specific extensions like Sphinx-Needs and Sphinx-Test-Reports. It dynamically adds the 'sphinx_immaterial' theme based on an environment variable. ```python # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html import os import sys import jinja2 # We need to make Python aware of our project source code, which is stored outside `/docs`, # under `src/` code_path = os.path.join(os.path.dirname(__file__), "../", "src/") sys.path.append(code_path) print(f"CODE_PATH: {code_path}") # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "Sphinx-Needs Demo" copyright = "2024, team useblocks" author = "team useblocks" version = "1.0" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration # List of Sphinx extension to use. extensions = [ "sphinx_needs", "sphinx_design", "sphinxcontrib.plantuml", "sphinxcontrib.test_reports", "sphinx_simplepdf", "sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx_preview", ] # During a PDF build with Sphinx-SimplePDF, a special theme is used. # But adding "sphinx_immaterial" to the extension list, the "immaterial" already # does a lot of sphinx voodoo, which is not needed and does not work during a PDF build. # Therefore we add it only, if a special ENV-Var is not set. # # As we can't ask Sphinx already in the config file, which Builder will be used, we need # to set this information by hand, or in this case via an ENV var. # # To build HTML, just call ``make html # To build PDF, call ``env PDF=1 make simplepdf" if os.environ.get("PDF", "0") != "1": extensions.append("sphinx_immaterial") ############################################################################### # SPHINX-NEEDS Config START ############################################################################### # Read the configuration from an external TOML file. # This makes it possible to use ubCode and its tools directly with # the project. Declarative configuration formats are also preferred as they # cannot contain logic and can be consumed by almost all languages. needs_from_toml = "ubproject.toml" ############################################################################### # SPHINX-NEEDS Config END ############################################################################### ############################################################################### # SPHINX-TEST-REPORTS Config START ############################################################################### # Override the default test-case need of Sphinx-Test-Reports, so that is called # ``test_run`` instead. # Docs: https://sphinx-test-reports.readthedocs.io/en/latest/configuration.html#tr-case tr_case = ["test-run", "testrun", "Test-Run", "TR_", "#999999", "node"] ############################################################################### # SPHINX-TEST-REPORTS Config END ############################################################################### ``` -------------------------------- ### Configure HTML Output Theme (Python) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Configures the HTML theme for Sphinx documentation, dynamically selecting between 'alabaster' (default) and 'sphinx_immaterial' based on an environment variable. It also sets the path for static HTML files and includes specific theme options for 'sphinx_immaterial', such as repository URL, editing URI, and feature toggles. ```python html_theme = "alabaster" if os.environ.get("PDF", 0) != 1: html_theme = "sphinx_immaterial" html_static_path = ["_static"] sphinx_immaterial_override_generic_admonitions = True html_logo = "_images/sphinx-needs-logo.png" html_theme_options = { "font": False, "icon": { "repo": "fontawesome/brands/github", "edit": "material/file-edit-outline", }, "site_url": "https://jbms.github.io/sphinx-immaterial/", "repo_url": "https://github.com/useblocks/sphinx-needs-demo", "repo_name": "Sphinx-Needs Demo", "edit_uri": "blob/main/docs", "globaltoc_collapse": False, "features": [ "navigation.expand", "navigation.sections", "navigation.top", "search.highlight", "search.share", "toc.follow", "toc.sticky", "content.tabs.link", "announce.dismiss", ], "palette": [ { "media": "(prefers-color-scheme: light)", "scheme": "default", "primary": "blue", "accent": "light-cyan", }, ], "toc_title_is_page_title": True, } html_css_files = [ "custom.css", ] ``` -------------------------------- ### Running Unit Tests with unittest Framework Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Demonstrates commands for executing the automotive ADAS test suite using Python's unittest framework. It covers running all tests, specific test classes or methods, and options for verbose output. This facilitates efficient testing and debugging of the ADAS components. ```bash # Run all tests python -m unittest src/automotive_adas_tests.py # Run specific test class python -m unittest src.automotive_adas_tests.TestLaneDetection # Run with verbose output python -m unittest -v src/automotive_adas_tests.py # Run single test method python -m unittest src.automotive_adas_tests.TestPedestrianDetection.test_detect_pedestrians # Expected output: # .... # ---------------------------------------------------------------------- # Ran 13 tests in 0.002s # # OK ``` -------------------------------- ### Configure Sphinx-Needs Schema Validation (TOML) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/SCHEMA_VALIDATION.md This TOML snippet configures Sphinx-Needs to use JSON schema definitions for validation. It specifies the schema file, the minimum severity level to report, and whether debug output is active. Ensure `schema_definitions_from_json` points to your actual schema file. ```toml # docs/ubproject.toml [needs] schema_definitions_from_json = "schemas.json" schema_severity = "warning" schema_debug_active = false ``` -------------------------------- ### Sphinx-Needs Demo: Add Playground to Table of Contents Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This code shows how to include the newly created 'playground.rst' file in the main table of contents by adding 'playground' to the '.. toctree::' directive in the 'index.rst' file. ```default .. toctree:: :maxdepth: 2 :caption: Contents: playground ``` -------------------------------- ### Define a New Validation Rule (JSON Schema) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/SCHEMA_VALIDATION.md This JSON snippet demonstrates how to add a new custom validation rule to your `schemas.json` file. It includes an ID for the rule, its severity, a user-facing message, selection criteria (e.g., targeting requirement types), and the validation logic using JSON Schema syntax. The `select` field determines which needs the rule applies to, and `validate` defines the specific checks. ```json { "id": "my-new-rule", "severity": "warning", "message": "Custom validation message", "select": { "$ref": "#/$defs/type-req" }, "validate": { "local": { "properties": { "my_field": { "type": "string", "minLength": 1 } }, "required": ["my_field"] } } } ``` -------------------------------- ### Sphinx-Needs Demo: Create a Playground RST file Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This snippet demonstrates how to create a new reStructuredText file named 'playground.rst' within the 'docs' directory. It includes setting a title for the page. ```default Playground ========== ``` -------------------------------- ### Sphinx-Needs Demo: Define a specification with 'spec' directive and links Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/online_editor.md This snippet demonstrates defining a specification using the '.. spec::' directive. It includes a custom ID 'SPEC_MY' and links it to a previously defined requirement 'REQ_FIRST'. ```default .. spec:: My spec :id: SPEC_MY :links: REQ_FIRST ``` -------------------------------- ### Sphinx-Needs Table Filtering Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/basic_example/index.md This directive creates a table of needs and applies a filter to include only those where the document name is not None and contains 'basic_example'. This is useful for organizing and displaying specific sets of requirements or specifications. ```rst .. needtable:: :filter: docname is not None and "basic_example" in docname ``` -------------------------------- ### GitHub and JIRA Integration Configuration Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Provides a TOML configuration snippet for setting up external service connectors for GitHub and JIRA integration within the project. This configuration enables synchronization of requirements between the project documentation and external platforms, facilitating collaborative development and issue tracking. ```toml # This section is intentionally left empty in the provided text, implying a placeholder for integration configuration. ``` -------------------------------- ### Include Demo Page Details (reStructuredText) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md A reStructuredText template designed to add 'Demo page details' at the top of a page. It utilizes Sphinx directives to include the page's source code, displaying it as a literal block with line numbers, specifically for HTML output. ```rst .. if-builder:: html .. tip:: :title: Demo page details :collapsible: **Page source code: {{page}}** .. literalinclude:: {{page}} :language: rst :linenos: ``` -------------------------------- ### Embed Sphinx-Needs in Python Docstrings Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Demonstrates embedding Sphinx-Needs directives within Python docstrings for automatic documentation generation. The 'impl' directive is used to document implementation details, linking them to requirements and architecture. ```python class AdaptiveCruiseControl: """ .. impl:: Radar-Based Distance Measurement :id: IMPL_004 :links: SWREQ_004, SWARCH_002 Measures distance to the vehicle ahead using radar. """ def measure_distance(self, radar_data): """ .. impl:: Speed Control Integration :id: IMPL_005 :links: SWREQ_005, SWARCH_002 Adjusts vehicle speed dynamically based on radar measurements. """ # Implementation here pass # Sphinx autodoc will extract these directives # Configure in conf.py: ``` -------------------------------- ### Querying and Filtering Needs using Sphinx-Needs Directives Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Illustrates the use of sphinx-needs directives like `needtable`, `needlist`, `needflow`, and `needpie` for visualizing and filtering requirements. These directives allow for dynamic display of needs based on filters, column selections, status visibility, link names, and chart labels, enabling comprehensive requirement analysis and traceability reporting. ```rst .. needtable:: All Open Software Requirements :filter: type == 'swreq' and status == 'open' :columns: id, title, status, release :style: table .. needlist:: :filter: type == 'test' and 'SWREQ_001' in links :show_status: :show_tags: .. needflow:: :filter: id == 'SWREQ_001' :show_link_names: :link_types: implements, specs Traceability flow from requirement through implementation to tests. .. needpie:: :filter: type == 'req' and 'automotive-adas' in docname :labels: status Requirements status distribution pie chart. ``` -------------------------------- ### SWREQ_015: Multi-Object Tracking Requirement Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/automotive-adas/swe_1_sw_req_analysis.md This section details the software requirement for 'Multi-Object Tracking' (SWREQ_015). It serves as a high-level description of the functionality without providing specific implementation details. This requirement is linked to outgoing and incoming system architecture elements. ```text SW_Requirement: **Multi-Object Tracking** [SWREQ_015](#SWREQ_015)

| ``` -------------------------------- ### Filter Sphinx Needs using c.this_docs() - Text Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/automotive-adas/external_data.md This snippet demonstrates how to replace an older filtering method in Sphinx-Needs with the more current `c.this_docs()` method. It specifically targets filtering needs based on the document name. The provided code is in plain text format, outlining the transformation. ```text Replace instances of :filter: docname is not None and "automotive-adas" in docname with :filter: c.this_docs() See: https://sphinx- needs.readthedocs.io/en/latest/filter.html#filtering-for- needs-on-the-current-page ``` -------------------------------- ### Teen Car Autonomous Driving Module (Python) Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt A simplified autonomous driving implementation using the TeenCar library. Includes functionalities for initializing the car, autonomous driving to a target, manual driving with speed limits, and retrieving current position. Dependencies include the 'teen_car' library. ```python from teen_car import TeenCar import time # Initialize teen car with color teen_car = TeenCar(color="#FFCC00") # Drive to target destination autonomously target_address = "123 Main Street, MyTown" teen_car.auto_drive(target=target_address, sleep=0.1) # Manual driving with speed limit max_speed = 100 # km/h teen_car._drive(max_speed=max_speed) # Get current position current_position = teen_car._get_position() print(f"Current location: {current_position}") # Complete autonomous navigation example class TeenCarExample: def __init__(self): self.car = TeenCar(color="#FF5733") def navigate_to_school(self): school_address = "High School, Education District" self.car.auto_drive(target=school_address, sleep=0.05) ``` -------------------------------- ### Configure GitHub Issue Service in TOML Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt This TOML configuration sets up a service for integrating with GitHub Issues. It defines a prefix for generated IDs, limits the amount of data to fetch, sets a maximum number of content lines, and specifies the need type and the GitHub API URL. ```toml [needs.services.github-issues] id_prefix = "GH_ISSUE_" max_amount = 2 max_content_lines = 20 need_type = "swreq" url = "https://api.github.com/" ``` -------------------------------- ### Sphinx-Needs Needflow Filtering Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/basic_example/index.md This directive generates a needflow visualization based on a filter. The filter ensures that only needs from documents containing 'basic_example' in their name are included in the flow diagram. This helps visualize relationships within a specific subset of project documentation. ```rst .. needflow:: :filter: docname is not None and "basic_example" in docname ``` -------------------------------- ### Display Object Traceability Details (reStructuredText) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md A reStructuredText template using Sphinx-Needs directives to display object traceability information. It conditionally renders a warning box with details like title, ID, and related links/authors, intended for HTML output. ```rst .. if-builder:: html .. warning:: :title: Object traceability details: {{title}} :collapsible: .. needflow:: :filter: "{{id}}"==id or "{{id}}" in links or "{{id}}" in links_back or "{{id}}" in author_back .. needtable:: :style: table :filter: "{{id}}"==id or "{{id}}" in links or "{{id}}" in links_back or "{{id}}" in author_back :columns: id, title, type, author ``` -------------------------------- ### Configure GitHub Pull Request Service in TOML Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt This TOML configuration sets up a service for integrating with GitHub Pull Requests. It defines a prefix for generated IDs, limits the amount of data to fetch, sets a maximum number of content lines, and specifies the need type and the GitHub API URL. ```toml [needs.services.github-prs] id_prefix = "GH_PR_" max_amount = 2 max_content_lines = 20 need_type = "impl" url = "https://api.github.com/" ``` -------------------------------- ### Pedestrian Detection and Protection - Python Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Utilizes sensor fusion for pedestrian detection, path prediction, and emergency braking initiation. Includes functions for driver alerts. ```python from automotive_adas import PedestrianDetection # Initialize pedestrian detection system pedestrian_detection = PedestrianDetection() # Detect pedestrians using camera and sensor fusion sensor_data = { 'camera_objects': [ {'type': 'pedestrian', 'position': (10, 5), 'confidence': 0.92} ], 'thermal_sensor': {'heat_signatures': 1}, 'lidar_points': [...] } pedestrians = pedestrian_detection.detect_pedestrians(sensor_data) # Alert driver of detected pedestrians if pedestrians: pedestrian_detection.alert_driver() # Predict pedestrian trajectory if collision_predicted: pedestrian_detection.initiate_emergency_brake() ``` -------------------------------- ### Configure Needs Constraints in Python Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_hints/constraints.rst This Python code snippet demonstrates how to define custom constraints for Sphinx-Needs within the Sphinx configuration file (conf.py). It shows the structure for defining constraint checks, severity levels, and error messages. These constraints help ensure requirements meet specific criteria, such as having a valid status and a linked release. ```python needs_constraints = { "status_set": { "check_0": "status is not None and status in ['open', 'in progress', 'closed']", "severity": "LOW", "error_message": "Status is invalid or not set!" }, "release_set": { "check_0": "len(release)>0", "severity": "CRITICAL", "error_message": "Requirement is not planned for any release!" }, } ``` -------------------------------- ### Configure GitHub String Link in TOML Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt This TOML configuration defines a custom string link for GitHub issues within the 'sphinx-needs-demo' repository. It specifies the link name format, the URL pattern for the GitHub issue, associated options, and a regular expression to extract the issue ID. ```toml [needs.string_links.github_link] link_name = "SN Demo #{{value}}" link_url = "https://github.com/useblocks/sphinx-needs-demo/issues/{{value}}" options = ["github"] regex = "^(?P\\w+)$" ``` -------------------------------- ### Define Template Paths and Exclusions (Python) Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Specifies the path for Sphinx templates and lists files and folders to be excluded from the build process. This is useful for managing template files and preventing unwanted content from being included in the final documentation. ```python templates_path = ["_templates"] exclude_patterns = [ "_build", "Thumbs.db", ".DS_Store", "demo_page_header.rst", "demo_hints", ] ``` -------------------------------- ### Defining Link Types for Need Traceability Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Configures relationships between different need types using TOML in `docs/ubproject.toml` to establish traceability. It defines options like 'reqs', 'implements', 'specs', 'release', and 'mitigates', specifying incoming and outgoing link names and colors. This facilitates clear visualization of dependencies between specifications, requirements, implementations, tests, safety goals, and hazards. ```toml # docs/ubproject.toml [[needs.extra_links]] # spec -> req option = "reqs" incoming = "specified by" outgoing = "specifies" [[needs.extra_links]] # impl -> spec option = "implements" incoming = "implemented by" outgoing = "implements" [[needs.extra_links]] # test_case -> spec option = "specs" incoming = "test_cases" outgoing = "specs" [[needs.extra_links]] # req -> release option = "release" incoming = "contains" outgoing = "release" [[needs.extra_links]] # safety_goal -> hazard option = "mitigates" incoming = "mitigated by" outgoing = "mitigates" color = "#DC143C" ``` -------------------------------- ### Lane Detection System - Python Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Implements lane marking detection, deviation warnings, and steering correction for lane-keeping assistance using a camera feed. Includes unit tests for `detect_lane_markings`. ```python from automotive_adas import LaneDetection # Initialize lane detection system lane_detection = LaneDetection() # Process camera feed to detect lane markings camera_feed = "camera_input_stream" lane_markings = lane_detection.detect_lane_markings(camera_feed) # Apply steering correction based on detected lane position lane_data = { 'left_boundary': 0.5, 'right_boundary': 3.5, 'current_position': 2.2, 'deviation': 0.3 } correction = lane_detection.apply_steering_correction(lane_data) # Test implementation import unittest class TestLaneDetection(unittest.TestCase): def test_detect_lane_markings(self): ld = LaneDetection() result = ld.detect_lane_markings(camera_feed="mock_feed") self.assertTrue(result) ``` -------------------------------- ### Adaptive Cruise Control - Python Source: https://context7.com/useblocks/sphinx-needs-demo/llms.txt Provides radar-based distance measurement and automatic speed adjustment for maintaining safe following distances. Includes unit tests for `measure_distance` and `adjust_speed`. ```python from automotive_adas import AdaptiveCruiseControl # Initialize adaptive cruise control acc = AdaptiveCruiseControl() # Measure distance to vehicle ahead using radar radar_data = { 'range': 50.0, # meters 'relative_velocity': -5.0, # m/s 'object_detected': True } distance = acc.measure_distance(radar_data) # Adjust vehicle speed based on traffic conditions target_speed = 60 # km/h acc.adjust_speed(target_speed) # Unit testing example class TestAdaptiveCruiseControl(unittest.TestCase): def test_measure_distance(self): acc = AdaptiveCruiseControl() result = acc.measure_distance(radar_data="mock_radar") self.assertTrue(result) def test_adjust_speed(self): acc = AdaptiveCruiseControl() result = acc.adjust_speed(target_speed=60) self.assertTrue(result) ``` -------------------------------- ### MyST Markdown Configuration Source: https://github.com/useblocks/sphinx-needs-demo/blob/main/docs/demo_details.md Configuration settings for MyST Markdown, controlling aspects like heading anchors, external link behavior, and suppressing specific warnings during the build process. These settings tailor how MyST Markdown is parsed and rendered within Sphinx. ```python myst_heading_anchors = 3 myst_all_links_external = False suppress_warnings = ['myst.xref_missing', 'myst.header'] ```