Skip to content

Commit 85e33c4

Browse files
jayhackcodegen-bot
and
codegen-bot
authored
docs: updates examples (#176)
# 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]>
1 parent 64631fa commit 85e33c4

File tree

8 files changed

+153
-90
lines changed

8 files changed

+153
-90
lines changed

docs/building-with-codegen/codebase-visualization.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Codebase Visualization"
33
sidebarTitle: "Visualization"
4-
icon: "chart-network"
4+
icon: "share-nodes"
55
iconType: "solid"
66
---
77

docs/introduction/getting-started.mdx

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,68 +15,44 @@ Install [codegen](https://pypi.org/project/codegen/) on Pypi via [uv](https://gi
1515
uv tool install codegen
1616
```
1717

18-
<Note>
19-
This makes the `codegen` command available globally in your terminal, while
20-
keeping its dependencies isolated.
21-
</Note>
22-
23-
2418
## Quick Start with Jupyter
2519

2620
The [codgen notebook](/cli/notebook) command creates a virtual environment and opens a Jupyter notebook for quick prototyping. This is often the fastest way to get up and running.
2721

28-
<Tip>
29-
Prefer working in your IDE? See [IDE Usage](/introduction/ide-usage)
30-
</Tip>
31-
32-
3322
```bash
34-
# Navigate to your repository
35-
cd path/to/git/repository
36-
37-
# Initialize codegen and launch Jupyter with a demo notebook
23+
# Launch Jupyter with a demo notebook
3824
codegen notebook --demo
3925
```
4026

41-
This will:
42-
43-
1. Create a `.codegen/` directory with:
44-
- `.venv/` - A dedicated virtual environment for this project
45-
- `jupyter/` - Jupyter notebooks for exploring your code
46-
- `config.toml` - Project configuration
47-
2. Launch Jupyter Lab with a pre-configured notebook
4827

4928
<Tip>
50-
The `notebook --demo` comes pre-configured to load [FastAPI](https://github.com/fastapi/fastapi)'s codebase , so you can start
29+
The `notebook --demo` comes pre-configured to load [FastAPI](https://github.com/fastapi/fastapi)'s codebase, so you can start
5130
exploring right away!
5231
</Tip>
5332

33+
<Note>
34+
Prefer working in your IDE? See [IDE Usage](/introduction/ide-usage)
35+
</Note>
36+
5437
## Initializing a Codebase
5538

5639
Instantiating a [Codebase](/api-reference/core/Codebase) will automatically parse a codebase and make it available for manipulation.
5740

5841
```python
5942
from codegen import Codebase
6043

61-
# Initialize FastAPI codebase
62-
print('Cloning and parsing FastAPI to /tmp/codegen/fastapi...')
44+
# Clone + parse fastapi/fastapi
6345
codebase = Codebase.from_repo('fastapi/fastapi')
6446

65-
# To initialize an existing local codebase, use this constructor
66-
# codebase = Codebase("path/to/git/repo")
47+
# Or, parse a local repository
48+
codebase = Codebase("path/to/git/repo")
6749
```
6850

6951
<Note>
7052
This will automatically infer the programming language of the codebase and
7153
parse all files in the codebase. Learn more about [parsing codebases here](/building-with-codegen/parsing-codebases)
7254
</Note>
7355

74-
<Tip>
75-
The initial parse may take a few minutes for large codebases. This
76-
pre-computation enables constant-time operations afterward. [Learn more
77-
here.](/introduction/how-it-works)
78-
</Tip>
79-
8056
## Exploring Your Codebase
8157

8258
Let's explore the codebase we just initialized.

docs/introduction/installation.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
1616

1717
## Installing Codegen
1818

19-
Install the Codegen CLI globally:
20-
2119
```bash
2220
uv tool install codegen
2321
```
@@ -29,14 +27,14 @@ This makes the `codegen` command available globally in your terminal, while keep
2927

3028
## Quick Start
3129

32-
Let's walk through a simple example of using Codegen in a project:
30+
Let's walk through a minimal example of using Codegen in a project:
3331

3432
1. Navigate to your repository:
3533
```bash
3634
cd path/to/your/project
3735
```
3836

39-
2. Initialize Codegen in your project:
37+
2. Initialize Codegen in your project with [codegen init](/cli/init):
4038
```bash
4139
codegen init
4240
```

docs/introduction/overview.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,58 @@ uv tool install codegen
6565
pip install codegen
6666
```
6767

68+
## What can I do with Codegen?
69+
70+
Codegen enables you to programmatically manipulate code at scale. Here's a visualization of a real-world codebase's function call graph:
71+
72+
<iframe
73+
width="100%"
74+
height="500px"
75+
scrolling="no"
76+
src={`https://codegen.sh/embedded/graph?id=299beefe-0207-43b6-bff3-6ca9036f62eb&zoom=0.5`}
77+
className="rounded-xl"
78+
style={{
79+
backgroundColor: "#15141b",
80+
}}
81+
></iframe>
82+
83+
Common use cases include:
84+
85+
<CardGroup cols={2}>
86+
<Card
87+
title="Visualize Your Codebase"
88+
icon="diagram-project"
89+
href="/tutorials/codebase-visualization"
90+
>
91+
Generate interactive visualizations of your codebase's structure, dependencies, and relationships.
92+
</Card>
93+
<Card
94+
title="Mine Codebase Data"
95+
icon="robot"
96+
href="/tutorials/training-data"
97+
>
98+
Create high-quality training data for fine-tuning LLMs on your codebase.
99+
</Card>
100+
<Card
101+
title="Eliminate Feature Flags"
102+
icon="flag"
103+
href="/tutorials/manage-feature-flags"
104+
>
105+
Add, remove, and update feature flags across your application.
106+
</Card>
107+
<Card
108+
title="Organize Your Codebase"
109+
icon="folder-tree"
110+
href="/tutorials/organize-your-codebase"
111+
>
112+
Restructure files, enforce naming conventions, and improve project layout.
113+
</Card>
114+
</CardGroup>
115+
116+
<Note>
117+
Codegen handles complex operations while maintaining correctness - automatically updating imports, references, and dependencies across files.
118+
</Note>
119+
68120
## Get Started
69121

70122
import {

docs/mint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@
7474
"tutorials/at-a-glance",
7575
"tutorials/migrating-apis",
7676
"tutorials/codebase-visualization",
77+
"tutorials/training-data",
7778
"tutorials/organize-your-codebase",
7879
"tutorials/modularity",
80+
"tutorials/manage-feature-flags",
7981
"tutorials/deleting-dead-code",
8082
"tutorials/increase-type-coverage",
81-
"tutorials/training-data",
82-
"tutorials/manage-feature-flags",
8383
"tutorials/managing-typescript-exports",
8484
"tutorials/converting-default-exports",
8585
"tutorials/creating-documentation",

docs/tutorials/at-a-glance.mdx

Lines changed: 84 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,103 +7,140 @@ iconType: "solid"
77

88
Explore our tutorials to learn how to use Codegen for various code transformation tasks.
99

10-
## Modernization & Migration
10+
## Featured Tutorials
1111

1212
<CardGroup cols={2}>
1313
<Card
14-
title="API Migrations"
15-
icon="arrow-right-arrow-left"
16-
href="/tutorials/migrating-apis"
14+
title="Visualize Your Codebase"
15+
icon="diagram-project"
16+
href="/tutorials/codebase-visualization"
1717
>
18-
Update API calls, handle breaking changes, and manage bulk updates across
19-
your codebase.
18+
Generate interactive visualizations of your codebase's structure, dependencies, and relationships.
2019
</Card>
21-
<Card title="Python 2 to 3" icon="snake" href="/tutorials/python2-to-python3">
22-
Migrate Python 2 code to Python 3, updating syntax and modernizing APIs.
20+
<Card
21+
title="Generate Training Data"
22+
icon="robot"
23+
href="/tutorials/training-data"
24+
>
25+
Create high-quality training data for fine-tuning LLMs on your codebase.
2326
</Card>
2427
<Card
25-
title="SQLAlchemy 1.6 to 2.0"
26-
icon="layer-group"
27-
href="/tutorials/sqlalchemy-1.6-to-2.0"
28+
title="Manage Feature Flags"
29+
icon="flag"
30+
href="/tutorials/manage-feature-flags"
2831
>
29-
Update SQLAlchemy code to use the new 2.0-style query interface and
30-
patterns.
32+
Add, remove, and update feature flags across your application.
3133
</Card>
3234
<Card
33-
title="unittest to pytest"
34-
icon="vial"
35-
href="/tutorials/unittest-to-pytest"
35+
title="Delete Dead Code"
36+
icon="broom"
37+
href="/tutorials/deleting-dead-code"
3638
>
37-
Convert unittest test suites to pytest's modern testing style.
39+
Remove unused imports, functions, and variables with confidence.
3840
</Card>
41+
</CardGroup>
42+
43+
## API Migrations
44+
45+
<CardGroup cols={2}>
3946
<Card
40-
title="Increase Type Coverage"
41-
icon="shield-check"
42-
href="/tutorials/increase-type-coverage"
47+
title="API Migration Guide"
48+
icon="arrow-right-arrow-left"
49+
href="/tutorials/migrating-apis"
4350
>
44-
Add TypeScript types, infer types from usage, and improve type safety.
51+
Update API calls, handle breaking changes, and manage bulk updates across your codebase.
52+
</Card>
53+
<Card
54+
title="SQLAlchemy 1.6 to 2.0"
55+
icon="layer-group"
56+
href="/tutorials/sqlalchemy-1.6-to-2.0"
57+
>
58+
Update SQLAlchemy code to use the new 2.0-style query interface and patterns.
4559
</Card>
4660
<Card
47-
title="React Modernization"
48-
icon="react"
49-
href="/tutorials/react-modernization"
61+
title="Flask to FastAPI"
62+
icon="bolt"
63+
href="/tutorials/flask-to-fastapi"
64+
>
65+
Convert Flask applications to FastAPI, updating routes and dependencies.
66+
</Card>
67+
<Card
68+
title="Python 2 to 3"
69+
icon="snake"
70+
href="/tutorials/python2-to-python3"
5071
>
51-
Convert class components to hooks, organize components into files, and
52-
extract prop types.
72+
Migrate Python 2 code to Python 3, updating syntax and modernizing APIs.
5373
</Card>
5474
</CardGroup>
5575

56-
## Code Quality & Organization
76+
## Code Organization
5777

5878
<CardGroup cols={2}>
59-
<Card
60-
title="Delete Dead Code"
61-
icon="broom"
62-
href="/tutorials/deleting-dead-code"
63-
>
64-
Remove unused imports, functions, and variables with confidence.
65-
</Card>
6679
<Card
6780
title="Organize Your Codebase"
6881
icon="folder-tree"
6982
href="/tutorials/organize-your-codebase"
7083
>
7184
Restructure files, enforce naming conventions, and improve project layout.
7285
</Card>
73-
<Card title="Improve Modularity" icon="cubes" href="/tutorials/modularity">
86+
<Card
87+
title="Improve Modularity"
88+
icon="cubes"
89+
href="/tutorials/modularity"
90+
>
7491
Split large files, extract shared logic, and manage dependencies.
7592
</Card>
93+
<Card
94+
title="Manage TypeScript Exports"
95+
icon="file-export"
96+
href="/tutorials/managing-typescript-exports"
97+
>
98+
Organize and optimize TypeScript module exports.
99+
</Card>
100+
<Card
101+
title="Convert Default Exports"
102+
icon="file-import"
103+
href="/tutorials/converting-default-exports"
104+
>
105+
Convert between default and named exports in TypeScript/JavaScript.
106+
</Card>
76107
</CardGroup>
77108

78-
## Documentation & Features
109+
## Testing & Types
79110

80111
<CardGroup cols={2}>
81112
<Card
82-
title="Create Documentation"
83-
icon="book"
84-
href="/tutorials/creating-documentation"
113+
title="unittest to pytest"
114+
icon="vial"
115+
href="/tutorials/unittest-to-pytest"
85116
>
86-
Generate JSDoc comments, README files, and API documentation.
117+
Convert unittest test suites to pytest's modern testing style.
87118
</Card>
88119
<Card
89-
title="Manage Feature Flags"
90-
icon="flag"
91-
href="/tutorials/manage-feature-flags"
120+
title="Increase Type Coverage"
121+
icon="shield-check"
122+
href="/tutorials/increase-type-coverage"
92123
>
93-
Add, remove, and update feature flags across your application.
124+
Add TypeScript types, infer types from usage, and improve type safety.
94125
</Card>
95126
</CardGroup>
96127

97-
## AI Integration
128+
## Documentation & AI
98129

99130
<CardGroup cols={2}>
131+
<Card
132+
title="Create Documentation"
133+
icon="book"
134+
href="/tutorials/creating-documentation"
135+
>
136+
Generate JSDoc comments, README files, and API documentation.
137+
</Card>
100138
<Card
101139
title="Prepare for AI"
102140
icon="robot"
103141
href="/tutorials/preparing-your-codebase-for-ai"
104142
>
105-
Generate system prompts, create hierarchical documentation, and optimize for
106-
AI assistance.
143+
Generate system prompts, create hierarchical documentation, and optimize for AI assistance.
107144
</Card>
108145
</CardGroup>
109146

docs/tutorials/codebase-visualization.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Codebase Visualization"
3-
sidebarTitle: "Codebase Visualization"
3+
sidebarTitle: "Visualization"
44
description: "This guide will show you how to create codebase visualizations using [codegen](/introduction/overview)."
5-
icon: "flashlight"
5+
icon: "share-nodes"
66
iconType: "solid"
77
---
88

docs/tutorials/migrating-apis.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Migrating APIs"
3-
sidebarTitle: "API Migration"
3+
sidebarTitle: "API Migrations"
44
icon: "arrows-rotate"
55
iconType: "solid"
66
---

0 commit comments

Comments
 (0)