Skip to content

Commit 1744b42

Browse files
authored
Update docs for include/exclude patterns for LocalFile. (#142)
1 parent 04031cf commit 1744b42

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

docs/docs/ops/sources.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ The `LocalFile` source imports files from a local file system.
1111

1212
The spec takes the following fields:
1313
* `path` (type: `str`, required): full path of the root directory to import files from
14-
* `binary` (type: `bool`, default: `False`): whether reading files as binary (instead of text)
14+
* `binary` (type: `bool`, optional): whether reading files as binary (instead of text)
15+
* `included_patterns` (type: `list[str]`, optional): a list of glob patterns to include files, e.g. `["*.txt", "docs/**/*.md"]`.
16+
If not specified, all files will be included.
17+
* `excluded_patterns` (type: `list[str]`, optional): a list of glob patterns to exclude files, e.g. `["tmp", "**/node_modules"]`.
18+
Any file or directory matching these patterns will be excluded even if they match `included_patterns`.
19+
If not specified, no files will be excluded.
20+
21+
:::info
22+
23+
`included_patterns` and `excluded_patterns` are using Unix-style glob syntax. See [globset syntax](https://docs.rs/globset/latest/globset/index.html#syntax) for the details.
24+
25+
:::
26+
1527

1628
The output is a table with the following sub fields:
1729
* `filename` (key, type: `str`): the filename of the file, including the path, relative to the root directory, e.g. `"dir1/file1.md"`

python/cocoindex/sources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class LocalFile(op.SourceSpec):
1010
binary: bool = False
1111

1212
# If provided, only files matching these patterns will be included.
13-
# See https://docs.rs/globset/latest/globset/index.html for the syntax of the patterns.
13+
# See https://docs.rs/globset/latest/globset/index.html#syntax for the syntax of the patterns.
1414
included_patterns: list[str] | None = None
1515

1616
# If provided, files matching these patterns will be excluded.
17-
# See https://docs.rs/globset/latest/globset/index.html for the syntax of the patterns.
17+
# See https://docs.rs/globset/latest/globset/index.html#syntax for the syntax of the patterns.
1818
excluded_patterns: list[str] | None = None

0 commit comments

Comments
 (0)