Add a setting for mapping file extensions to syntax highlighters for diffs

Review Request #11821 — Created Sept. 24, 2021 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

Previously, we guess what syntax highlighting to apply to files in the diff
viewer given their data and file extension. Sometimes this guess would be wrong,
and we have no way of setting what type of syntax highlighting gets applied to
files. This change adds a setting for mapping file extensions to pygments
lexers (the syntax highlighters), namely
reviewboard.admin.siteconfig.diffviewer_custom_pygments_lexers. If a mapping
is not defined for a certain file extension, we revert to the old behaviour
of guessing which lexer to use given the filename and file contents.

Adds reviewboard.admin.form_widgets.LexersMappingWidget which partly
handles the UI for modifying this mapping.

  • Created unit tests for the mapping in
    reviewboard.diffviewer.tests.test_raw_diff_chunk_generator.
    Ran all unit tests in reviewboard.diffviewer with success
  • Created the unit tests for the LexersMappingWidget in
    reviewboard.admin.tests.test_lexers_mapping_widget.
    Ran all unit tests in reviewboard.admin.tests with success.

Changes between revision 20 and 21

orig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

Commits

Summary ID Author
resolved merge conflicts from reviewboard-5.0.x
updates
d9de4e339566468c528b53f6f36ede7f7bb1ec25 Michelle
resolved merge conflicts from reviewboard-5.0.x
updates
930128881e245f00cdc9f918b56bdf483d734336 Michelle
reviewboard/admin/form_widgets.py
reviewboard/diffviewer/chunk_generator.py
Loading...