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.

Diff Revision 17

This is not the most recent revision of the diff. The latest diff is revision 22. See what's changed.

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

Commits

First Last Summary ID Author
resolved merge conflicts from reviewboard-5.0.x
updates
c9a53a82a075528117ee4f95a14a0c88a2ab8be1 Michelle
docs/manual/admin/configuration/diffviewer-settings.rst
reviewboard/settings.py
reviewboard/admin/form_widgets.py
reviewboard/admin/siteconfig.py
reviewboard/admin/forms/diff_settings.py
reviewboard/admin/tests/test_lexers_mapping_widget.py
reviewboard/diffviewer/chunk_generator.py
reviewboard/diffviewer/tests/test_raw_diff_chunk_generator.py
Loading...