documentation for multi-part extensions and negative extensions

This commit is contained in:
David Cantrell 2022-06-05 01:28:00 +01:00
parent 3d13547612
commit bf7411ba26

View File

@ -152,6 +152,27 @@ format = '''
\$''' \$'''
``` ```
### File Extensions
Many modules have a `detect_extensions` variable, which takes a list of file extensions to match or not match.
"Negative" extensions, those which should not be matched, are indicated with a leading "!" character.
Extensions are matched against both the characters after the last dot in a filename, and the characters after
the first dot in a filename. For example, consider the filename `foo.bar.tar.gz`. To see if that matches anything
mentioned in `detect_extensions` we will consider both the characters after the last dot, "gz", and those after
the first dot, "bar.tar.gz".
We first look for any files matching a negative extension. If there are any, the module is not triggered.
If there were none, we then look for any files matching a positive extension.
To see how this works in practice, and why you might want to use negative extensions, consider how a Node
programmer who also works with video might configure the Nodejs module. By default its `detect_extensions`
is `["js", "mjs", "cjs", "ts", "mts", "cts"]`. However, in their video work they also deal with `.video.ts`
and `.audio.ts` files containing MPEG Transport Stream encoded data. They don't want a directory full of
video data to trigger the Nodejs module! So they add two negative extensions to the list:
`["js", "mjs", "cjs", "ts", "mts", "cts", "!audio.ts", "!video.ts"]`.
## Prompt ## Prompt
This is the list of prompt-wide configuration options. This is the list of prompt-wide configuration options.