Scripts added to create requirement specification document
This commit is contained in:
parent
da85b750f2
commit
5a8f5e1603
20
__init__.py
20
__init__.py
@ -1,7 +1,3 @@
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from reqif import xml_parser
|
||||
from reqif import reqif_conv
|
||||
|
||||
@ -69,19 +65,3 @@ class reqif(object):
|
||||
|
||||
def get_title(self):
|
||||
return self._data._title
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser("usage: %%prog reqif_file [options]")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
#
|
||||
# Check options and args
|
||||
if len(args) != 1 or not os.path.isfile(args[0]):
|
||||
parser.print_help()
|
||||
else:
|
||||
reqif_path = args[0]
|
||||
tex_path = os.path.abspath(os.path.splitext(reqif_path)[0] + '.tex')
|
||||
reqif_data = reqif_dict(reqif_path, 'Heading', 'Software Specification')
|
||||
reqif_conv.tex_gen(reqif_data, tex_path)
|
||||
sys.exit(reqif_conv.pdf_gen(tex_path))
|
||||
|
14
scripts/Makefile
Normal file
14
scripts/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
.PHONY: all
|
||||
.PRECIOUS: %.tex
|
||||
|
||||
all: specification.pdf clean
|
||||
|
||||
%.tex: %.reqif
|
||||
python3 reqif/scripts/parse.py $<
|
||||
|
||||
%.pdf: %.tex
|
||||
latexmk -pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make $<
|
||||
|
||||
clean:
|
||||
latexmk -c
|
||||
rm -f *~ *.tex
|
36
scripts/parse.py
Normal file
36
scripts/parse.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import jinja2
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
BASEPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
sys.path.insert(0, BASEPATH)
|
||||
|
||||
import reqif
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser("usage: %prog reqif_file")
|
||||
parser.add_option("-t", "--template", dest="template", default=os.path.join(BASEPATH, 'reqif', 'templates', 'tex', 'requirement_specification.tex'), help="path to the template")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
#
|
||||
# Check options and args
|
||||
if len(args) != 1 or not os.path.isfile(args[0]):
|
||||
parser.print_help()
|
||||
else:
|
||||
reqif_path = args[0]
|
||||
template_path = os.path.abspath(options.template)
|
||||
output_path = os.path.splitext(reqif_path)[0] + os.path.splitext(template_path)[1]
|
||||
if reqif_path == output_path:
|
||||
sys.exit('ERROR: Source and Destination would be the same file')
|
||||
#
|
||||
reqif_data = reqif.reqif_dict(reqif_path, 'Heading', 'Software Specification')
|
||||
#
|
||||
with open(output_path, 'w') as fh:
|
||||
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(template_path)))
|
||||
template = jenv.get_template(os.path.basename(template_path))
|
||||
fh.write(template.render(data=reqif_data))
|
@ -1,17 +0,0 @@
|
||||
SPEC_FILENAME=requirements
|
||||
|
||||
.PHONY: specification
|
||||
|
||||
specification:
|
||||
venv/bin/python reqif/__init__.py $(SPEC_FILENAME).reqif
|
||||
@$(MAKE) --no-print-directory clean
|
||||
xdg-open $(SPEC_FILENAME).pdf
|
||||
|
||||
clean:
|
||||
@echo Removing generated files for target
|
||||
@rm -f $(SPEC_FILENAME).tex $(SPEC_FILENAME).aux $(SPEC_FILENAME).log $(SPEC_FILENAME).out $(SPEC_FILENAME).toc *~
|
||||
|
||||
|
||||
cleanall: clean
|
||||
@echo Removing target
|
||||
@rm -f $(SPEC_FILENAME).pdf
|
Loading…
x
Reference in New Issue
Block a user