From 448b6849f63419298706edd5b948d97ca95b0667 Mon Sep 17 00:00:00 2001 From: Alpha DIALLO Date: Wed, 28 Feb 2024 12:45:08 +0100 Subject: [PATCH] doc: Move glob syntax to dune-glob Signed-off-by: Alpha DIALLO --- otherlibs/dune-glob/index.mld | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/otherlibs/dune-glob/index.mld b/otherlibs/dune-glob/index.mld index 5e4db9d6f38a..da75dd8ef5d9 100644 --- a/otherlibs/dune-glob/index.mld +++ b/otherlibs/dune-glob/index.mld @@ -6,6 +6,35 @@ A {e glob} is a way of referring to a set of files that match a certain pattern, such as "files with the [.ml] extension" or "files with [test] in their name". +The glob syntax is interpreted as follows: +- [\] matches exactly [], even if it's a special character + ([*], [?], ...). +- [*] matches any sequence of characters, except if it comes first, in which + case it matches any character that is not [.] followed by anything. +- [**] matches any character that is not [.] followed by anything, except if + it comes first, in which case it matches anything. +- [?] matches any single character. +- [[]] matches any character that is part of []. +- [[!]] matches any character that is not part of []. +- [{,,...,}] matches any string that is matched by one of + [] [] etc. + +{t + | Syntax | Files matched | Files not matched | + |-------------------|------------------------------------|-------------------------| + | [ x ] | [ x ] | [ y ] | + | [ \* ] | [ * ] | [ x ] | + | [ file*.txt ] | [ file1.txt ], [ file2.txt ] | [ f.txt ] | + | [ *.txt ] | [ f.txt ] | [ .hidden.txt ] | + | [ a** ] | [ aml ] | [ a.ml ] | + | [ ** ] | [ a/b ], [ a.b ] | (none) | + | [ a?.txt ] | [ a1.txt ], [ a2.txt ] | [ b1.txt ], [ a10.txt ] | + | [ f[xyz].txt ] | [ fx.txt ], [ fy.txt ], [ fz.txt ] | [ f2.txt ], [ f.txt ] | + | [ f[!xyz].txt ] | [ f2.txt ], [ fa.txt ] | [ fx.txt ], [ f.txt ] | + | [ a.{ml,mli} ] | [ a.ml ], [ a.mli ] | [ a.txt ], [ b.ml ] | + | [ ../a.{ml,mli} ] | [ ../a.ml ], [ ../a.mli ] | [ a.ml ] | +} + [dune-glob] exposes an abstraction so that we can refer to the first group as [*.ml] and the second one as [*test*].