Page MenuHomeSoftware Heritage

common/highlightjs: Turn some global variables into functions
ClosedPublic

Authored by anlambert on Apr 20 2021, 3:30 PM.

Details

Summary

The _hljs_languages* global variables content rely on reading a JSON file
located through Django static finders.

As a side effect, when the module is imported, the JSON file is located
then read.

When the DJANGO_SETTINGS_MODULE environment variable is not set, the
module import will fail as the JSON file could not be located.

So avoid to execute that JSON loading code when importing the module
by turning the global variables into functions.

The purpose is to avoid import errors when running sphinx autodoc.

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

Build has FAILED

Patch application report for D5563 (id=19870)

Rebasing onto 4a6d884a74...

Current branch diff-target is up to date.
Changes applied before test
commit 2f83416d9f2a12bc9dc03f95cf6c2399a342b1c9
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Apr 20 15:00:54 2021 +0200

    common/highlightjs: Turn some global variables into functions
    
    The _hljs_languages* global variables content rely on reading a JSON file
    located through Django static finders.
    
    As a side effect, when the module is imported, the JSON file is located
    then read.
    
    When the DJANGO_SETTINGS_MODULE environment variable is not set, the
    module import will fail as the JSON file could not be located.
    
    So avoid to execute that JSON loading code when importing the module
    by turning the global variables into functions.
    
    The purpose is to avoid import errors when running sphinx autodoc.

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/698/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/698/console

Harbormaster returned this revision to the author for changes because remote builds failed.Apr 20 2021, 3:38 PM
Harbormaster failed remote builds in B20880: Diff 19870!

Build is green

Patch application report for D5563 (id=19870)

Rebasing onto 4a6d884a74...

Current branch diff-target is up to date.
Changes applied before test
commit 2f83416d9f2a12bc9dc03f95cf6c2399a342b1c9
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Apr 20 15:00:54 2021 +0200

    common/highlightjs: Turn some global variables into functions
    
    The _hljs_languages* global variables content rely on reading a JSON file
    located through Django static finders.
    
    As a side effect, when the module is imported, the JSON file is located
    then read.
    
    When the DJANGO_SETTINGS_MODULE environment variable is not set, the
    module import will fail as the JSON file could not be located.
    
    So avoid to execute that JSON loading code when importing the module
    by turning the global variables into functions.
    
    The purpose is to avoid import errors when running sphinx autodoc.

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

This revision is now accepted and ready to land.Apr 20 2021, 6:29 PM