Skip to content

Commit 16e0453

Browse files
author
codegen-bot
committed
.
1 parent e43b9bb commit 16e0453

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/building-with-codegen/files-and-directories.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,32 @@ dir = file.directory
5050
exists = codebase.has_directory("path/to/dir")
5151
```
5252

53+
## Working with Non-Code Files (README, JSON, etc.)
54+
55+
By default, Codegen focuses on source code files (Python, TypeScript, etc). However, you can access all files in your codebase, including documentation, configuration, and other non-code files like README.md, package.json, or .env:
56+
57+
```python
58+
# Get all files in the codebase (including README, docs, config files)
59+
files = codebase.files(extensions="*")
60+
61+
# Print files that are not source code (documentation, config, etc)
62+
for file in files:
63+
if not file.filepath.endswith(('.py', '.ts', '.js')):
64+
print(f"📄 Non-code file: {file.filepath}")
65+
```
66+
67+
You can also filter for specific file types:
68+
69+
```python
70+
# Get only markdown documentation files
71+
docs = codebase.files(extensions=[".md", ".mdx"])
72+
73+
# Get configuration files
74+
config_files = codebase.files(extensions=[".json", ".yaml", ".toml"])
75+
```
76+
77+
These APIs are similar for [`Directory`](../api-reference/core/Directory), which provides similar methods for accessing files and subdirectories.
78+
5379
## Raw Content and Metadata
5480

5581
```python

0 commit comments

Comments
 (0)