Skip to content

Commit a29ce6a

Browse files
authored
Merge pull request #620 from cbernt/pullrequest_refs_latex
traceability: support linking Tex files to requirements
2 parents 4ce2465 + 28b9f4f commit a29ce6a

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

strictdoc/core/finders/source_files_finder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def is_c_file(self):
5757
def is_cpp_file(self):
5858
return self.extension == ".cpp"
5959

60+
def is_tex_file(self):
61+
return self.extension == ".tex"
62+
6063

6164
class SourceFilesFinder:
6265
@staticmethod
@@ -81,7 +84,7 @@ def find_source_files(
8184
doctree_root_mount_path = os.path.basename(doctree_root_abs_path)
8285

8386
file_tree = FileFinder.find_files_with_extensions(
84-
doctree_root_abs_path, config, {".py", ".c", ".cpp"}
87+
doctree_root_abs_path, config, {".py", ".c", ".cpp", ".tex"}
8588
)
8689

8790
root_level = doctree_root_abs_path.count(os.sep)

strictdoc/export/html/generators/source_file_view_generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pygments.formatters.html import HtmlFormatter
44
from pygments.lexers.c_cpp import CppLexer, CLexer
55
from pygments.lexers.python import PythonLexer
6+
from pygments.lexers.markup import TexLexer
67

78
from strictdoc.core.finders.source_files_finder import SourceFile
89
from strictdoc.core.traceability_index import TraceabilityIndex
@@ -44,6 +45,8 @@ def export(
4445
lexer = CLexer()
4546
elif source_file.is_cpp_file():
4647
lexer = CppLexer()
48+
elif source_file.is_tex_file():
49+
lexer = TexLexer()
4750
else:
4851
assert NotImplementedError
4952

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[DOCUMENT]
2+
TITLE: Example: Traceability between requirements and source files
3+
4+
[REQUIREMENT]
5+
UID: REQ-001
6+
REFS:
7+
- TYPE: File
8+
VALUE: file.tex
9+
TITLE: Whole file reference
10+
STATEMENT: This requirement references the whole file.
11+
12+
[REQUIREMENT]
13+
UID: REQ-002
14+
REFS:
15+
- TYPE: File
16+
VALUE: file.tex
17+
TITLE: Source range reference
18+
STATEMENT: This requirement references a range in the file.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
\documentclass[12pt]{article}
2+
\usepackage{lingmacros}
3+
\usepackage{tree-dvips}
4+
\begin{document}
5+
6+
\section*{Notes for My Paper}
7+
8+
Don't forget to include examples of topicalization.
9+
They look like this:
10+
11+
{\small
12+
\enumsentence{Topicalization from sentential subject:\\
13+
\shortex{7}{a John$_i$ [a & kltukl & [el &
14+
{\bf l-}oltoir & er & ngii$_i$ & a Mary]]}
15+
{ & {\bf R-}clear & {\sc comp} &
16+
{\bf IR}.{\sc 3s}-love & P & him & }
17+
{John, (it's) clear that Mary loves (him).}}
18+
}
19+
20+
\subsection*{How to handle topicalization}
21+
22+
I'll just assume a tree structure like (\ex{1}).
23+
24+
{\small
25+
\enumsentence{Structure of A$'$ Projections:\\ [2ex]
26+
\begin{tabular}[t]{cccc}
27+
& \node{i}{CP}\\ [2ex]
28+
\node{ii}{Spec} & &\node{iii}{C$'$}\\ [2ex]
29+
&\node{iv}{C} & & \node{v}{SAgrP}
30+
\end{tabular}
31+
\nodeconnect{i}{ii}
32+
\nodeconnect{i}{iii}
33+
\nodeconnect{iii}{iv}
34+
\nodeconnect{iii}{v}
35+
}
36+
}
37+
38+
% [REQ-002]
39+
\subsection*{Mood}
40+
41+
Mood changes when there is a topic, as well as when
42+
there is WH-movement. \emph{Irrealis} is the mood when
43+
there is a non-subject topic or WH-phrase in Comp.
44+
\emph{Realis} is the mood when there is a subject topic
45+
or WH-phrase.
46+
% [/REQ-002]
47+
48+
\end{document}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RUN: %strictdoc export %S --experimental-enable-file-traceability --output-dir Output | filecheck %s --dump-input=fail
2+
CHECK: Published: Example: Traceability between requirements and source files
3+
4+
RUN: %check_exists --file "%S/Output/html/_source_files/10_support_files_with_tex_extension/file.tex.html"
5+
6+
RUN: cat %S/Output/html/10_support_files_with_tex_extension/example.html | filecheck %s --dump-input=fail --check-prefix CHECK-HTML
7+
CHECK-HTML: <a{{.*}}href="../_source_files/10_support_files_with_tex_extension/file.tex.html#REQ-001">
8+
9+
RUN: cat %S/Output/html/_source_files/10_support_files_with_tex_extension/file.tex.html | filecheck %s --dump-input=fail --check-prefix CHECK-SOURCE-FILE
10+
CHECK-SOURCE-FILE: <a{{.*}}href="../../10_support_files_with_tex_extension/example.html#1-REQ-001"{{.*}}>

0 commit comments

Comments
 (0)