From 40b81c553bc1dd6ae2601afd13cb813d6a41f0f8 Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sun, 27 Oct 2019 06:07:34 +0530 Subject: [PATCH 1/2] Fix scancode command example Signed-off-by: Ayan Sinha Mahapatra --- .../scancode-toolkit/rst_snippets/custom_output_format.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst b/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst index e3ac7296..9cf812bb 100644 --- a/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst +++ b/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst @@ -36,12 +36,12 @@ Now I can run ScanCode using my newly created template: :: - $ ./scancode -clpeui --custom-output sample.json --custom-template sample.html samples + $ ./scancode -clpeui --custom-output output.json --custom-template template.html samples Scanning files... [####################################] 46 Scanning done. -Now are results are saved in ``t.json`` and we can easily view them with ``head t.json``\ : +Now are results are saved in ``output.json`` and we can easily view them with ``head output.json``\ : :: From f2d6cc4f78306063a6db2eee884d342f6fc0b97f Mon Sep 17 00:00:00 2001 From: Ayan Sinha Mahapatra Date: Sun, 27 Oct 2019 06:58:17 +0530 Subject: [PATCH 2/2] Fix template error This commit fixes https://github.com/nexB/scancode-toolkit/issues/1760 Signed-off-by: Ayan Sinha Mahapatra --- .../rst_snippets/custom_output_format.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst b/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst index 9cf812bb..8e921dc7 100644 --- a/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst +++ b/docs/source/scancode-toolkit/rst_snippets/custom_output_format.rst @@ -18,8 +18,8 @@ data for this particular scan. ## template.html: [ - {% if results.license_copyright %} - {% for location, data in results.license_copyright.items() %} + {% if files.license_copyright %} + {% for location, data in files.license_copyright.items() %} {% for row in data %} location:"{{ location }}", {% if row.what == 'copyright' %}copyright:"{{ row.value|escape }}",{% endif %} @@ -41,7 +41,7 @@ Now I can run ScanCode using my newly created template: [####################################] 46 Scanning done. -Now are results are saved in ``output.json`` and we can easily view them with ``head output.json``\ : +Now are results are saved in ``output.json`` and we can easily view them with ``head output.json``: :: @@ -53,8 +53,7 @@ Now are results are saved in ``output.json`` and we can easily view them with `` copyright:"copyrighted by the Free Software Foundation", ] -.. - [ToDo] - There is an error in the template.html file: - "UndefinedError: 'results' is undefined" - Will be solved in a later commit. +For a more elaborate template, refer this `default template `_ +given with Scancode, to generate HTML output with the ``--html`` output format option. + +Documentation on `Jinja templates `_.