Skip to content

Commit bb88d52

Browse files
authored
📚 Add traceability to documentation (#47)
1 parent 83bcb95 commit bb88d52

23 files changed

+457
-11
lines changed

docs/source/basics/quickstart.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Sphinx Config
2727
:caption: src_trace.toml
2828
:language: toml
2929

30-
3130
One-line comment
3231
----------------
3332

docs/source/components/discover.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Source Discover
66
SourceDiscover is one of the modules provided in ``Codelinks``. It discovers the source files from the given directory.
77
It provides users CLI and API to discover the source files.
88

9-
109
Usage Examples
1110
--------------
1211

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
Features
2+
========
3+
4+
.. dropdown:: 🔍 Features
5+
6+
.. needtable::
7+
:filter: type == "feature"
8+
:columns: id, title, si as "SI", parent_needs_back as "Errors"
9+
10+
.. feature:: Define new traceability objects in source code
11+
:id: FE_DEF
12+
13+
Create new Sphinx-Needs directly from a single comment line in your source code.
14+
This feature enables developers to maintain traceability information right at the point
15+
of implementation, ensuring that requirements, specifications, and code remain synchronized.
16+
17+
By embedding traceability markers in comments, you can:
18+
19+
* Define requirements, specifications, or test cases directly in source files
20+
* Automatically generate documentation from code comments
21+
* Maintain bidirectional links between documentation and implementation
22+
* Track coverage of requirements by implementation
23+
24+
.. fault:: Traceability objects are not detected in supported languages
25+
:id: FAULT_1
26+
27+
.. fault:: Sphinx-codelinks halucinates traceability objects
28+
:id: FAULT_2
29+
30+
.. feature:: Discover Source Code Files
31+
:id: FE_DISCOVERY
32+
33+
Discover source code files in a specified root directory.
34+
The root directory shall be configurable.
35+
36+
.. feature:: C Language Support
37+
:id: FE_C_SUPPORT
38+
39+
Support for defining traceability objects in C source code.
40+
41+
The C language parser leverages tree-sitter to accurately identify and extract
42+
comments from C source files, including both single-line (``//``) and multi-line
43+
(``/* */``) comment styles. This ensures that traceability markers are correctly
44+
associated with the appropriate code structures such as functions, structs, and
45+
global definitions.
46+
47+
Key capabilities:
48+
49+
* Detection of inline and block comments
50+
* Association of comments with function definitions
51+
* Support for standard C comment conventions
52+
* Accurate scope detection for nested structures
53+
54+
.. fault:: Traceability objects are not detected in C language
55+
:id: FAULT_C_1
56+
57+
.. fault:: Sphinx-codelinks halucinates traceability objects in C
58+
:id: FAULT_C_2
59+
60+
.. feature:: C++ Language Support
61+
:id: FE_CPP
62+
63+
Support for defining traceability objects in C++ source code.
64+
65+
Building upon C language support, the C++ parser handles the full complexity of modern
66+
C++ syntax including classes, namespaces, templates, and advanced features. The tree-sitter
67+
based parser ensures accurate comment extraction and scope detection across various C++
68+
constructs.
69+
70+
Enhanced features for C++:
71+
72+
* Class and namespace scope detection
73+
* Support for C++ style comments (``//``) and C style comments (``/* */``)
74+
* Template and method declaration handling
75+
* Accurate association with member functions and constructors
76+
* Support for modern C++ features (C++11/14/17/20)
77+
78+
.. fault:: Traceability objects are not detected in C++ language
79+
:id: FAULT_CPP_1
80+
81+
.. fault:: Sphinx-codelinks halucinates traceability objects in C++
82+
:id: FAULT_CPP_2
83+
84+
.. feature:: Python Language Support
85+
:id: FE_PY
86+
87+
Support for defining traceability objects in Python source code.
88+
89+
The Python language parser provides comprehensive support for Python's unique comment
90+
and docstring conventions. It can extract traceability markers from both standard
91+
comments (``#``) and docstrings (triple-quoted strings), making it ideal for Python's
92+
documentation-driven development practices.
93+
94+
Python-specific capabilities:
95+
96+
* Hash-style comment (``#``) detection
97+
* Docstring extraction from modules, classes, and functions
98+
* Proper handling of multi-line comments and docstrings
99+
* Scope detection for functions, classes, and methods
100+
* Support for nested class and function definitions
101+
* Integration with Python's natural documentation patterns
102+
103+
.. fault:: Traceability objects are not detected in Python language
104+
:id: FAULT_PY_1
105+
106+
.. fault:: Sphinx-codelinks halucinates traceability objects in Python
107+
:id: FAULT_PY_2
108+
109+
.. feature:: YAML Language Support
110+
:id: FE_YAML
111+
112+
Support for defining traceability objects in YAML configuration files.
113+
114+
The YAML language parser provides comprehensive support for YAML's structure
115+
and comment conventions. It can extract traceability markers from YAML comments
116+
(``#``) and properly associate them with YAML structures including key-value pairs,
117+
list items, and nested configurations, making it ideal for documenting configuration
118+
files, CI/CD pipelines, and infrastructure definitions.
119+
120+
YAML-specific capabilities:
121+
122+
* Hash-style comment (``#``) detection
123+
* Inline comment support with proper structure association
124+
* Block comment detection and association
125+
* Scope detection for block mapping pairs and sequence items
126+
* Support for nested YAML structures
127+
* Document structure handling with ``---`` separators
128+
* Accurate association of inline comments with their corresponding structures
129+
* Flow and block mapping/sequence support
130+
131+
.. fault:: Traceability objects are not detected in YAML language
132+
:id: FAULT_YAML_1
133+
134+
.. fault:: Sphinx-codelinks halucinates traceability objects in YAML
135+
:id: FAULT_YAML_2
136+
137+
.. feature:: Customized comment styles
138+
:id: FE_CMT
139+
140+
Support for different customized comment styles in source code.
141+
The comment structure can be defined in the configuration file.
142+
143+
This feature provides flexibility to adapt Sphinx-Codelinks to your project's
144+
existing coding standards and conventions. Define custom markers, prefixes, and
145+
delimiters that match your team's documentation practices without requiring code
146+
changes.
147+
148+
Configuration options include:
149+
150+
* Custom marker syntax (e.g., ``@req``, ``#TODO``, ``//!``)
151+
* Configurable comment prefixes and delimiters
152+
* Support for language-specific comment conventions
153+
* Flexible pattern matching for traceability markers
154+
* Per-project customization via configuration files
155+
156+
.. fault:: Customized comment styles are not detected in supported languages
157+
:id: FAULT_CMT
158+
159+
.. feature:: Link code to existing need items
160+
:id: FE_LNK
161+
162+
Link code to existing need items without creating new ones, perfect for tracing
163+
implementations to requirements.
164+
165+
This feature enables you to establish connections between your source code and
166+
existing documentation or requirements defined elsewhere in your Sphinx-Needs
167+
documentation. Instead of creating duplicate need objects, you can simply reference
168+
existing ones, maintaining a clean and organized traceability structure.
169+
170+
Linking capabilities:
171+
172+
* Reference existing requirements, specifications, or test cases by ID
173+
* Create bidirectional links between code and documentation
174+
* Avoid duplication of traceability information
175+
* Support for multiple links from a single code location
176+
* Automatic validation of link targets
177+
* Integration with Sphinx-Needs link visualization
178+
179+
.. fault:: Linking code to existing need items fails
180+
:id: FAULT_LNK_1
181+
182+
.. fault:: Sphinx-codelinks links code to wrong need items
183+
:id: FAULT_LNK_2
184+
185+
.. feature:: Extract blocks of reStructuredText embedded within comments
186+
:id: FE_RST_EXTRACTION
187+
188+
Extract blocks of reStructuredText embedded within comments, allowing you to
189+
include rich documentation with associated metadata right next to your code.
190+
191+
This powerful feature enables you to write full reStructuredText content directly
192+
in your source code comments, which will be extracted and processed as part of
193+
your Sphinx documentation. This approach brings documentation closer to implementation,
194+
making it easier to keep both synchronized.
195+
196+
reStructuredText extraction features:
197+
198+
* Full reStructuredText syntax support within comments
199+
* Extraction of formatted documentation blocks
200+
* Support for directives, roles, and inline markup
201+
* Preservation of indentation and formatting
202+
* Integration with Sphinx-Needs directives
203+
* Markers for block start (``@rst``) and end (``@endrst``)
204+
* Single-line and multi-line RST blocks
205+
206+
.. fault:: Extracting reStructuredText from comments fails
207+
:id: FAULT_RST_EXTRACTION_1
208+
209+
.. fault:: Sphinx-codelinks extracts wrong reStructuredText blocks
210+
:id: FAULT_RST_EXTRACTION_2
211+
212+
.. fault:: Extracted reStructuredText blocks are malformed
213+
:id: FAULT_RST_EXTRACTION_3
214+
215+
.. feature:: Analyze marked content via CLI interface
216+
:id: FE_CLI_ANALYZE
217+
218+
It shall be possible to analyze marked content via the CLI interface.
219+
220+
The command-line interface provides powerful tools for analyzing and reporting on
221+
traceability markers in your codebase without requiring a full Sphinx build. This
222+
enables quick validation, continuous integration checks, and standalone reporting.
223+
224+
CLI analysis capabilities:
225+
226+
* Scan source files for traceability markers
227+
* Generate reports on found markers and their metadata
228+
* Validate marker syntax and structure
229+
* Export analysis results in various formats (JSON, CSV)
230+
* Integration with CI/CD pipelines
231+
* Fast iteration during development
232+
* Batch processing of multiple files or directories
233+
234+
.. fault:: CLI integration fails silently
235+
:id: FAULT_CLI_ANALYZE_1
236+
237+
.. fault:: Sphinx-codelinks halucinates marked content
238+
:id: FAULT_CLI_ANALYZE_2
239+
240+
.. fault:: Sphinx-codelinks misses marked content
241+
:id: FAULT_CLI_ANALYZE_3
242+
243+
.. feature:: Discover the filepaths a specified root directory via CLI interface
244+
:id: FE_CLI_DISCOVER
245+
246+
It shall be possible to specify a root directory for the CLI interface.
247+
All files in and below this directory shall be discovered.
248+
249+
The discovery feature provides intelligent file system traversal to identify all
250+
relevant source files within a project structure. This enables bulk operations
251+
and ensures comprehensive coverage of your codebase.
252+
253+
Discovery features:
254+
255+
* Recursive directory traversal from specified root
256+
* File type filtering based on extensions
257+
* Respect for ignore patterns (e.g., ``.gitignore``)
258+
* Detection of binary vs. text files
259+
* Configurable include/exclude patterns
260+
* Support for multiple root directories
261+
* Efficient handling of large codebases
262+
263+
.. fault:: Specifying a root directory fails
264+
:id: FAULT_CLI_DISCOVER_1
265+
266+
.. fault:: Sphinx-codelinks discovers files outside the specified root directory
267+
:id: FAULT_CLI_DISCOVER_2
268+
269+
Root directory setting is not respected or ignored
270+
271+
.. feature:: Export marked content to other formats via CLI interface
272+
:id: FE_CLI_WRITE
273+
274+
It shall be possible to export marked content to other formats via the CLI interface.
275+
276+
The export functionality enables transformation of extracted traceability data into
277+
various output formats for use in external tools, reports, or downstream processing.
278+
This makes Sphinx-Codelinks a versatile component in your documentation toolchain.
279+
280+
Export capabilities:
281+
282+
* JSON format for programmatic processing
283+
* CSV format for spreadsheet analysis
284+
* Sphinx-Needs compatible formats
285+
* Custom format definitions via templates
286+
* Batch export of multiple analyses
287+
* Filtering and transformation options
288+
* Integration with external reporting tools
289+
* Support for incremental exports
290+
291+
.. fault:: Exporting marked content fails
292+
:id: FAULT_CLI_WRITE_1
293+
294+
.. fault:: Sphinx-codelinks exports wrong content
295+
:id: FAULT_CLI_WRITE_2
296+
297+
.. fault:: Exported content is malformed
298+
:id: FAULT_CLI_WRITE_3

docs/source/components/oneline.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ to simplify the effort required to create a need in source code.
1313

1414
For more comprehensive examples and advanced configurations, see the `test cases <https://github.com/useblocks/sphinx-codelinks/tree/main/tests>`__.
1515

16-
1716
Start and End sequences
1817
-----------------------
1918

docs/source/components/write.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ The following RST file with :external+needs:ref:`needextend <needextend>` direct
3434

3535
.. code-block:: rst
3636
37-
.. needextend:: NEED_001
38-
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
37+
.. needextend:: NEED_001
38+
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
3939
40-
.. needextend:: NEED_002
41-
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
40+
.. needextend:: NEED_002
41+
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
4242
43-
.. needextend:: NEED_003
44-
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
43+
.. needextend:: NEED_003
44+
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
4545
46-
.. needextend:: NEED_004
47-
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
46+
.. needextend:: NEED_004
47+
:remote-url: https://github.com/useblocks/sphinx-codelinks/blob/951e40e7845f06d5cfc4ca20ebb984308fdaf985/tests/data/need_id_refs/dummy_1.cpp#L3
4848
4949
More examples can be found in `test cases <https://github.com/useblocks/sphinx-codelinks/blob/main/tests/test_needextend_write.py>`__
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Traceability
2+
============
3+
4+
Implementation
5+
--------------
6+
7+
.. src-trace::
8+
:project: sphinx_codelinks
9+
:directory: sphinx_codelinks
10+
11+
Testing
12+
-------
13+
14+
.. src-trace::
15+
:project: tests

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Contents
6666
components/analyse
6767
components/discover
6868
components/write
69+
components/features
6970

7071
.. toctree::
7172
:maxdepth: 1
@@ -74,3 +75,4 @@ Contents
7475
development/roadmap
7576
development/change_log
7677
development/contributing
78+
development/traceability

0 commit comments

Comments
 (0)