Skip to content

Commit bb92a35

Browse files
committed
2.2.3
Added optional {levels} parameter to @uid_fw_trace
1 parent 013c99c commit bb92a35

File tree

9 files changed

+55
-29
lines changed

9 files changed

+55
-29
lines changed

Spexyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ ALIASES += \
1111
"uid_bw_trace=<tr><td><b>Backward Traceability</b><br>^^" \
1212
"uid_bw_trace{1}=<tr><td><b>Backward Traceability</b><br>^^" \
1313
"uid_fw_trace=<tr><td><b>Forward Traceability</b><br>^^" \
14-
"uid_fw_trace{1}=<tr><td><b>Forward Traceability</b><br>^^" \
14+
"uid_fw_trace{1}=<tr><td><b>Forward Traceability (truncated to \1 level(s))</b><br>^^" \
1515
"enduid=</table>" \
1616
"code_uid{2}=@brief \2^^" \
1717
"code_alias{2}=@brief <b>\1</b> : \2^^@anchor \1" \
1818
"code_litem{1}=^^@par \1^^" \
1919
"code_bw_trace=^^@par Backward Traceability^^" \
2020
"code_bw_trace{1}=^^@par Backward Traceability^^" \
2121
"code_fw_trace=^^@par Forward Traceability^^" \
22-
"code_fw_trace{1}=^^@par Forward Traceability^^" \
22+
"code_fw_trace{1}=^^@par Forward Traceability (truncated to \1 level(s))^^" \
2323
"endcode_uid=" \
2424
"tr{1}=@ref \1 \"\1\"" \
2525
"precondition{2}=^^@par Precondition `\1:\2`^^" \

doc/DOC_MAN_SPX.pdf

-6.56 KB
Binary file not shown.

doc/Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Project related configuration options
77
#---------------------------------------------------------------------------
88
PROJECT_NAME = Spexygen
9-
PROJECT_NUMBER = 2.2.2
9+
PROJECT_NUMBER = 2.2.3
1010
PROJECT_BRIEF = "Reference Manual"
1111
PROJECT_LOGO = $(SPEXYGEN)/spexygen-awesome/img/logo_spexygen.webp
1212
PROJECT_ICON =

doc/Doxyfile-PDF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Configuration options related to the LateX output
77
#---------------------------------------------------------------------------
88
PROJECT_NAME = Reference Manual
9-
PROJECT_BRIEF = For Spexygen 2.2.2
9+
PROJECT_BRIEF = For Spexygen 2.2.3
1010
PROJECT_NUMBER = Document: DOC_MAN_SPX
1111

1212
#---------------------------------------------------------------------------

doc/main.dox

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ __Work artifacts__ (e.g., requirements) are defined by means of the following _S
222222
<tr><td><b>\@uid_litem{item}</b> <td>adds new line - item in the "work artifact" definition<br>parameter: <b>title</b> -- Title of the line item(e.g., Details)
223223
<tr><td><b>\@uid_bw_trace{brief}</b> <td>adds the backward trace section in in the "work artifact" definition<br>parameter: <b>brief</b> -- request _Spexygen_ to add the brief item description
224224
<tr><td><b>\@uid_bw_trace</b> <td>adds the backward trace section in in the "work artifact" definition<br> overloaded version without requesting the brief description
225-
<tr><td><b>\@uid_fw_trace</b> <td>adds the forward trace section in in the "work artifact" definition<br> this is a request to _Spexygen_ to __generate__ the recursive @ref tr-fw "forward traceability" for the "work artifact"
225+
<tr><td><b>\@uid_fw_trace{levels}</b> <td>adds the forward trace section in in the "work artifact" definition<br> this is a request to _Spexygen_ to __generate__ the recursive @ref tr-fw "forward traceability" for the "work artifact" <br>optional parameter: <b>levels</b> truncates the displayed recursion levels
226226
<tr><td><b>\@enduid</b> <td>ends the definition "work artifact" <br> must be placed at the end of "work artifact" definition
227227
<tr><td><b>\@tr{uid}</b> <td>references the given UID<br> parameter: <b>uid</b> -- the @ref tr-uid "UID" of the "work artifact"
228228
</table>
@@ -238,7 +238,7 @@ The following snippet illustrates how a "work artifact" (a requirement) has been
238238
Longer description of the requirement
239239
[4] @uid_bw_trace{brief}
240240
[5] - @tr{SRS_PRJ_Foo_00}
241-
[6] @uid_fw_trace
241+
[6] @uid_fw_trace{2}
242242
[7] @enduid
243243
@endverbatim
244244

@@ -259,7 +259,7 @@ The whole <b>\@uid{}</b> command must be defined in a single line of text and th
259259

260260
`[6]` the "work artifact" can specify forward traceability by means of the <b>\@uid_fw_trace</b> _Spexygen_ command
261261
@note
262-
The <b>\@uid_fw_trace</b> _Spexygen_ command is just a __placeholder__ for _Spexygen_ to generate the forward traceability links at this place.
262+
The <b>\@uid_fw_trace</b> _Spexygen_ command is just a __placeholder__ for _Spexygen_ to generate the forward traceability links at this place. The optional parameter truncates the number of recursion levels to the specified value.
263263

264264
`[7]` The artifact definition must end with the _Spexygen_ <b>\@enduid</b> command
265265

@@ -277,7 +277,7 @@ __Code artifacts__ (e.g., functions, macros, classes) are naturally handled by D
277277
<tr><td><b>\@code_litem{item }</b> <td>adds new line-item in the "code artifact" definition<br>parameter: <b>title</b> --Title of the line item(e.g., Details)
278278
<tr><td><b>\@code_bw_trace{brief}</b> <td>adds the backward trace section in in the "code artifact" definition<br>parameter: <b>brief</b> -- request _Spexygen_ to add the brief item description
279279
<tr><td><b>\@code_bw_trace</b> <td>adds the backward trace section in in the "code artifact" definition<br> overloaded version without requesting the brief description
280-
<tr><td><b>\@code_fw_trace</b> <td>adds the forward trace section in in the "code artifact" definition<br> this is a request to _Spexygen_ to __generate__ the recursive @ref tr-fw "forward traceability" for the "code artifact"
280+
<tr><td><b>\@code_fw_trace{levels}</b> <td>adds the forward trace section in in the "code artifact" definition<br> this is a request to _Spexygen_ to __generate__ the recursive @ref tr-fw "forward traceability" for the "code artifact"<br>optional parameter: <b>levels</b> truncates the displayed recursion levels
281281
<tr><td><b>\@endcode_uid</b> <td>ends the definition "code artifact" <br> must be placed at the end of "code artifact" definition
282282
<tr><td><b>\@tr{uid}</b> <td>references the given UID<br> parameter: <b>uid</b> -- the @ref tr-uid "UID" of the "code artifact"
283283
</table>
@@ -295,7 +295,7 @@ The following snippet illustrates how a "code artifact" (function `free_fun()`)
295295

296296
[3] @code_bw_trace{brief}
297297
[4] - @tr{SRS_PRJ_Foo_03}
298-
[5] @code_fw_trace
298+
[5] @code_fw_trace{3}
299299
[6] @endcode_uid
300300
*/
301301
[7] bool Foo_verify_(Foo const* const me);
@@ -316,7 +316,7 @@ The whole <b>\@code_uid{}</b> command must be defined in a single line of text a
316316

317317
`[5]` the "code artifact" can specify forward traceability by means of the <b>\@code_fw_trace</b> _Spexygen_ command
318318
@note
319-
The <b>\@code_fw_trace</b> _Spexygen_ command is just a __placeholder__ for _Spexygen_ to generate the forward traceability links at this place.
319+
The <b>\@code_fw_trace</b> _Spexygen_ command is just a __placeholder__ for _Spexygen_ to generate the forward traceability links at this place. The optional parameter truncates the number of recursion levels to the specified value.
320320

321321
`[6]` The "code artifact" definition must end with the _Spexygen_ <b>\@endcode_uid</b> command
322322

example/main.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@endif
88

99
@ifnot LATEX
10-
@nav{gen,srs}
10+
@nav_next{srs}
1111
<div style="clear:both"></div>
1212
@endif
1313

@@ -47,6 +47,6 @@ Please note the generated _forward-traceability_ and the _backward-traceability_
4747

4848
@ifnot LATEX
4949
<p></p>
50-
@nav{gen,srs}
50+
@nav_next{srs}
5151
@endif
5252
*/

example/srs.dox

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,29 @@ Definitions of formal requirements specifications with _Spexygen_ commands.
1818
@uid{SRS_EXA_FF_00,My project shall provide a free function foo().}
1919
@uid_litem{Description}
2020
Longer description of the requirement
21-
@uid_fw_trace
21+
@uid_fw_trace{1}
2222
@enduid
2323

2424
@uid{SRS_EXA_Foo_00,My project shall provide a class Foo.}
2525
@uid_litem{Description}
2626
Longer description of the requirement
27-
@uid_fw_trace
27+
@uid_fw_trace{1}
2828
@enduid
2929

3030
@uid{SRS_EXA_Foo_01,Class Foo shall provide a public attribute x.}
3131
@uid_litem{Description}
3232
Longer description of the requirement
3333
@uid_bw_trace{brief}
3434
- @tr{SRS_EXA_Foo_00}
35-
@uid_fw_trace
35+
@uid_fw_trace{2}
3636
@enduid
3737

3838
@uid{SRS_EXA_Foo_02,Class Foo shall provide a constructor.}
3939
@uid_litem{Description}
4040
Longer description of the requirement
4141
@uid_bw_trace{brief}
4242
- @tr{SRS_EXA_Foo_00}
43-
@uid_fw_trace
43+
@uid_fw_trace{2}
4444
@enduid
4545

4646
@uid{SRS_EXA_Foo_03,Class Foo shall provide a verify operation.}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
setup(
1111
name="spexygen",
12-
version="2.2.2",
12+
version="2.2.3",
1313
author="Quantum Leaps",
1414
author_email="[email protected]",
1515
description="Traceable specifications based on doxygen",

spexygen.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Spexygen:
4747
'''
4848

4949
# public class constants
50-
VERSION = 222
50+
VERSION = 223
5151

5252
UID_DOC = 1
5353
UID_CODE = 2
@@ -66,6 +66,7 @@ def __init__(self):
6666
self._uid_trace_dict = {} # UID dictionary collected during tracing
6767
self._uid_brief_dict = {} # UID-brief dictionary collected during tracing
6868
self._uid_traced_list = [] # UID list built during generation
69+
self._fw_trace_levels = len(Spexygen.LEVELS) - 2 # number of fw-trace levels to generate
6970

7071
@staticmethod
7172
def debug(*args, **kwargs):
@@ -76,30 +77,32 @@ def debug(*args, **kwargs):
7677

7778

7879
def on_file_pattern(self, fname):
79-
'''return True if file-name is acceptable for Spexygen
80+
'''return True if file-name is recognizable to Spexygen
8081
'''
8182
return fname.endswith('.dox') or \
8283
fname.endswith('.h') or fname.endswith('.c') or \
8384
fname.endswith('.hpp') or fname.endswith('.cpp') or \
8485
fname.endswith('.py') or fname.endswith('.lnt')
8586

86-
def on_gen_fw_trace(self, uid, level):
87+
def on_gen_fw_trace(self, uid_in, level):
8788
'''recursively generate the forward trace for a "uid"
8889
'''
89-
self._uid_traced_list.append(uid)
90-
Spexygen.debug(" level=", level, "uid=", uid,
90+
self._uid_traced_list.append(uid_in)
91+
Spexygen.debug(" level=", level, "uid=", uid_in,
9192
"self._uid_traced_list:", self._uid_traced_list)
92-
for uid in self._uid_trace_dict.get(uid):
93+
for uid in self._uid_trace_dict.get(uid_in):
9394
if uid not in self._uid_traced_list:
9495
self._file.write("%s%s- @tr{%s}: %s\n"
9596
%(self._prefix, Spexygen.LEVELS[level],
9697
uid, self._uid_brief_dict[uid]))
97-
if level < len(Spexygen.LEVELS) - 2:
98+
if level < self._fw_trace_levels:
9899
if uid in self._uid_trace_dict:
99100
self.on_gen_fw_trace(uid, level+1) # recursive!
100-
else:
101-
self._file.write("%s%s- ...\n"
102-
%(self._prefix, Spexygen.LEVELS[level+1]))
101+
elif level >= len(Spexygen.LEVELS) - 2:
102+
#self._file.write("%s%s- ...\n"
103+
# %(self._prefix, Spexygen.LEVELS[level+1]))
104+
self._file.write(
105+
f"{self._prefix}{Spexygen.LEVELS[level+1]}- ...\n")
103106
print(f" {self._fname}:{self._lnum} too many"\
104107
f' forward trace levels for "{uid}"')
105108

@@ -288,11 +291,34 @@ def gen_fw_trace(self, line):
288291
'''find a fw-trace placeholder and generate fw-trace
289292
return True if the placeholder found
290293
'''
291-
if (i := line.find('@uid_fw_trace')) < 0:
292-
i = line.find('@code_fw_trace')
294+
l = 0
295+
if (i := line.find('@uid_fw_trace')) >= 0:
296+
l = 13
297+
elif (i := line.find('@code_fw_trace')) >= 0:
298+
l = 14
293299
if i < 0:
294300
return False # placeholder not found
295301

302+
# parse the optional number of levels parameter
303+
levels = len(Spexygen.LEVELS) - 2
304+
if line.find('{', i+l) == i+l: # parameter present?
305+
j = line.find('}', i+l+1)
306+
if j >= 0:
307+
try:
308+
levels = int(line[i+l+1:j])
309+
if levels >= 1:
310+
levels -= 1
311+
elif levels > len(Spexygen.LEVELS) - 2:
312+
levels = len(Spexygen.LEVELS) - 2
313+
except ValueError:
314+
print("Error: non-numeric parameter in '@uid_fw_trace{}'")
315+
return False
316+
else:
317+
print("Error: missing '}' for '@uid_fw_trace{' in line",
318+
self._lnum, ":", i+l+1)
319+
return False
320+
self._fw_trace_levels = levels
321+
296322
self._prefix = line[:i]
297323
self._file.write(line)
298324
if self._uid in self._uid_trace_dict:

0 commit comments

Comments
 (0)