Skip to content

Commit 58dd243

Browse files
committed
Update RTD and doc
Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 7dc1acc commit 58dd243

File tree

5 files changed

+86
-62
lines changed

5 files changed

+86
-62
lines changed

docs/source/general.rst

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ AboutCode Toolkit Defined
99

1010
AboutCode Toolkit is a tool for your software development team to document your code inside your codebase, typically in preparation for a product release, side-by-side with the actual code. ABOUT file(s) have a simple, standard format that identifies components and their associated licenses. The current AboutCode Toolkit subcommands are:
1111

12-
- **attrib**: Generate a Product Attribution notice document (HTML format) from your ABOUT file(s). You can also generate documents for other purposes (such as a License Reference) by varying your input control file and your template.
12+
- **attrib**: Generate a Product Attribution notice document from your ABOUT file(s), JSON, CSV or Excel. You can also generate documents for other purposes (such as a License Reference) by varying your input control file and your template.
1313

1414
- **check**: A simple command to validate the ABOUT file(s) and output errors/warnings if any on the terminal.
1515

1616
- **collect_redist_src**: A command to collect and copy sources that have 'redistribute' flagged as 'True' in ABOUT file(s) or from an inventory.
1717

18-
- **gen**: Create ABOUT file(s) from a Software Inventory file (.csv or .json format) which is typically created from a software audit, and insert these AboutCode Toolkit files into your codebase. You can regenerate the AboutCode Toolkit files from a new Software Inventory file whenever you make changes.
18+
- **gen**: Create ABOUT file(s) from a Software Inventory file (.csv, .json or .xlsx format) which is typically created from a software audit, and insert these AboutCode Toolkit files into your codebase. You can regenerate the AboutCode Toolkit files from a new Software Inventory file whenever you make changes.
1919

20-
- **inventory**: Generate a Software Inventory list (.csv or .json format) from your codebase based on ABOUT file(s). Note that this Software Inventory will only include components that have AboutCode Toolkit data. In another word, if you do not create AboutCode Toolkit files for your own original software components, these components will not show up in the generated inventory.
20+
- **inventory**: Generate a Software Inventory list (.csv, .json or .xlsx format) from your codebase based on ABOUT file(s). Note that this Software Inventory will only include components that have AboutCode Toolkit data. In another word, if you do not create AboutCode Toolkit files for your own original software components, these components will not show up in the generated inventory.
2121

2222
- **transform**: A command to transform an input CSV/JSON/Excel by applying renaming and/or filtering and then output to a new CSV/JSON/Excel file.
2323

@@ -217,7 +217,7 @@ For instance with this configuration, the target file will not contain the "type
217217
Run gen to Generate ABOUT file(s)
218218
---------------------------------
219219

220-
When your software inventory is ready, you can save it as a .csv or .json file, and use it as input to run gen to generate ABOUT file(s). The official gen parameters are defined here: :ref:`reference`
220+
When your software inventory is ready, you can save it as a .csv, .json or .xlsx file, and use it as input to run gen to generate ABOUT file(s). The official gen parameters are defined here: :ref:`reference`
221221

222222
Here is an example of a gen command:
223223

@@ -227,7 +227,7 @@ Here is an example of a gen command:
227227
228228
This gen example command does the following:
229229

230-
- Activates the --fetch-license option to get license information.
230+
- Activates the --fetch-license option to get license information from ScanCode LicenseDB.
231231

232232
- Activates the --reference option to get license text files and notice text files that you have specified in your software inventory to be copied next to the associated .ABOUT files when those are created.
233233

@@ -247,8 +247,9 @@ Review the generated ABOUT file(s) to determine if it meets your requirements. H
247247
license_expression: gpl-2.0
248248
licenses:
249249
- key: gpl-2.0
250-
name: GNU General Public License 2.0
250+
name: GPL 2.0
251251
file: gpl-2.0.LICENSE
252+
url: https://scancode-licensedb.aboutcode.org/gpl-2.0.LICENSE
252253
owner: Red Hat
253254
redistribute: Y
254255
@@ -257,21 +258,6 @@ You can make appropriate changes to your input software inventory and then run g
257258
Using attrib to Generate a Product Attribution Notice Package
258259
=============================================================
259260

260-
Prepare a Filtered Product BOM to Use as Input to attrib
261-
--------------------------------------------------------
262-
263-
The Software Inventory that you prepared for gen most likely includes components that do not need to appear in a product attribution notice package; for example:
264-
265-
- Components in your codebase that are not Deployed on the final product (e.g. build tools, testing tools, internal documentation).
266-
267-
- Components in your codebase under licenses that do not require attribution (e.g. proprietary packages, commercial products).
268-
269-
There are two options here:
270-
271-
- Edit the jinja2 template to only include the one that have value in attribute field such as: ``{% if about_object.attribute.value %}``
272-
273-
- You should prepare a filtered version of your software inventory (the one that you used for gen) by removing the rows that identify components which should not be included in a product attribution notice package, and saving that filtered version as your Product BOM.
274-
275261
Prepare an Attribution Template to Use as Input to attrib
276262
---------------------------------------------------------
277263

@@ -401,7 +387,7 @@ One of the major features of the ABOUT File specification is that the .ABOUT fil
401387

402388
If your organization adopts the practice of manually creating and maintaining ABOUT file(s), you can easily re-create your software inventory from your codebase using inventory. The official inventory parameters are defined here: :ref:`reference`
403389

404-
A successful execution of inventory will create a complete software inventory in .csv format or .json format based on defined format.
390+
A successful execution of inventory will create a complete software inventory in .csv, .json or .xlsx format based on defined format.
405391

406392

407393

docs/source/reference.rst

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ Commands
2727

2828
.. code-block:: none
2929
30-
attrib Generate an attribution document from .ABOUT files.
30+
attrib Generate an attribution document from JSON/CSV/Excel/.ABOUT files.
3131
check Validate that the format of .ABOUT files is correct and
3232
report errors and warnings.
33-
collect_redist_src Collect redistributable sources.
34-
gen Generate .ABOUT files from an inventory as CSV or JSON.
35-
inventory Collect the inventory of .ABOUT files to a CSV or JSON
36-
file.
33+
collect-redist-src Collect redistributable sources.
34+
gen Generate .ABOUT files from an inventory as CSV/JSON/Excel.
35+
inventory Collect the inventory of .ABOUT files to a CSV/JSON/Excel file.
3736
transform Transform a CSV/JSON/Excel by applying renamings, filters and checks.
3837
3938
attrib
@@ -46,51 +45,92 @@ Syntax
4645
4746
about attrib [OPTIONS] LOCATION OUTPUT
4847
49-
LOCATION: Path to a file, directory or .zip archive containing .ABOUT
50-
files.
51-
48+
INPUT: Path to a file (.ABOUT/.csv/.json/.xlsx), directory or .zip archive containing .ABOUT files.
49+
5250
OUTPUT: Path where to write the attribution document.
5351
5452
Options
5553
-------
5654

5755
.. code-block:: none
5856
59-
--template FILE Path to an optional custom attribution template to
60-
generate the attribution document. If not provided
61-
the default built-in template is used.
62-
--vartext <key>=<value> Add variable text as key=value for use in a custom
63-
attribution template.
64-
-q, --quiet Do not print error or warning messages.
65-
--verbose Show all error and warning messages.
66-
-h, --help Show this message and exit.
57+
--api_url URL URL to DejaCode License Library.
58+
--api_key KEY API Key for the DejaCode License Library
59+
--min-license-score INTEGER Attribute components that have license score
60+
higher than the defined --min-license-score.
61+
--scancode Indicate the input JSON file is from
62+
scancode toolkit.
63+
--reference DIR Path to a directory with reference files where
64+
"license_file" and/or "notice_file" located.
65+
--template FILE Path to an optional custom attribution template to
66+
generate the attribution document. If not provided
67+
the default built-in template is used.
68+
--vartext <key>=<value> Add variable text as key=value for use in a custom
69+
attribution template.
70+
-q, --quiet Do not print error or warning messages.
71+
--verbose Show all error and warning messages.
72+
-h, --help Show this message and exit.
6773
6874
Purpose
6975
-------
7076

71-
Generate an attribution file which contains the all license information from the LOCATION along with the license text.
77+
Generate an attribution file which contains license information from the INPUT along with the license text.
7278

7379
Assume the following:
7480

7581
.. code-block:: none
7682
77-
'/home/about_files/'** contains all the ABOUT files [LOCATION]
83+
'/home/about_files/' contains all the ABOUT files [INPUT]
84+
'/home/project/inventory.csv' is a BOM inventory [INPUT]
85+
'/home/project/scancode-detection.json' is a detection output from scancode-toolkit[INPUT]
86+
'/home/project/licenses/' contains all the license/notice file references
7887
'/home/attribution/attribution.html' is the user's output path [OUTPUT]
7988
89+
90+
.. code-block:: none
91+
8092
$ about attrib /home/about_files/ /home/attribution/attribution.html
93+
or
94+
$ about attrib /home/project/inventory.csv /home/attribution/attribution.html
95+
or
96+
$ about attrib --scancode /home/project/scancode-detection.json /home/attribution/attribution.html
8197
8298
Details
8399
^^^^^^^
84100

85101
.. code-block:: none
86102
103+
--api_url URL --api_key
104+
105+
This option let user to define where to get the license information such as
106+
from DJE. If these options are not set, the tool will get the license
107+
information from ScanCode LicenseDB by default
108+
109+
$ about attrib --api_url <URL> --api_key <KEY> INPUT OUTPUT
110+
111+
--min-license-score
112+
113+
This option is a filter to collect license information where the license score
114+
in the scancode toolkit detection is greater than or equal to the defined
115+
--min-license-score. This option is specifically design for scancode's input
116+
and therefore --scancode is required
117+
118+
$ about attrib --scancode --min-license-score 85 /home/project/scancode-detection.json OUTPUT
119+
120+
--reference
121+
122+
This option is to define the reference directory where the 'license_file'
123+
or 'notice_file' are stored
124+
125+
$ about attrib --reference /home/project/licenses/ /home/project/inventory.csv OUTPUT
126+
87127
--template
88-
128+
89129
This option allows you to use your own template for attribution generation.
90130
For instance, if you have a custom template located at:
91131
/home/custom_template/template.html
92132
93-
$ about attrib --template /home/custom_template/template.html LOCATION OUTPUT
133+
$ about attrib --template /home/custom_template/template.html INPUT OUTPUT
94134
95135
--vartext
96136
@@ -110,12 +150,7 @@ Details
110150
The following data are passed to jinja2 and, therefore, can be used for a custom template:
111151
* about object: the about objects
112152
* common_licenses: a common license keys list in licenses.py
113-
* license_file_key_and_context: a dictionary with license_file_key (It's basically a license_key if it's not a custom license or license file name otherwise) as a key and license text as the value
114-
* license_file_key_and_license_key: a dictionary with license file key as a key and license key as the value
115-
* license_file_name_and_license_file_key: a dictionary with license file name as a key and license file key as the value
116-
* license_key_and_license_file_name: a dictionary with license key as a key and license file name as the value
117-
* license_key_and_license_name: a dictionary with license key as a key and license name as the value
118-
* license_name_and_license_key: a dictionary with license name as a key and license key as the value
153+
* licenses_list: a license object list contains all the licenses found in about objects. It contains the following attribute: key, name, filename, url, text
119154

120155
check
121156
=====
@@ -245,7 +280,7 @@ Syntax
245280
246281
about gen [OPTIONS] LOCATION OUTPUT
247282
248-
LOCATION: Path to a JSON or CSV inventory file.
283+
LOCATION: Path to a JSON/CSV/Excel inventory file.
249284
OUTPUT: Path to a directory where ABOUT files are generated.
250285
251286
Options
@@ -279,7 +314,7 @@ Options
279314
Purpose
280315
-------
281316

282-
Given a CSV/JSON inventory, generate ABOUT files in the output location.
317+
Given a CSV/JSON/Excel inventory, generate ABOUT files in the output location.
283318

284319
Details
285320
^^^^^^^
@@ -348,29 +383,29 @@ Syntax
348383
about inventory [OPTIONS] LOCATION OUTPUT
349384
350385
LOCATION: Path to an ABOUT file or a directory with ABOUT files.
351-
OUTPUT: Path to the JSON or CSV inventory file to create.
386+
OUTPUT: Path to the CSV/JSON/Excel inventory file to create.
352387
353388
Options
354389
-------
355390

356391
.. code-block:: none
357392
358-
-f, --format [json|csv] Set OUTPUT file format. [default: csv]
359-
-q, --quiet Do not print any error/warning.
360-
--verbose Show all the errors and warning.
361-
-h, --help Show this message and exit.
393+
-f, --format [json|csv|excel] Set OUTPUT file format. [default: csv]
394+
-q, --quiet Do not print any error/warning.
395+
--verbose Show all the errors and warning.
396+
-h, --help Show this message and exit.
362397
363398
Purpose
364399
-------
365400

366-
Create a JSON or CSV inventory of components from ABOUT files.
401+
Create a JSON/CSV/Excel inventory of components from ABOUT files.
367402

368403
Details
369404
^^^^^^^
370405

371406
.. code-block:: none
372407
373-
-f, --format [json|csv]
408+
-f, --format [json|csv|excel]
374409
375410
Set OUTPUT file format. [default: csv]
376411

docs/source/specification.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ A simple and valid ABOUT file named httpd-2.4.3.tar.gz.ABOUT may look like this:
2626
license_expression: apache-2.0
2727
licenses:
2828
- key: apache-2.0
29-
name: Apache License 2.0
29+
name: Apache 2.0
3030
file: apache-2.0.LICENSE
31+
url: https://scancode-licensedb.aboutcode.org/apache-2.0.LICENSE
3132
notice_file: httpd.NOTICE
3233
copyright: Copyright (c) 2012 The Apache Software Foundation.
3334

src/attributecode/cmd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def validate_template(ctx, param, value):
324324

325325
@click.option('--min-license-score',
326326
type=int,
327-
help='Attribute components that have license score higher than the defined '
327+
help='Attribute components that have license score higher than or equal to the defined '
328328
'--min-license-score.')
329329

330330
@click.option('--scancode',
@@ -363,7 +363,7 @@ def attrib(input, output, api_url, api_key, scancode, min_license_score, referen
363363
"""
364364
Generate an attribution document at OUTPUT using JSON, CSV or Excel or .ABOUT files at INPUT.
365365
366-
INPUT: Path to a file, directory or .zip archive containing .ABOUT files.
366+
INPUT: Path to a file (.ABOUT/.csv/.json/.xlsx), directory or .zip archive containing .ABOUT files.
367367
368368
OUTPUT: Path where to write the attribution document.
369369
"""

tests/testdata/test_cmd/help/about_attrib_help.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ Usage: about attrib [OPTIONS] INPUT OUTPUT
33
Generate an attribution document at OUTPUT using JSON, CSV or Excel or .ABOUT
44
files at INPUT.
55

6-
INPUT: Path to a file, directory or .zip archive containing .ABOUT files.
6+
INPUT: Path to a file (.ABOUT/.csv/.json/.xlsx), directory or .zip archive
7+
containing .ABOUT files.
78

89
OUTPUT: Path where to write the attribution document.
910

1011
Options:
1112
--api_url URL URL to DejaCode License Library.
1213
--api_key KEY API Key for the DejaCode License Library
1314
--min-license-score INTEGER Attribute components that have license score
14-
higher than the defined --min-license-score.
15+
higher than or equal to the defined --min-
16+
license-score.
1517
--scancode Indicate the input JSON file is from
1618
scancode_toolkit.
1719
--reference DIR Path to a directory with reference files where

0 commit comments

Comments
 (0)