From 365740f733eaff547041e7e8b2c64304a7dab8ac Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Tue, 28 Jan 2025 21:02:24 -0800 Subject: [PATCH 1/2] . --- docs/introduction/getting-started.mdx | 42 ++------- docs/introduction/installation.mdx | 6 +- docs/introduction/overview.mdx | 52 ++++++++++ docs/tutorials/at-a-glance.mdx | 131 +++++++++++++++++--------- 4 files changed, 147 insertions(+), 84 deletions(-) diff --git a/docs/introduction/getting-started.mdx b/docs/introduction/getting-started.mdx index cdb805452..cf7b8a1c6 100644 --- a/docs/introduction/getting-started.mdx +++ b/docs/introduction/getting-started.mdx @@ -15,42 +15,25 @@ Install [codegen](https://pypi.org/project/codegen/) on Pypi via [uv](https://gi uv tool install codegen ``` - - This makes the `codegen` command available globally in your terminal, while - keeping its dependencies isolated. - - - ## Quick Start with Jupyter 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. - - Prefer working in your IDE? See [IDE Usage](/introduction/ide-usage) - - - ```bash -# Navigate to your repository -cd path/to/git/repository - -# Initialize codegen and launch Jupyter with a demo notebook +# Launch Jupyter with a demo notebook codegen notebook --demo ``` -This will: - -1. Create a `.codegen/` directory with: - - `.venv/` - A dedicated virtual environment for this project - - `jupyter/` - Jupyter notebooks for exploring your code - - `config.toml` - Project configuration -2. Launch Jupyter Lab with a pre-configured notebook - The `notebook --demo` comes pre-configured to load [FastAPI](https://github.com/fastapi/fastapi)'s codebase , so you can start + The `notebook --demo` comes pre-configured to load [FastAPI](https://github.com/fastapi/fastapi)'s codebase, so you can start exploring right away! + + Prefer working in your IDE? See [IDE Usage](/introduction/ide-usage) + + ## Initializing a Codebase Instantiating a [Codebase](/api-reference/core/Codebase) will automatically parse a codebase and make it available for manipulation. @@ -58,12 +41,11 @@ Instantiating a [Codebase](/api-reference/core/Codebase) will automatically pars ```python from codegen import Codebase -# Initialize FastAPI codebase -print('Cloning and parsing FastAPI to /tmp/codegen/fastapi...') +# Clone + parse fastapi/fastapi codebase = Codebase.from_repo('fastapi/fastapi') -# To initialize an existing local codebase, use this constructor -# codebase = Codebase("path/to/git/repo") +# Or, parse a local repository +codebase = Codebase("path/to/git/repo") ``` @@ -71,12 +53,6 @@ codebase = Codebase.from_repo('fastapi/fastapi') parse all files in the codebase. Learn more about [parsing codebases here](/building-with-codegen/parsing-codebases) - - The initial parse may take a few minutes for large codebases. This - pre-computation enables constant-time operations afterward. [Learn more - here.](/introduction/how-it-works) - - ## Exploring Your Codebase Let's explore the codebase we just initialized. diff --git a/docs/introduction/installation.mdx b/docs/introduction/installation.mdx index 95d65149c..5be335995 100644 --- a/docs/introduction/installation.mdx +++ b/docs/introduction/installation.mdx @@ -16,8 +16,6 @@ curl -LsSf https://astral.sh/uv/install.sh | sh ## Installing Codegen -Install the Codegen CLI globally: - ```bash uv tool install codegen ``` @@ -29,14 +27,14 @@ This makes the `codegen` command available globally in your terminal, while keep ## Quick Start -Let's walk through a simple example of using Codegen in a project: +Let's walk through a minimal example of using Codegen in a project: 1. Navigate to your repository: ```bash cd path/to/your/project ``` -2. Initialize Codegen in your project: +2. Initialize Codegen in your project with [codegen init](/cli/init): ```bash codegen init ``` diff --git a/docs/introduction/overview.mdx b/docs/introduction/overview.mdx index 54e7981ea..97eee13d1 100644 --- a/docs/introduction/overview.mdx +++ b/docs/introduction/overview.mdx @@ -65,6 +65,58 @@ uv tool install codegen pip install codegen ``` +## What can I do with Codegen? + +Codegen enables you to programmatically manipulate code at scale. Here's a visualization of a real-world codebase's function call graph: + + + +Common use cases include: + + + + Generate interactive visualizations of your codebase's structure, dependencies, and relationships. + + + Create high-quality training data for fine-tuning LLMs on your codebase. + + + Add, remove, and update feature flags across your application. + + + Restructure files, enforce naming conventions, and improve project layout. + + + + + Codegen handles complex operations while maintaining correctness - automatically updating imports, references, and dependencies across files. + + ## Get Started import { diff --git a/docs/tutorials/at-a-glance.mdx b/docs/tutorials/at-a-glance.mdx index bd3a6b064..03dda7459 100644 --- a/docs/tutorials/at-a-glance.mdx +++ b/docs/tutorials/at-a-glance.mdx @@ -7,62 +7,75 @@ iconType: "solid" Explore our tutorials to learn how to use Codegen for various code transformation tasks. -## Modernization & Migration +## Featured Tutorials - Update API calls, handle breaking changes, and manage bulk updates across - your codebase. + Generate interactive visualizations of your codebase's structure, dependencies, and relationships. - - Migrate Python 2 code to Python 3, updating syntax and modernizing APIs. + + Create high-quality training data for fine-tuning LLMs on your codebase. - Update SQLAlchemy code to use the new 2.0-style query interface and - patterns. + Add, remove, and update feature flags across your application. - Convert unittest test suites to pytest's modern testing style. + Remove unused imports, functions, and variables with confidence. + + +## API Migrations + + - Add TypeScript types, infer types from usage, and improve type safety. + Update API calls, handle breaking changes, and manage bulk updates across your codebase. + + + Update SQLAlchemy code to use the new 2.0-style query interface and patterns. + Convert Flask applications to FastAPI, updating routes and dependencies. + + - Convert class components to hooks, organize components into files, and - extract prop types. + Migrate Python 2 code to Python 3, updating syntax and modernizing APIs. -## Code Quality & Organization +## Code Organization - - Remove unused imports, functions, and variables with confidence. - Restructure files, enforce naming conventions, and improve project layout. - + Split large files, extract shared logic, and manage dependencies. + + Organize and optimize TypeScript module exports. + + + Convert between default and named exports in TypeScript/JavaScript. + -## Documentation & Features +## Testing & Types - Generate JSDoc comments, README files, and API documentation. + Convert unittest test suites to pytest's modern testing style. - Add, remove, and update feature flags across your application. + Add TypeScript types, infer types from usage, and improve type safety. -## AI Integration +## Documentation & AI + + Generate JSDoc comments, README files, and API documentation. + - Generate system prompts, create hierarchical documentation, and optimize for - AI assistance. + Generate system prompts, create hierarchical documentation, and optimize for AI assistance. From 5362c2a0d0e0a71408adb6aaaf71242a8c05d9ee Mon Sep 17 00:00:00 2001 From: codegen-bot Date: Tue, 28 Jan 2025 21:13:44 -0800 Subject: [PATCH 2/2] . --- docs/building-with-codegen/codebase-visualization.mdx | 2 +- docs/mint.json | 4 ++-- docs/tutorials/codebase-visualization.mdx | 4 ++-- docs/tutorials/migrating-apis.mdx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/building-with-codegen/codebase-visualization.mdx b/docs/building-with-codegen/codebase-visualization.mdx index c08e3b0a4..da5e368f3 100644 --- a/docs/building-with-codegen/codebase-visualization.mdx +++ b/docs/building-with-codegen/codebase-visualization.mdx @@ -1,7 +1,7 @@ --- title: "Codebase Visualization" sidebarTitle: "Visualization" -icon: "chart-network" +icon: "share-nodes" iconType: "solid" --- diff --git a/docs/mint.json b/docs/mint.json index 1f9fd103b..8bed0b914 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -74,12 +74,12 @@ "tutorials/at-a-glance", "tutorials/migrating-apis", "tutorials/codebase-visualization", + "tutorials/training-data", "tutorials/organize-your-codebase", "tutorials/modularity", + "tutorials/manage-feature-flags", "tutorials/deleting-dead-code", "tutorials/increase-type-coverage", - "tutorials/training-data", - "tutorials/manage-feature-flags", "tutorials/managing-typescript-exports", "tutorials/converting-default-exports", "tutorials/creating-documentation", diff --git a/docs/tutorials/codebase-visualization.mdx b/docs/tutorials/codebase-visualization.mdx index 93c0e5003..e94752e43 100644 --- a/docs/tutorials/codebase-visualization.mdx +++ b/docs/tutorials/codebase-visualization.mdx @@ -1,8 +1,8 @@ --- title: "Codebase Visualization" -sidebarTitle: "Codebase Visualization" +sidebarTitle: "Visualization" description: "This guide will show you how to create codebase visualizations using [codegen](/introduction/overview)." -icon: "flashlight" +icon: "share-nodes" iconType: "solid" --- diff --git a/docs/tutorials/migrating-apis.mdx b/docs/tutorials/migrating-apis.mdx index 3e7d23b04..b42c010f9 100644 --- a/docs/tutorials/migrating-apis.mdx +++ b/docs/tutorials/migrating-apis.mdx @@ -1,6 +1,6 @@ --- title: "Migrating APIs" -sidebarTitle: "API Migration" +sidebarTitle: "API Migrations" icon: "arrows-rotate" iconType: "solid" ---