Page MenuHomeSoftware Heritage

common/highlightjs: Use dynamically generated languages data
ClosedPublic

Authored by anlambert on Fri, Nov 20, 7:18 PM.

Details

Summary

Instead of hardcoding the set of supported programming languages and their
aliases in the common.highlightjs module, read those data from a JSON file
instead.

That JSON file is generated during frontend assets processing by webpack
by using the highlightjs library API.
This ensures languages data will always be in sync with current release
of the highlightjs library.

The produced JSON file is stored in git as it is needed to execute backend tests.
Its content might change each time a new release of highlightjs is available.

Test Plan

I have updated Python tests to match latest highlightjs release and ensured the
cypress tests related to languages highlighting I put in place some times ago
still pass (can be executed by invoking make test-frontend-full).

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Fri, Nov 20, 7:18 PM
anlambert updated this revision to Diff 16155.Fri, Nov 20, 7:20 PM

Update: Remove debug print

Build is green

Patch application report for D4551 (id=16154)

Rebasing onto 6cc8f01cce...

Current branch diff-target is up to date.
Changes applied before test
commit bd5ad05ea37fb8d5c2c1544c10c5a8b3cecb3e3b
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Nov 20 18:46:58 2020 +0100

    common/highlightjs: Use dynamically generated languages data
    
    Instead of hardcoding the set of supported programming languages and their
    aliases in the common.highlightjs module, read those data from a JSON file
    instead.
    
    That JSON file is generated during frontend assets processing by webpack.
    This ensures languages data will always be in sync with current release
    of the highlightjs library.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/487/ for more details.

Build is green

Patch application report for D4551 (id=16155)

Rebasing onto 6cc8f01cce...

Current branch diff-target is up to date.
Changes applied before test
commit 5c915825bd2ff1f9db5592cd702a6970c5fd483e
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Nov 20 18:46:58 2020 +0100

    common/highlightjs: Use dynamically generated languages data
    
    Instead of hardcoding the set of supported programming languages and their
    aliases in the common.highlightjs module, read those data from a JSON file
    instead.
    
    That JSON file is generated during frontend assets processing by webpack.
    This ensures languages data will always be in sync with current release
    of the highlightjs library.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/488/ for more details.

vlorentz accepted this revision.Mon, Nov 23, 10:41 AM
This revision is now accepted and ready to land.Mon, Nov 23, 10:41 AM