Skip to content

Commit

Permalink
Merge pull request #10 from CogPy/latexJinja
Browse files Browse the repository at this point in the history
Latex jinja
  • Loading branch information
florath committed Mar 29, 2018
2 parents fa56c0b + 7e16fba commit edd3146
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 15 deletions.
3 changes: 2 additions & 1 deletion contrib/template_project/Config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"requirements_dirs": [ "requirements" ],
"topics_dirs": [ "topics" ],
"topic_root_node": "ReqsDocument",
"constraints_dirs": [ "constraints" ] }
"constraints_dirs": [ "constraints" ],
"testcases_dirs": [ "testcases" ] }
]
],
"output": {
Expand Down
4 changes: 4 additions & 0 deletions contrib/template_project/latex/LatexJinja2/singleReq.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
((* for outg in dependson *)) \hyperlink{(((outg)))}{(((outg)))} ((* endfor *))
((* endif *))

((* if testcases is defined *)) \textbf{Test Cases:}
((* for tc in testcases *))\hyperlink{TESTCASE(((tc)))}{(((tc)))}((* if not loop.last *)),((* endif *)) ((* endfor *))
((* endif *))

\par{\small \begin{center}
\begin{tabular}{rlrlrl}
Id: & (((req_id))) & Priority: & (((prio))) & Owner: & (((owner))) \\
Expand Down
1 change: 1 addition & 0 deletions contrib/template_project/requirements/req1.req
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Status: not done
Priority: development:10
Effort estimation: 21
Topic: WhatsAbout
Test Cases: ExampleTestcase ExampleTestcase2

7 changes: 7 additions & 0 deletions contrib/template_project/testcases/ExampleTestcase.tec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Name: Example Test Case
Owner: development
Invented by: flonatel
Invented on: 2012-03-19
Description: This is an example test case.
Expected Result: This is the result.
Note: Just for testing.
7 changes: 7 additions & 0 deletions contrib/template_project/testcases/ExampleTestcase2.tec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Name: Example Test Case 2
Owner: development
Invented by: flonatel
Invented on: 2012-03-19
Description: This is an example test case.
Expected Result: This is also a result.
Note: Just for testing.
23 changes: 9 additions & 14 deletions rmtoo/outputs/LatexJinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ def __output_latex_one_testcase(self, cname, cnstrt):
self.__fd.write(u"%% TEST-CASE '%s'\n" % cname)

self.__fd.write(u"\%s{%s}\label{TESTCASE%s}\n"
"\hypertarget{TESTCASE%s}{}"
"\\textbf{Description:} %s\n"
% (self.level_names[1],
cnstrt.get_value("Name").get_content(),
cnstrt.get_value("Name").get_content(),
cname, cnstrt.get_value(
"Description").get_content()))
Expand Down Expand Up @@ -275,13 +277,12 @@ def _get_requirement(self, req):
except KeyError:
pass

return req_template.render(template_vars)

# The following has not been ported yet (TODO)
if self.__ce3set is not None:
raise NotImplementedError('Not yet defined')
cnstrt = self.__ce3set.get(req.get_id())
if cnstrt is not None and len(cnstrt) > 0:
raise NotImplementedError(
'Not yet defined, use latex2 output instead!')
self.__fd.write(u"\n\\textbf{Constraints:} ")
cstrs = []
for key, val in sorted(iteritems(cnstrt)):
Expand All @@ -301,17 +302,11 @@ def _get_requirement(self, req):

testcases = req.get_value_default("Test Cases")
if testcases is not None:
raise NotImplementedError('Not yet defined: Test Cases')
self.__fd.write(u"\n\\textbf{Test Cases:} ")
tcout = []
for testcase in testcases:
refid = LatexJinja2.__strescape(testcase)
refctr = "\\ref{TESTCASE%s} \\nameref{TESTCASE%s}" \
% (refid, refid)
tcout.append(refctr)

self.__fd.write(u", ".join(tcout))
self.__fd.write(u"\n")
inc = [LatexJinja2.__strescape(testcase)
for testcase in testcases]
template_vars['testcases'] = inc

return req_template.render(template_vars)

def cmad_topic_continuum_pre(self, _):
'''Write out the one and only dependency to all the requirements.'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ topics:
topic_root_node: ReqsDocument
constraints_dirs:
- ../contrib/template_project/constraints
testcases_dirs:
- ../contrib/template_project/testcases
output:
graph:
- output_filename: ${ENV:rmtoo_test_dir}/artifacts/req-graph1.dot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@ \subsection{req1}\label{req1}

\textbf{Depends on:} \ref{project} \nameref{project}

\textbf{Test Cases:} \ref{TESTCASEExampleTestcase} \nameref{TESTCASEExampleTestcase}, \ref{TESTCASEExampleTestcase2} \nameref{TESTCASEExampleTestcase2}

\par
{\small \begin{center}\begin{tabular}{rlrlrl}
\textbf{Id:} & req1 & \textbf{Priority:} & 10.00 & \textbf{Owner:} & development\\
\textbf{Invented on:} & 2010-10-09 & \textbf{Invented by:} & flonatel & \textbf{Status:} & not done \\
\textbf{Class:} & detailable & & & \end{tabular}\end{center} }

\chapter{Test Cases}
% TEST-CASE 'ExampleTestcase'
\section{Example Test Case}\label{TESTCASEExampleTestcase}
\textbf{Description:} This is an example test case.

\textbf{Note:} Just for testing.
% TEST-CASE 'ExampleTestcase2'
\section{Example Test Case 2}\label{TESTCASEExampleTestcase2}
\textbf{Description:} This is an example test case.

\textbf{Note:} Just for testing.
2 changes: 2 additions & 0 deletions rmtoo/tests/RMTTest-Output/RMTTestLaTeXJinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def rmttest_def_req(self):
\par{\small \begin{center}
\begin{tabular}{rlrlrl}
Id: & TestReq & Priority: & & Owner: & \\
Expand Down

0 comments on commit edd3146

Please sign in to comment.