Document FilePattern elements

This commit is contained in:
Jeroen Engels 2024-06-12 17:00:17 +02:00
parent ac7811dec4
commit 6c94b2bf31

View File

@ -62,28 +62,53 @@ type FilePattern
| ExcludeDirectory String | ExcludeDirectory String
{-| REPLACEME {-| Create a `FilePattern` that includes files that match a Glob-like pattern.
[ FilePattern.include "CHANGELOG.md"
, FilePattern.include "src/**/*.elm"
, FilePattern.include "*.css"
]
-} -}
include : String -> FilePattern include : String -> FilePattern
include = include =
Include Include
{-| REPLACEME {-| Create a `FilePattern` that excludes files that match a Glob-like pattern.
[ FilePattern.include "**/*.css"
, FilePattern.exclude "exception.css"
]
Files that get excluded this way can be re-included through `FilePattern.include`.
[ FilePattern.include "**/*.css"
, FilePattern.exclude "exception-*.css"
, FilePattern.include "exception-among-exceptions.css"
]
-} -}
exclude : String -> FilePattern exclude : String -> FilePattern
exclude = exclude =
Exclude Exclude
{-| REPLACEME {-| Create a `FilePattern` that excludes a whole directory.
Files that get excluded this way can't be re-included.
[ FilePattern.include "**/*.css"
, FilePattern.excludeDirectory "build/"
]
-} -}
excludeDirectory : String -> FilePattern excludeDirectory : String -> FilePattern
excludeDirectory = excludeDirectory =
ExcludeDirectory ExcludeDirectory
{-| REPLACEME {-| Compiled version of a list of `FilePattern`s.
This is done to have good performance.
-} -}
type Summary type Summary
= Summary SummaryInfo = Summary SummaryInfo
@ -97,7 +122,8 @@ type alias SummaryInfo =
} }
{-| REPLACEME {-| Compile a list of `FilePattern`s.
This is done to have good performance.
-} -}
compact : List FilePattern -> Result (List String) Summary compact : List FilePattern -> Result (List String) Summary
compact filePatterns = compact filePatterns =
@ -282,7 +308,7 @@ addRawIncludeExclude string included summary =
} }
{-| REPLACEME {-| Check if a file path matches file patterns.
-} -}
match : { includeByDefault : Bool } -> Summary -> String -> Bool match : { includeByDefault : Bool } -> Summary -> String -> Bool
match { includeByDefault } (Summary summary) str = match { includeByDefault } (Summary summary) str =
@ -314,7 +340,7 @@ matchHelp includeByDefault filePatterns str =
matchHelp includeByDefault rest str matchHelp includeByDefault rest str
{-| REPLACEME {-| Stringify the file patterns in a way that is easily understandable by a JavaScript Glob-like API.
-} -}
toStrings : Summary -> { files : List { pattern : String, included : Bool }, excludedDirectories : List String } toStrings : Summary -> { files : List { pattern : String, included : Bool }, excludedDirectories : List String }
toStrings (Summary summary) = toStrings (Summary summary) =