diff --git a/.gitignore b/.gitignore index 014aa7404c19c5a3f57ff1c5d57d6f43b456125f..8aefbb403ab5d094ad08de58823daeb5b3c2b003 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ .pytest_cache/ *.pyc .vscode/ +.project +.settings/ +.pydevproject +*.egg-info/ +build/ +dist/ \ No newline at end of file diff --git a/execOverFolder.sh b/execOverFolder.sh new file mode 100644 index 0000000000000000000000000000000000000000..3fa07a6605c8cf4daa0e86feb4777ecd48995bd3 --- /dev/null +++ b/execOverFolder.sh @@ -0,0 +1,36 @@ +#!/bin/bash +EXCLUDE="" +SOL="SOL00Y" +COMMIT="" +if [ "$1" != "" ]; then + DIR=$1 + if [ "$2" != "" ]; then + EXCLUDE=$2 + else + echo "No configured exclusions" + fi + if [ "$3" != "" ]; then + COMMIT=$3 + else + echo "No configured commit id" + fi + if [ "$4" != "" ]; then + SOL=$4 + else + echo "No configured commit id" + fi + + API=$(basename $DIR) + echo "api: $API" + for file in $DIR/*.robot; do + filename=$(basename "$file") + if [[ $filename != *"$EXCLUDE"* ]]; then + python robot2doc/main.py $file "${filename%.*}.docx" "${filename%.*}" $COMMIT $SOL $API + else + echo "excluded file: $filename" + fi + done +else + echo "Enter a directory" +fi + diff --git a/robot2doc/ETSI_GS_skeleton.docx b/robot2doc/ETSI_GS_skeleton.docx deleted file mode 100644 index 7e203201a595e464eb72bf3c9dfc79c7b399140d..0000000000000000000000000000000000000000 Binary files a/robot2doc/ETSI_GS_skeleton.docx and /dev/null differ diff --git a/robot2doc/basespec.docx b/robot2doc/basespec.docx deleted file mode 100755 index fccf91af44f764a50a46b6bbabf86463273f6f90..0000000000000000000000000000000000000000 Binary files a/robot2doc/basespec.docx and /dev/null differ diff --git a/robot2doc/main.py b/robot2doc/main.py index cc62c19bcaf263c9f92573ca13055b124f2a1da5..15def83c2f3d2ac8d6bf2431dfc488ec5d020082 100644 --- a/robot2doc/main.py +++ b/robot2doc/main.py @@ -39,7 +39,7 @@ def keywords_to_text(kws): ''' return "\n".join(map(keyword_to_line, kws)) -def gen_test(suite, this_test, spec, sec, subsec, workspace): +def gen_test(suite, this_test, spec, sec, subsec, workspace, commit_id, sol, api): ''' Generate the Docx part for an individual test ''' @@ -57,9 +57,9 @@ def gen_test(suite, this_test, spec, sec, subsec, workspace): else: subsec = subsec + 1 spec.add_heading(str(this_test), DOC_TC_LEVEL, DOC_CLAUSE_LVL_1, sec, DOC_CLAUSE_LVL_3, subsec) - tp.add_to_spec(spec, keywords_to_text(this_test.keywords), str(suite)+".robot") + tp.add_to_spec(spec, keywords_to_text(this_test.keywords), str(suite)+".robot", commit_id, sol, api) -def gen_doc(src, doc_fn, doc_main_tit): +def gen_doc(src, doc_fn, doc_main_tit, commit_id, sol, api): ''' Converts a Robot test suite to a word document @@ -102,7 +102,7 @@ def gen_doc(src, doc_fn, doc_main_tit): print(" Generating test suite: " + str(suite)) spec.add_sub_heading(str(suite), DOC_CLAUSE_LVL_1, sec, DOC_CLAUSE_LVL_3, subsec) for i in suite.tests: - gen_test(suite, i, spec, sec, subsec, workspace) + gen_test(suite, i, spec, sec, subsec, workspace, commit_id, sol, api) if len(workspace.suites) == 0: sec = sec + 1 @@ -110,7 +110,7 @@ def gen_doc(src, doc_fn, doc_main_tit): suite = str(workspace) spec.add_sub_heading(suite, DOC_CLAUSE_LVL_1, sec, DOC_CLAUSE_LVL_3, subsec) for i in workspace.tests: - gen_test(suite, i, spec, sec, subsec, workspace) + gen_test(suite, i, spec, sec, subsec, workspace, commit_id, sol, api) not QUIET and print("Saving to: " + doc_fn) not DRY_RUN and spec.save(doc_fn) @@ -125,5 +125,8 @@ if __name__ == "__main__": FILE = sys.argv[1] DOC_FILENAME = sys.argv[2] if len(sys.argv) > 2 else DOC_FILENAME DOC_MAIN_TITLE = sys.argv[3] if len(sys.argv) > 3 else DOC_MAIN_TITLE - - gen_doc(FILE, DOC_FILENAME, DOC_MAIN_TITLE) + COMMIT_ID = sys.argv[4] if len(sys.argv) > 4 else None + SOL = sys.argv[5] if len(sys.argv) > 5 else None + API = sys.argv[6] if len(sys.argv) > 6 else None + print( sys.argv[1:]) + gen_doc(FILE, DOC_FILENAME, DOC_MAIN_TITLE, COMMIT_ID, SOL, API) diff --git a/robot2doc/testpurpose.py b/robot2doc/testpurpose.py index c294675787196a07061a38f1f6bc5802e4b3272f..dc15c1dc4f82f9f39ad0748b93740891e6870eda 100644 --- a/robot2doc/testpurpose.py +++ b/robot2doc/testpurpose.py @@ -43,10 +43,15 @@ class TP(): def __str__(self): return str(self.lines) - def add_to_spec(self, spec: testspec.TestSpec, testbehaviour: str, robot_file: str): + def add_to_spec(self, spec : testspec.TestSpec, testbehaviour: str, robot_file : str, commit_id=None, sol=None, api=None): ''' Given a Test Spec, executes the addition of the this TP in the document. ''' spec.add_tp(self.tp_fields, testbehaviour) - if config.GIT_COMMIT_PREFIX != "": - spec.add_commit_url(config.GIT_COMMIT_PREFIX, robot_file) + + if commit_id != None: + spec.add_commit_url(robot_file, commit_id, sol, api) + else: + if config.GIT_COMMIT_PREFIX != "": + spec.add_commit_url( robot_file, "", "", config.GIT_COMMIT_PREFIX) + diff --git a/robot2doc/testspec.py b/robot2doc/testspec.py index 1e1d3ebe48c21c3599d7d63ac2940c5bf9ef683f..aa0272618aa81169649cf55e05910fd976c7b4c1 100644 --- a/robot2doc/testspec.py +++ b/robot2doc/testspec.py @@ -115,17 +115,17 @@ class TestSpec(): TestSpec.cell_text_bold(hdr_cells[0]) TestSpec.cell_text_centered(hdr_cells[0]) - def add_commit_url(self, commit : str, robot_file : str): + def add_commit_url(self, robot_file : str, commit, sol, api): ''' Adds a note to the document containing the URL to the location of the file, according to the configured URL prefix configured. ''' empty_par = self.doc.add_paragraph("") + + commit_url="https://forge.etsi.org/gitlab/nfv/api-tests/raw/"+commit+"/"+sol+"/"+api+"/"+robot_file note_par = self.doc.add_paragraph("NOTE: Robot code can be found at ") - - hyperlink = add_hyperlink(note_par, commit + robot_file, commit + robot_file, None, True) - note_par.style = self.doc.styles["NO"] + hyperlink = add_hyperlink(note_par, commit_url, commit_url, None, True) def add_tp(self, fields, testbehaviour): table = self.doc.add_table(cols=2, rows=1)