Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following organizations or individuals have contributed to ScanCode:
- Horie Issei @is2ei
- James Ward @jamesward
- Jelmer Vernooij @jelmer
- Jens Keim @pepper-jk
- Kunal Chhabra @kunalchhabra37
- Jillian Daguil @jdaguil
- Jiri Popelka @jpopelka
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
Next release
--------------

- Enable License References table for HTML Output without requiring
`--license-references` by implementing a fallback license reference
collection based on the behavior of v32.0.0.
https://github.com/aboutcode-org/scancode-toolkit/pull/4474
https://github.com/aboutcode-org/scancode-toolkit/issues/4101


v32.4.1 - 2025-07-23
Expand Down
4 changes: 3 additions & 1 deletion docs/source/cli-reference/output-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ Comparing Different ``json`` Output Formats
- Copyright and Licenses Information
- File Information
- Package Information
- Licenses (Links to Dejacode/License Homepage)
- License References (SPDX ID, Links to spdx/scancode/licensedb/License Homepage)

.. include:: /rst_snippets/note_snippets/output_html_license_references.rst

.. figure:: data/output_html1.png

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. note::

For the license references table it is recommended to pass the ``--license-references`` argument.
However, there is a fall back implemented in case the ``license_references`` data is missing.
13 changes: 13 additions & 0 deletions src/formattedcode/output_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ def generate_output(results, license_references, version, template):
"""
# FIXME: This code is highly coupled with actual scans and may not
# support adding new scans at all

from licensedcode.cache import get_licenses_db

converted = {}
converted_infos = {}
converted_packages = {}
licenses = {}

LICENSES = 'license_detections'
COPYRIGHTS = 'copyrights'
Expand Down Expand Up @@ -223,6 +227,11 @@ def generate_output(results, license_references, version, template):
'value': license_expression,
})

if not license_references and license_expression not in licenses:
license_object = get_licenses_db().get(license_expression)
if license_object != None:
licenses[license_expression] = license_object

if results:
converted[path] = sorted(results, key=itemgetter('start'))

Expand All @@ -239,6 +248,10 @@ def generate_output(results, license_references, version, template):
if PACKAGES in scanned_file:
converted_packages[path] = scanned_file[PACKAGES]

if not license_references:
licenses = dict(sorted(licenses.items()))
license_references = list(licenses.values())

files = {
'license_copyright': converted,
'infos': converted_infos,
Expand Down