Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/cyclomatic_complexity/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import codegen
from codegen import Codebase
from codegen.sdk.enums import ProgrammingLanguage
from codegen.sdk.core.statements.for_loop_statement import ForLoopStatement
from codegen.sdk.core.statements.if_block_statement import IfBlockStatement
from codegen.sdk.core.statements.try_catch_statement import TryCatchStatement
Expand Down Expand Up @@ -81,7 +82,7 @@ def calculate_cyclomatic_complexity(code_block):

if __name__ == "__main__":
print("🔍 Analyzing codebase...")
codebase = Codebase.from_repo("fastapi/fastapi", commit="887270ff8a54bb58c406b0651678a27589793d2f")
codebase = Codebase.from_repo("fastapi/fastapi", commit="887270ff8a54bb58c406b0651678a27589793d2f", programming_language=ProgrammingLanguage.PYTHON)

print("Running analysis...")
run(codebase)
25 changes: 18 additions & 7 deletions examples/document_functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ def hop_through_imports(imp: Import) -> Symbol | ExternalModule:
return imp.imported_symbol
```

## Usage
## Running the Conversion

1. Run the script on a target repository:
```python
codebase = Codebase.from_repo("your/repo", commit="commit_hash")
run(codebase)
```bash
# Install Codegen
pip install codegen

# Run the conversion
python run.py
```

2. The script will:
The script will:
- Process each function in the codebase
- Skip functions that already have docstrings
- Generate contextually aware docstrings for undocumented functions
Expand Down Expand Up @@ -81,4 +83,13 @@ The script provides detailed progress information:
- Documenting legacy codebases
- Maintaining documentation standards in large projects
- Onboarding new team members with better code documentation
- Preparing codebases for public release
- Preparing codebases for public release

## Learn More

- [Creating Documentation](https://docs.codegen.com/tutorials/creating-documentation#creating-documentation)
- [Codegen Documentation](https://docs.codegen.com)

## Contributing

Feel free to submit issues and enhancement requests!