Skip to content

Document directory path markers in the FAQ - #168

Open
tongwentao wants to merge 1 commit into
cpburnz:masterfrom
tongwentao:docs/directory-path-matching
Open

tongwentao wants to merge 1 commit into
cpburnz:masterfrom
tongwentao:docs/directory-path-matching

Conversation

@tongwentao

@tongwentao tongwentao commented Oct 22, 2026 •

Copy link
Copy Markdown

Add a FAQ explaining why a directory-only gitignore pattern matches build/ but not the bare path build when using match_file() or match_files().

The distinction discussed in #89 is easy to miss: these methods match supplied paths without checking the filesystem, and pathlib.Path does not preserve a trailing slash. Include executable examples and point readers to the entry-based methods, which supply directory markers automatically. Matching behavior is unchanged.

Behavior and review notes

The examples distinguish matching a path string from discovering filesystem metadata. Creating a real directory named build does not make a bare build string acquire a directory marker in match_file(). Readers who already have filesystem entries are directed to the entry-based API instead of being advised to alter matching rules or assume Path preserves a trailing separator.

Validation on Linux, Python 3.13.5:

  • All five statements in the new FAQ passed with doctest.
  • The project's python -m unittest discover -t . -s tests/ command completed successfully. Optional RE2/Hyperscan cases were skipped because those extras are not installed.
  • The configured strict Sphinx command (sphinx-build -aWEnqb html) passed; checked the rendered FAQ and navigation.
  • git diff --check passed.

Related to #89; this documents the existing behavior rather than changing or closing that issue. Prepared and validated with Codex assistance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant