Edgewall Software
Modify

Opened 4 years ago

Closed 4 years ago

#13251 closed enhancement (fixed)

Add switch to jinjachecker to suppress IGNORED messages

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.4.2
Component: general Version:
Severity: normal Keywords: jinja2
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

contrib/jinjachecker.py doesn't print ignored XHTML errors and HTML hints by default. Use the -i / --show-ignored switch to print the errors and hints. To validate HTML only, the --html-only must be used. The -h shortflag now prints the command line help.

Description

TracDev/ReleaseChecklist@150 adds a check of Jinja2 and HTML syntax. The output looks like the following:

# -- Jinja2 check for 'trac/templates/error.html'
# -- Jinja2 OK

# -- HTML check for 'trac/templates/error.html'
trac/templates/error.html:61:14: Element script does not carry attribute type (IGNORED "<script> without "type" attribute")
trac/templates/error.html:73:14: Element script does not carry attribute type (IGNORED "<script> without "type" attribute")
# -- HTML OK

For ease of inspecting output when errors are present, it would be nice to have a switch to suppress the IGNORED errors. For example, if I make about.html have duplicate id attributes, the end of the output is:

# -- HTML check for 'tracopt/ticket/templates/ticket_delete.html'
# -- HTML OK
One error found.
make: *** [jinja] Error 1

It can take a while to inspect all of the output and find the error:

# -- HTML check for 'trac/templates/about.html'
trac/templates/about.html:26:69: ID content already defined
# -- HTML 1 errors

Also, it seems the -q parameter must come after -h or -j. We should use the argparse module to simplify and make the argument parsing more robust.

Attachments (0)

Change History (5)

comment:1 by Ryan J Ollos, 4 years ago

Owner: set to Ryan J Ollos
Status: newassigned

comment:2 by Ryan J Ollos, 4 years ago

Proposed changes: [17c2bcca8/rjollos.git]

make jinja will not display ignored errors. To display ignored errors make jinja jinjaopts=-i.

comment:3 by Ryan J Ollos, 4 years ago

$ ./contrib/jinjachecker.py -h
usage: jinjachecker.py [-h] [-j] [--html-only] [-q] [-i]
                       TEMPLATE [TEMPLATE ...]

If no flags are given, both jinja and html checks will be performed. An
alternative usage is to run the tool via make, i.e. `make jinja`, which will
run the tool on all .html files.

positional arguments:
  TEMPLATE            path or glob of template(s) to check

optional arguments:
  -h, --help          show this help message and exit
  -j, --jinja-only    only check the jinja structure
  --html-only         only validate the HTML
  -q, --quiet         don't show the filtered content, only the errors
  -i, --show-ignored  show ignored XHTML errors and HTML hints

Rebased in [96a16e1eb/rjollos.git] with some minor changes:

comment:4 by Ryan J Ollos, 4 years ago

Internal Changes: modified (diff)

comment:5 by Ryan J Ollos, 4 years ago

Resolution: fixed
Status: assignedclosed

Committed to 1.4-stable in r17335, merged to trunk in r17336.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.