Skip to content

Commit 531ba3f

Browse files
Fixed broken links caught by mintlify (#79)
# Motivation There are broken links in the documentation # Content Modified various files in the docs that had faulty links # Testing This was tested using the mintlify CLI (`mintlify broken-links`) # Please check the following before marking your PR as ready for review - [x] I have added tests for my changes - [x] I have updated the documentation or added new documentation as needed - [x] I have read and agree to the [Contributor License Agreement](../CLA.md)
1 parent f64c1d4 commit 531ba3f

21 files changed

+108
-184
lines changed

docs/api-reference/index.mdx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ Welcome to the Codegen API reference. This documentation covers the core classes
2222
and call sites.
2323
</Card>
2424
<Card
25-
title="CallGraph"
25+
title="Symbol"
2626
icon="diagram-project"
27-
href="/api-reference/core/CallGraph"
27+
href="/api-reference/core/Symbol"
2828
>
29-
Navigate function calls and dependencies throughout your codebase.
29+
Represents a symbol in your codebase, includes functions, classes, and more.
3030
</Card>
3131
</CardGroup>
3232

@@ -45,24 +45,23 @@ Welcome to the Codegen API reference. This documentation covers the core classes
4545

4646
### Code Analysis
4747

48-
- [Finding Functions](/api-reference/core/Codebase#find_function)
49-
- [Analyzing Dependencies](/api-reference/core/CallGraph#get_dependencies)
50-
- [Working with ASTs](/api-reference/core/File#get_ast)
51-
- [Type Information](/api-reference/core/Function#get_type)
48+
- [Finding Functions](/api-reference/core/Codebase#get-function)
49+
- [Analyzing Dependencies](/api-reference/core/Symbol#dependencies)
50+
- [Analyzing Usages](/api-reference/core/Symbol#usages)
5251

5352
### Code Transformation
5453

5554
- [Editing Files](/api-reference/core/File#edit)
56-
- [Managing Imports](/api-reference/core/File#add_import)
57-
- [Renaming Symbols](/api-reference/core/Codebase#rename)
58-
- [Moving Code](/api-reference/core/File#move)
55+
- [Managing Imports](/api-reference/core/SourceFile#add-import-from-import-string)
56+
- [Renaming Symbols](/api-reference/core/Symbol#set-name)
57+
- [Managing Return Types](/api-reference/core/Function#set-return-type)
58+
- [Moving Code](/api-reference/core/Symbol#move-to-file)
5959

6060
### React & TypeScript
6161

62-
- [Component Analysis](/api-reference/typescript/ReactComponent)
63-
- [Type Definitions](/api-reference/typescript/TypeDefinition)
64-
- [JSX Manipulation](/api-reference/typescript/JSXElement)
65-
- [Props & State](/api-reference/typescript/Props)
62+
- [JSX Components](/api-reference/typescript/JSXElement)
63+
- [Props & State](/api-reference/typescript/JSXProp)
64+
- [Type Aliases](/api-reference/typescript/TSTypeAlias)
6665

6766
<Note>
6867
Each class and function includes detailed examples and common use cases. Use

docs/building-with-codegen/at-a-glance.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Learn how to use Codegen's core APIs to analyze and transform code.
3535
<Card
3636
title="Symbols, Functions and Classes"
3737
icon="pen-to-square"
38-
href="/building-with-codegen/symbols-functions-and-classes"
38+
href="/building-with-codegen/the-editable-api"
3939
>
4040
Master the core abstractions for manipulating code safely and effectively.
4141
</Card>

docs/building-with-codegen/class-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ icon: "cube"
55
iconType: "solid"
66
---
77

8-
The [Class](/api-reference/core/class.py) API extends the [Symbol](/building-with-codegen/symbol-api) API to support methods, attributes, and inheritance hierarchies.
8+
The [Class](/api-reference/core/Class) API extends the [Symbol](/building-with-codegen/symbol-api) API to support methods, attributes, and inheritance hierarchies.
99

1010
## Methods and Method Usages
1111

docs/building-with-codegen/collections.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ icon: "layer-group"
55
iconType: "solid"
66
---
77

8-
Codegen enables traversing and manipulating collections through the [Collection](../api-reference/core/Collection) class and its implementations [List](../api-reference/core/List) and [Dict](../api-reference/core/Dict).
8+
Codegen enables traversing and manipulating collections through the [List](/api-reference/core/List) and [Dict](/api-reference/core/Dict) classes.
99

1010
These APIs work consistently across Python and TypeScript while preserving formatting and structure.
1111

1212
## Core Concepts
1313

14-
The [Collection](../api-reference/core/Collection) class provides a consistent interface for working with ordered sequences of elements. Key features include:
14+
The [List](/api-reference/core/List) and [Dict](/api-reference/core/Dict) classes provide a consistent interface for working with ordered sequences of elements. Key features include:
1515

1616
- Standard sequence operations (indexing, length, iteration)
1717
- Automatic formatting preservation

docs/building-with-codegen/dependencies-and-usages.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This document explains how to use the dependency and usage tracking APIs in Code
1313

1414
Codegen provides two main ways to track relationships between symbols:
1515

16-
- [`.dependencies`](../api-reference/core/Symbol#dependencies) / [`.get_dependencies(...)`](../api-reference/core/Symbol#get_dependencies) - What symbols does this symbol depend on?
17-
- [`.usages`](../api-reference/core/Symbol.mdx#usages) / [`.usages(...)`](../api-reference/core/Symbol.mdx#usages) - Where is this symbol used?
16+
- [`.dependencies`](/api-reference/core/Symbol#dependencies) / [`.get_dependencies(...)`](/api-reference/core/Symbol#get-dependencies) - What symbols does this symbol depend on?
17+
- [`.usages`](/api-reference/core/Symbol#usages) / [`.usages(...)`](/api-reference/core/Symbol#usages) - Where is this symbol used?
1818

1919
Dependencies and usages are inverses of each other. For example, given the following input code:
2020

@@ -161,14 +161,14 @@ deps = my_class.get_dependencies(
161161
```python
162162
# Check if a symbol is unused
163163
def is_dead_code(symbol):
164-
return len(symbol.usages()) == 0
164+
return not symbol.usages
165165

166166
# Find all unused functions in a file
167-
dead_functions = [f for f in file.functions if is_dead_code(f)]
167+
dead_functions = [f for f in file.functions if not f.usages]
168168
```
169169

170170
<Tip>
171-
See [Finding Unused Code](/tutorials/dead-code) to learn more about finding
171+
See [Deleting Dead Code](/tutorials/deleting-dead-code) to learn more about finding
172172
unused code.
173173
</Tip>
174174

docs/building-with-codegen/editables-and-behaviors.mdx

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ This guide explains the key behaviors and how to use them effectively.
1111

1212
## Core Behaviors
1313

14-
- [`HasName`](../api-reference/interfaces/HasName): For elements with names (functions, classes, variables)
15-
- [`HasValue`](../api-reference/interfaces/HasValue): For elements with values (variables, parameters)
16-
- [`HasBlock`](../api-reference/interfaces/HasBlock): For elements containing code blocks (functions, classes)
17-
- [`HasAttribute`](../api-reference/interfaces/HasAttribute): For elements that can have attributes accessed
18-
- [`Editable`](../api-reference/interfaces/Editable): For elements that can be safely modified ([learn more](/building-with-codegen/the-editable-api))
14+
- [`HasName`](/api-reference/core/HasName): For elements with names (functions, classes, variables)
15+
- [`HasValue`](/api-reference/core/HasValue): For elements with values (variables, parameters)
16+
- [`HasBlock`](/api-reference/core/HasBlock): For elements containing code blocks (functions, classes)
17+
- [`Editable`](/api-reference/core/Editable): For elements that can be safely modified ([learn more](/building-with-codegen/the-editable-api))
1918

2019
## Working with Names
2120

22-
The [`HasName`](../api-reference/interfaces/HasName) behavior provides APIs for working with named elements:
21+
The [`HasName`](/api-reference/core/HasName) behavior provides APIs for working with named elements:
2322

2423
```python
2524
# Access the name
@@ -36,7 +35,7 @@ name_node = function.get_name()
3635

3736
## Working with Values
3837

39-
The [`HasValue`](../api-reference/interfaces/HasValue) behavior provides APIs for elements that have values:
38+
The [`HasValue`](/api-reference/core/HasValue) behavior provides APIs for elements that have values:
4039

4140
```python
4241
# Access the value
@@ -53,7 +52,7 @@ if variable.value is not None:
5352

5453
## Working with Code Blocks
5554

56-
The [`HasBlock`](../api-reference/interfaces/HasBlock) behavior provides APIs for elements containing code:
55+
The [`HasBlock`](/api-reference/core/HasBlock) behavior provides APIs for elements containing code:
5756

5857
```python
5958
# Access the code block
@@ -77,20 +76,20 @@ for fcall in function.function_calls:
7776

7877
## Working with Attributes
7978

80-
The [`HasAttribute`](../api-reference/interfaces/HasAttribute) behavior provides APIs for attribute access:
79+
The [get_attribute](/api-reference/core/Class#get-attribute) method provides APIs for attribute access:
8180

8281
```python
83-
# Resolve attributes
84-
attr = obj.resolve_attribute("property_name")
85-
if attr:
86-
print(f"Found attribute: {attr.name}")
87-
8882
# Common patterns
89-
class_attr = class_def.resolve_attribute("class_var")
83+
class_attr = class_def.get_attribute("attribute_name")
9084
if class_attr:
9185
print(f"Class variable value: {class_attr.value.source}")
9286
```
9387

88+
<Info>
89+
Learn more about [working with Attributes
90+
here](/building-with-codegen/class-api#class-attributes).
91+
</Info>
92+
9493
## Behavior Combinations
9594

9695
Many code elements inherit multiple behaviors. For example, a function typically has:
@@ -111,10 +110,3 @@ function.add_decorator("@timer")
111110
function.edit("def process_input():\n pass")
112111
```
113112

114-
## Best Practices
115-
116-
1. **Use Behavior APIs**: Prefer using behavior methods over direct manipulation
117-
2. **Check for None**: Some behavior properties may return None (e.g., value, docstring)
118-
3. **Update References**: Use methods like `rename()` that handle reference updates
119-
4. **Combine Behaviors**: Take advantage of behavior combinations for complex operations
120-
5. **Preserve Context**: Let the behaviors handle formatting and context preservation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ if main_function:
147147
Files themselves are [`Editable`](../api-reference/core/Editable.mdx) objects, just like Functions and Classes.
148148

149149
<Tip>
150-
Learn more about the [Editable API](/building-with-codegen/editable-api).
150+
Learn more about the [Editable API](/building-with-codegen/the-editable-api).
151151
</Tip>
152152

153153
This means they expose many useful operations, including:

docs/building-with-codegen/inheritable-behaviors.mdx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ This guide explains the key behaviors and how to use them effectively.
1111

1212
## Core Behaviors
1313

14-
- [HasName](../api-reference/core/HasName): For elements with [Names](/api-reference/core/Name) (Functions, Classes, Assignments, etc.)
15-
- [HasValue](../api-reference/core/HasValue): For elements with [Values](/api-reference/core/Value) (Arguments, Assignments, etc.)
16-
- [HasBlock](../api-reference/core/HasBlock): For elements containing [CodeBlocks](/api-reference/core/CodeBlock) (Files, Functions, Classes)
17-
- [HasAttribute](../api-reference/core/HasAttribute): For elements with [Attributes](/api-reference/core/Attribute) (Classes, Types, Inferfaces, etc.)
18-
- [Editable](../api-reference/core/Editable): For elements that can be safely modified ([learn more](/building-with-codegen/the-editable-api))
14+
- [HasName](/api-reference/core/HasName): For elements with [Names](/api-reference/core/Name) (Functions, Classes, Assignments, etc.)
15+
- [HasValue](/api-reference/core/HasValue): For elements with [Values](/api-reference/core/Value) (Arguments, Assignments, etc.)
16+
- [HasBlock](/api-reference/core/HasBlock): For elements containing [CodeBlocks](/api-reference/core/CodeBlock) (Files, Functions, Classes)
17+
- [Editable](/api-reference/core/Editable): For elements that can be safely modified ([learn more](/building-with-codegen/the-editable-api))
1918

2019
<Note>These "behaviors" are implemented as inherited classes.</Note>
2120

2221
## Working with Names
2322

24-
The [HasName](../api-reference/core/HasName) behavior provides APIs for working with named elements:
23+
The [HasName](/api-reference/core/HasName) behavior provides APIs for working with named elements:
2524

2625
```python
2726
# Access the name
@@ -38,7 +37,7 @@ name_node = function.get_name()
3837

3938
## Working with Values
4039

41-
The [HasValue](../api-reference/core/HasValue) behavior provides APIs for elements that have values:
40+
The [HasValue](/api-reference/core/HasValue) behavior provides APIs for elements that have values:
4241

4342
```python
4443
# Access the value
@@ -55,7 +54,7 @@ if variable.value is not None:
5554

5655
## Working with Code Blocks
5756

58-
The [HasBlock](../api-reference/core/HasBlock) behavior provides APIs for elements containing code:
57+
The [HasBlock](/api-reference/core/HasBlock) behavior provides APIs for elements containing code:
5958

6059
```python
6160
# Access the code block
@@ -71,16 +70,11 @@ printS(block.source)
7170

7271
## Working with Attributes
7372

74-
The [HasAttribute](api-reference/core/HasAttribute) behavior provides APIs for attribute access:
73+
The [get_attribute](/api-reference/core/Class#get-attribute) method provides APIs for attribute access:
7574

7675
```python
77-
# Resolve attributes
78-
attr = obj.resolve_attribute("property_name")
79-
if attr:
80-
print(f"Found attribute: {attr.name}")
81-
8276
# Common patterns
83-
class_attr = class_def.resolve_attribute("class_var")
77+
class_attr = class_def.get_attribute("attribute_name")
8478
if class_attr:
8579
print(f"Class variable value: {class_attr.value.source}")
8680
```

docs/building-with-codegen/language-support.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ TSCodebaseType = Codebase[
4848

4949
Every code element has both a Python and TypeScript implementation that inherits from a common base class. For example:
5050

51-
- [`Function`](../api-reference/core/Function)
52-
- [`PyFunction`](../api-reference/python/function.py)
53-
- [`TSFunction`](../api-reference/typescript/function.py)
54-
- [`Class`](../api-reference/core/Class)
55-
- [`PyClass`](../api-reference/python/class.py)
56-
- [`TSClass`](../api-reference/typescript/class.py)
57-
- [`Import`](../api-reference/core/Import)
58-
- [`PyImport`](../api-reference/python/import.py)
59-
- [`TSImport`](../api-reference/typescript/import.py)
51+
- [`Function`](/api-reference/core/Function)
52+
- [`PyFunction`](/api-reference/python/PyFunction)
53+
- [`TSFunction`](/api-reference/typescript/TSFunction)
54+
- [`Class`](/api-reference/core/Class)
55+
- [`PyClass`](/api-reference/python/PyClass)
56+
- [`TSClass`](/api-reference/typescript/TSClass)
57+
- [`Import`](/api-reference/core/Import)
58+
- [`PyImport`](/api-reference/python/PyImport)
59+
- [`TSImport`](/api-reference/typescript/TSImport)
6060

6161
...
6262

@@ -91,8 +91,8 @@ for function in codebase.functions:
9191

9292
Some features are only available in TypeScript codebases:
9393

94-
- **Types and Interfaces**: TypeScript's rich type system ([`TSType`](../api-reference/typescript/type.py), [`TSInterface`](../api-reference/typescript/interface.py))
95-
- **Exports**: Module exports and re-exports ([`TSExport`](../api-reference/typescript/export.py))
94+
- **Types and Interfaces**: TypeScript's rich type system ([`TSTypeAlias`](/api-reference/typescript/TSTypeAlias), [`TSInterface`](/api-reference/typescript/TSInterface))
95+
- **Exports**: Module exports and re-exports ([`TSExport`](/api-reference/typescript/TSExport))
9696
- **JSX/TSX**: React component handling (see [React and JSX](/building-with-codegen/react-and-jsx))
9797

9898
Example of TypeScript-specific features:

docs/building-with-codegen/parsing-codebases.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ icon: "power-off"
55
iconType: "solid"
66
---
77

8-
The primary entrypoint to programs leveraging Codegen is the [Codebase](../api-reference/core/Codebase) class.
8+
The primary entrypoint to programs leveraging Codegen is the [Codebase](/api-reference/core/Codebase) class.
99

1010
## Local Codebases
1111

@@ -61,5 +61,5 @@ codebase = codegen.from_repo(
6161
Codegen currently supports:
6262

6363
- [Python](/api-reference/python)
64-
- [TypeScript/JavaScript](/api-reference/javascript)
64+
- [TypeScript/JavaScript](/api-reference/typescript)
6565
- [React/JSX](/building-with-codegen/react-and-jsx)

docs/building-with-codegen/react-and-jsx.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ GraphSitter exposes several React and JSX-specific APIs for working with modern
99

1010
Key APIs include:
1111

12-
- [Function.is_jsx](../api-reference/core/Function#is_jsx) - Check if a function contains JSX elements
13-
- [Symbol.jsx_elements](../api-reference/core/Symbol#jsx_elements) - Get all JSX elements in a symbol
14-
- [JSXElement](../api-reference/core/JSXElement) - Manipulate JSX elements
15-
- [JSXProp](../api-reference/core/JSXProp) - Manipulate JSX props
12+
- [Function.is_jsx](/api-reference/typescript/TSFunction#is-jsx) - Check if a function contains JSX elements
13+
- [Class.jsx_elements](/api-reference/typescript/TSClass#jsx-elements) - Get all JSX elements in a class
14+
- [Function.jsx_elements](/api-reference/typescript/TSFunction#jsx-elements) - Get all JSX elements in a function
15+
- [JSXElement](/api-reference/typescript/JSXElement) - Manipulate JSX elements
16+
- [JSXProp](/api-reference/typescript/JSXProp) - Manipulate JSX props
1617

1718
<Tip>
1819
See [React Modernization](/tutorials/react-modernization) for tutorials and
@@ -35,9 +36,9 @@ is_component = class_def.is_jsx # True for React class components
3536

3637
## Working with JSX Elements
3738

38-
Given a React component, you can access its JSX elements using the [jsx_elements](../api-reference/core/Function#jsx-elements) property.
39+
Given a React component, you can access its JSX elements using the [jsx_elements](/api-reference/typescript/TSFunction#jsx-elements) property.
3940

40-
You can manipulate these elements by using the [JSXElement](../api-reference/core/JSXElement) and [JSXProp](../api-reference/core/JSXProp) APIs.
41+
You can manipulate these elements by using the [JSXElement](/api-reference/typescript/JSXElement) and [JSXProp](/api-reference/typescript/JSXProp) APIs.
4142

4243
```python
4344
# Get all JSX elements in a component

docs/building-with-codegen/symbol-api.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ icon: "shapes"
55
iconType: "solid"
66
---
77

8-
The [`Symbol`](/api-reference/core/symbol.py) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities.
8+
The [`Symbol`](/api-reference/core/Symbol) is the primary way developers interact with code in Codegen. It maps to how developers think about code - as functions, classes, variables, and other named entities.
99

10-
Both the [`Function`](/api-reference/core/function.py) and [`Class`](/api-reference/core/class.py) symbols are subclasses of the [`Symbol`](/api-reference/core/symbol.py) class.
10+
Both the [`Function`](/api-reference/core/Function) and [`Class`](/api-reference/core/Class) symbols are subclasses of the [`Symbol`](/api-reference/core/Symbol) class.
1111

1212
## Accessing Symbols
1313

14-
The [`Codebase`](/api-reference/core/codebase.py) class provides getters and iterators for functions, classes and symbols:
14+
The [`Codebase`](/api-reference/core/Codebase) class provides getters and iterators for functions, classes and symbols:
1515

1616
```python
1717
# Core symbol types
@@ -34,15 +34,15 @@ All symbols share common APIs for manipulation:
3434

3535
- The [`Editable`](/api-reference/core/Editable) API
3636
- Metadata
37-
- [`symbol.name`](/api-reference/core/symbol.py#name)
38-
- [`symbol.source`](/api-reference/core/symbol.py#source)
39-
- [`symbol.docstring`](/api-reference/core/symbol.py#docstring)
37+
- [`symbol.name`](/api-reference/core/Symbol#name)
38+
- [`symbol.source`](/api-reference/core/Symbol#source)
39+
- [`symbol.docstring`](/api-reference/core/Symbol#docstring)
4040
- Edit operations
41-
- [`symbol.set_docstring`](/api-reference/core/symbol.py#add_comment)
42-
- [`symbol.move_to_file`](/api-reference/core/symbol.py#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols))
41+
- [`symbol.set_docstring`](/api-reference/core/Symbol#add_comment)
42+
- [`symbol.move_to_file`](/api-reference/core/Symbol#move-to-file) (see [Moving Symbols](/building-with-codegen/moving-symbols))
4343
- Graph relations (See [Usages and Dependencies](/building-with-codegen/dependencies-and-usages))
44-
- [`symbol.usages`](/api-reference/core/symbol.py#usages)
45-
- [`symbol.dependencies`](/api-reference/core/symbol.py#dependencies)
44+
- [`symbol.usages`](/api-reference/core/Symbol#usages)
45+
- [`symbol.dependencies`](/api-reference/core/Symbol#dependencies)
4646

4747
## Name operations
4848

@@ -71,8 +71,8 @@ symbol.insert_after("# end deprecated")
7171

7272
Functions provide special APIs for adding statements to their body:
7373

74-
- [Function.prepend_statements](/api-reference/core/function.py#prepend_statements) - add statements to the start of the function body
75-
- [Function.add_statements](/api-reference/core/function.py#add_statements) - add statements to the end of the function body
74+
- [Function.prepend_statements](/api-reference/core/Function#prepend_statements) - add statements to the start of the function body
75+
- [Function.add_statements](/api-reference/core/Function#add_statements) - add statements to the end of the function body
7676

7777
```python
7878
# Add statements at the start of a function

0 commit comments

Comments
 (0)