You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Motivation
<!-- Why is this change necessary? -->
# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review
- [ ] I have added tests for my changes
- [ ] I have updated the documentation or added new documentation as
needed
- [ ] I have read and agree to the [Contributor License
Agreement](../CLA.md)
---------
Co-authored-by: codegen-bot <[email protected]>
Copy file name to clipboardExpand all lines: docs/building-with-codegen/parsing-codebases.mdx
+80-7Lines changed: 80 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -9,21 +9,29 @@ The primary entrypoint to programs leveraging Codegen is the [Codebase](/api-ref
9
9
10
10
## Local Codebases
11
11
12
-
Construct a Codebase by passing in a path to a local `git` repository.
12
+
Construct a Codebase by passing in a path to a local `git` repository or any subfolder within it. The path must be within a git repository (i.e., somewhere in the parent directory tree must contain a `.git` folder).
commit='786a8ada7ed0c7f9d8b04d49f24596865e4b7901',# Optional: specific commit
50
59
shallow=False, # Optional: full clone instead of shallow
60
+
programming_language=ProgrammingLanguage.PYTHON# Optional: override language detection
51
61
)
52
62
```
53
63
@@ -56,6 +66,69 @@ codebase = codegen.from_repo(
56
66
default. The clone is shallow by default for better performance.
57
67
</Note>
58
68
69
+
## Configuration Options
70
+
71
+
You can customize the behavior of your Codebase instance by passing a `CodebaseConfig` object. This allows you to configure secrets (like API keys) and toggle specific features:
72
+
73
+
```python
74
+
from codegen import Codebase
75
+
from codegen.sdk.codebase.config import CodebaseConfig, GSFeatureFlags, Secrets
76
+
77
+
codebase = Codebase(
78
+
"path/to/repository",
79
+
config=CodebaseConfig(
80
+
secrets=Secrets(
81
+
openai_key="your-openai-key"# For AI-powered features
82
+
),
83
+
feature_flags=GSFeatureFlags(
84
+
sync_enabled=True, # Enable graph synchronization
85
+
...# Add other feature flags as needed
86
+
)
87
+
)
88
+
)
89
+
```
90
+
91
+
The `CodebaseConfig` allows you to configure:
92
+
-`secrets`: API keys and other sensitive information needed by the codebase
93
+
-`feature_flags`: Toggle specific features like language engines, dependency management, and graph synchronization
94
+
95
+
For a complete list of available feature flags and configuration options, see the [source code on GitHub](https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/codebase/config.py).
96
+
97
+
## Advanced Initialization
98
+
99
+
For more complex scenarios, Codegen supports an advanced initialization mode using `ProjectConfig`. This allows for fine-grained control over:
100
+
101
+
- Repository configuration
102
+
- Base path and subdirectory filtering
103
+
- Multiple project configurations
104
+
105
+
Here's an example:
106
+
107
+
```python
108
+
from codegen import Codebase
109
+
from codegen.git.repo_operator.local_repo_operator import LocalRepoOperator
110
+
from codegen.git.schemas.repo_config import BaseRepoConfig
111
+
from codegen.sdk.codebase.config import ProjectConfig
For more details on advanced configuration options, see the [source code on GitHub](https://github.com/codegen-sh/codegen-sdk/blob/develop/src/codegen/sdk/core/codebase.py).
raiseValueError("Cannot specify both projects and programming_language. Use ProjectConfig.from_path() to create projects with a custom programming_language.")
152
+
153
+
# If projects is a single ProjectConfig, convert it to a list
154
+
ifisinstance(projects, ProjectConfig):
155
+
projects= [projects]
156
+
149
157
# Initialize project with repo_path if projects is None
0 commit comments