Skip to content
Snippets Groups Projects
Commit c26464ce0781 authored by Steven Brown's avatar Steven Brown
Browse files

check-code: check for consistent usage of the websub filter in hgweb templates

The check-code tool now expects the "desc" keyword to be followed by the
"websub" filter, with the following exceptions:
a) It has no filters at all, e.g. a changeset description in the raw style
   templates or the repository description in the summary page.
b) It is followed by the "firstline" filter, e.g. the first line of the
   changeset description is displayed as a summary or title.
parent 16352b34e32e
No related branches found
No related tags found
No related merge requests found
......@@ -367,6 +367,16 @@
[]
]
webtemplatefilters = []
webtemplatepats = [
[],
[
(r'{desc(\|(?!websub|firstline)[^\|]*)+}',
'follow desc keyword with either firstline or websub'),
]
]
checks = [
('python', r'.*\.(py|cgi)$', r'^#!.*python', pyfilters, pypats),
('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats),
......@@ -377,6 +387,8 @@
('layering violation ui in util', r'mercurial/util\.py', '', pyfilters,
inutilpats),
('txt', r'.*\.txt$', '', txtfilters, txtpats),
('web template', r'mercurial/templates/.*\.tmpl', '',
webtemplatefilters, webtemplatepats),
]
def _preparepats():
......
......@@ -284,3 +284,19 @@
> print _(
don't use % inside _()
[1]
web templates
$ mkdir -p mercurial/templates
$ cat > mercurial/templates/example.tmpl <<EOF
> {desc}
> {desc|escape}
> {desc|firstline}
> {desc|websub}
> EOF
$ "$check_code" --warnings mercurial/templates/example.tmpl
mercurial/templates/example.tmpl:2:
> {desc|escape}
warning: follow desc keyword with either firstline or websub
[1]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment