Detail Design Document #4
Replies: 5 comments
-
Ok, so here is how the documentation is generated in the demo (DDD):
""" Implements the lane marking detection algorithm using camera inputs.
This tells Sphinx to extract and include the docstrings (with the embedded Sphinx-Needs objects) from the automotive_adas Python module.
|
Beta Was this translation helpful? Give feedback.
-
sphinx-rust does not have a direct equivalent of .. automodule::. You cannot just point to a Rust crate or module and have all public items and their doc comments imported and rendered with one directive. Instead, you have to explicitly document each module, struct, enum, or function using the provided directives:
These directives will extract doc comments for each item, but you must list them manually. |
Beta Was this translation helpful? Give feedback.
-
ObjectiveI've tried out to build a custom Sphinx extension that would automatically extract "needs objects" from Rust source code (specifically, from annotated Rust doc comments) and make them available as structured documentation elements in the generated docs. This is inspired by the workflow used in Python codebases, where docstrings can be parsed for such objects using Sphinx extensions like Goals
Approach
Key Implementation Details
Troubleshooting and Status
Next Steps
Example Reference Usage.. toctree::
:maxdepth: 1
ddd
----
See :need:`dd_sta__kvs_design` for the static detailed design extracted from the source code. Links and Related Work |
Beta Was this translation helpful? Give feedback.
-
It turns out the |
Beta Was this translation helpful? Give feedback.
-
🧩Using
|
Feature | Python (autodoc ) |
Rust (needextract :file: ) |
---|---|---|
Language Support | Python only | Any (Rust, YAML, etc.) |
Uses real imports | ✅ Yes | ❌ No |
Interprets type signatures | ✅ Yes | ❌ No |
Extracts docstring | ✅ Yes | ✅ Yes (via NEEDS fields) |
Supports [source] links |
✅ Via sphinx.ext.viewcode |
❌ Use manual source= field |
Native API doc generation | ✅ | ❌ Use cargo doc instead |
❌ sphinx.ext.viewcode
Doesn’t Work for Rust
- Only works with Python modules
- Requires the code to be importable into Python
- Doesn’t recognize or parse
.rs
files
Use needs_extra_options
with source=
instead.
🛠️ Optional Tools for Advanced Rust Doc Integration
Tool | Purpose | Notes |
---|---|---|
cargo doc |
Native Rust API documentation | Recommended for full API docs |
sphinx-needs |
Traceability, requirements, metadata | Best for structured documentation |
Doxygen + Breathe |
Parse Rust code as C-like syntax | Advanced setup with doxyfilter-rust |
literalinclude |
Embed Rust code snippets | Pure Sphinx feature, syntax-highlighted |
📁 Example Project Structure
my-docs/
├── docs/
│ ├── index.rst
│ ├── conf.py
├── rust_src/
│ └── auth.rs
└── requirements.txt
auth.rs
/// NEEDS:id=REQ-LOGIN
/// NEEDS:title=User login functionality
/// NEEDS:status=approved
/// NEEDS:source=https://github.com/myorg/mycrate/blob/main/src/auth.rs#L10
pub fn login_user(...) { ... }
index.rst
.. needextract:: ../rust_src/auth.rs
:file:
:filter: NEEDS:
conf.py
extensions = ['sphinx_needs']
needs_extra_options = ["source"]
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to start a discussion on how we can best structure detail design documentation using Sphinx-Needs.
Maybe we can use as a reference this demo
https://sphinx-needs-demo.readthedocs.io/en/latest/automotive-adas/swe_3_sw_detailed_design.html
Beta Was this translation helpful? Give feedback.
All reactions