Reference Docs in Source Code#
In your C++/Rust/Python source code, you want to reference requirements (needs). The docs-as-code tool will create backlinks in the documentation in two steps:
You add a special comment in your source code that references the need ID.
Scan for those comments and provide needs links to your documentation.
For an example result, look at the attribute source_code_link
of Enforces title wording rules (tool_req__docs_common_attr_title).
Scanning Source Code for Links#
In you BUILD files, you specify which source files to scan
with filegroup or glob or whatever Bazel mechanism you prefer.
Finally, pass the scan results to the docs rule as scan_code attribute.
1filegroup(
2 name = "some_sources",
3 srcs = [
4 "foo.py",
5 "bar.cpp",
6 "data.yaml",
7 ] + glob(["subdir/**/.py"]),
8)
9
10docs(
11 data = [
12 "@score_process//:needs_json",
13 ],
14 source_dir = "docs",
15 scan_code = [":some_sources"],
16)
Comments in Source Code#
Use a comment and start with
req-Id:orreq-traceability:followed by the need ID.For other languages (C++, Rust, etc.), use the appropriate comment syntax.