Opened 5 years ago
Closed 5 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: |
|
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 , 5 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
comment:3 by , 5 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:
- Use sys.exit rather than exit.
- Print No errors on success.
comment:4 by , 5 years ago
Internal Changes: | modified (diff) |
---|
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Proposed changes: [17c2bcca8/rjollos.git]
make jinja
will not display ignored errors. To display ignored errorsmake jinja jinjaopts=-i
.