Skip to content

Commit 2787eb0

Browse files
committed
Use different name for arity-2 @has and @matches
See #100354 for the rationale.
1 parent 46c59bb commit 2787eb0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/etc/htmldocck.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
`PATH` is relative to the output directory. It can be given as `-`
4242
which repeats the most recently used `PATH`.
4343
44-
* `@has PATH PATTERN` and `@matches PATH PATTERN` checks for
45-
the occurrence of the given pattern `PATTERN` in the specified file.
44+
* `@has-literal PATH PATTERN` and `@matches-literal PATH PATTERN` checks
45+
for the occurrence of the given pattern `PATTERN` in the specified file.
4646
Only one occurrence of the pattern is enough.
4747
48-
For `@has`, `PATTERN` is a whitespace-normalized (every consecutive
48+
For `@has-literal`, `PATTERN` is a whitespace-normalized (every consecutive
4949
whitespace being replaced by one single space character) string.
5050
The entire file is also whitespace-normalized including newlines.
5151
52-
For `@matches`, `PATTERN` is a Python-supported regular expression.
52+
For `@matches-literal`, `PATTERN` is a Python-supported regular expression.
5353
The file remains intact but the regexp is matched without the `MULTILINE`
5454
and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)`
5555
to override them, and `\A` and `\Z` for definitely matching
@@ -542,19 +542,19 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
542542
def check_command(c, cache):
543543
try:
544544
cerr = ""
545-
if c.cmd == 'has' or c.cmd == 'matches': # string test
546-
regexp = (c.cmd == 'matches')
547-
if len(c.args) == 1 and not regexp: # @has <path> = file existence
545+
if c.cmd in ['has', 'has-literal', 'matches', 'matches-literal']: # string test
546+
regexp = c.cmd.startswith('matches')
547+
if len(c.args) == 1 and not regexp and 'literal' not in c.cmd: # @has <path> = file existence
548548
try:
549549
cache.get_file(c.args[0])
550550
ret = True
551551
except FailedCheck as err:
552552
cerr = str(err)
553553
ret = False
554-
elif len(c.args) == 2: # @has/matches <path> <pat> = string test
554+
elif len(c.args) == 2 and 'literal' in c.cmd: # @has-literal/matches-literal <path> <pat> = string test
555555
cerr = "`PATTERN` did not match"
556556
ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)
557-
elif len(c.args) == 3: # @has/matches <path> <pat> <match> = XML tree test
557+
elif len(c.args) == 3 and 'literal' not in c.cmd: # @has/matches <path> <pat> <match> = XML tree test
558558
cerr = "`XPATH PATTERN` did not match"
559559
ret = get_nb_matching_elements(cache, c, regexp, True) != 0
560560
else:

0 commit comments

Comments
 (0)