Skip to content

Commit 01408fc

Browse files
committed
Rename @{has,matches}-literal to ...text
Reasons: 1. It's shorter. 2. `@matches-literal` seems to contradict itself: a regex is intrinsically not a literal match, while it is still a textual match.
1 parent 2787eb0 commit 01408fc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/etc/htmldocck.py

+7-7
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-literal PATH PATTERN` and `@matches-literal PATH PATTERN` checks
44+
* `@hastext PATH PATTERN` and `@matchestext PATH PATTERN` checks
4545
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-literal`, `PATTERN` is a whitespace-normalized (every consecutive
48+
For `@hastext`, `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-literal`, `PATTERN` is a Python-supported regular expression.
52+
For `@matchestext`, `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 in ['has', 'has-literal', 'matches', 'matches-literal']: # string test
545+
if c.cmd in ['has', 'hastext', 'matches', 'matchestext']: # string test
546546
regexp = c.cmd.startswith('matches')
547-
if len(c.args) == 1 and not regexp and 'literal' not in c.cmd: # @has <path> = file existence
547+
if len(c.args) == 1 and not regexp and 'text' 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 and 'literal' in c.cmd: # @has-literal/matches-literal <path> <pat> = string test
554+
elif len(c.args) == 2 and 'text' in c.cmd: # @hastext/matchestext <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 and 'literal' not in c.cmd: # @has/matches <path> <pat> <match> = XML tree test
557+
elif len(c.args) == 3 and 'text' 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)