Skip to content

Commit 75331b8

Browse files
authored
docs: removes code link backticks (#369)
# 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
1 parent 038f17c commit 75331b8

File tree

13 files changed

+96
-49
lines changed

13 files changed

+96
-49
lines changed

.codegen/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ prompts/
55
jupyter/
66
.venv/
77
codegen-system-prompt.txt
8+
*.txt
9+
*.pyc
810

911
# Python cache files
1012
__pycache__/
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import codegen
2+
from codegen import Codebase
3+
4+
5+
@codegen.function("no-link-backticks")
6+
def run(codebase: Codebase):
7+
import re
8+
9+
# Define the pattern for Markdown links with backticks in the link text
10+
link_pattern = re.compile(r"\[([^\]]*`[^\]]*`[^\]]*)\]\(([^)]+)\)")
11+
12+
# Iterate over all .mdx files in the codebase
13+
for file in codebase.files(extensions=["mdx"]):
14+
if file.extension == ".mdx":
15+
new_content = file.content
16+
17+
# Find all markdown links with backticks in link text
18+
matches = link_pattern.finditer(new_content)
19+
20+
for match in matches:
21+
# Original link text with backticks
22+
original_text = match.group(1)
23+
24+
# Remove backticks from the link text
25+
new_text = original_text.replace("`", "")
26+
27+
# Replace the link in content
28+
new_content = new_content.replace(match.group(0), f"[{new_text}]({match.group(2)})")
29+
30+
# Update file content if changes were made
31+
if new_content != file.content:
32+
file.edit(new_content)
33+
34+
# Commit all changes
35+
codebase.commit()
36+
37+
38+
if __name__ == "__main__":
39+
print("Parsing codebase...")
40+
codebase = Codebase("./")
41+
42+
print("Running function...")
43+
codegen.run(run)

docs/blog/fixing-import-loops.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Not all import cycles are problematic! Some cycles using dynamic imports can wor
110110

111111
PyTorch prevents most circular import issues through dynamic imports which can be seen through the `import_symbol.is_dynamic` property. If any edge in a strongly connected component is dynamic, runtime conflicts are typically resolved.
112112

113-
However, we discovered an import loop worth investigating between [`flex_decoding.py`](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/flex_decoding.py) and [`flex_attention.py`](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/flex_attention.py):
113+
However, we discovered an import loop worth investigating between [flex_decoding.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/flex_decoding.py) and [flex_attention.py](https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/flex_attention.py):
114114

115115
<img src="/images/problematic-import-loop.png" alt="Invalid import loop example" />
116116

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Codegen pre-computes dependencies and usages for all symbols in the codebase, en
1111

1212
Codegen provides two main ways to track relationships between symbols:
1313

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

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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ 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 (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))
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))
1818

1919
## Working with Names
2020

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

2323
```python
2424
# Access the name
@@ -35,7 +35,7 @@ name_node = function.get_name()
3535

3636
## Working with Values
3737

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

4040
```python
4141
# Access the value
@@ -52,7 +52,7 @@ if variable.value is not None:
5252

5353
## Working with Code Blocks
5454

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

5757
```python
5858
# Access the code block

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,20 @@ parent = dir.parent # Parent directory
191191

192192
## Editing Files Directly
193193

194-
Files themselves are [`Editable`](/api-reference/core/Editable.mdx) objects, just like Functions and Classes.
194+
Files themselves are [Editable](/api-reference/core/Editable.mdx) objects, just like Functions and Classes.
195195

196196
<Tip>
197197
Learn more about the [Editable API](/building-with-codegen/the-editable-api).
198198
</Tip>
199199

200200
This means they expose many useful operations, including:
201201

202-
- [`File.search`](/api-reference/core/File#search) - Search for all functions named "main"
203-
- [`File.edit`](/api-reference/core/File#edit) - Edit the file
204-
- [`File.replace`](/api-reference/core/File#replace) - Replace all instances of a string with another string
205-
- [`File.insert_before`](/api-reference/core/File#insert-before) - Insert text before a specific string
206-
- [`File.insert_after`](/api-reference/core/File#insert-after) - Insert text after a specific string
207-
- [`File.remove`](/api-reference/core/File#remove) - Remove a specific string
202+
- [File.search](/api-reference/core/File#search) - Search for all functions named "main"
203+
- [File.edit](/api-reference/core/File#edit) - Edit the file
204+
- [File.replace](/api-reference/core/File#replace) - Replace all instances of a string with another string
205+
- [File.insert_before](/api-reference/core/File#insert-before) - Insert text before a specific string
206+
- [File.insert_after](/api-reference/core/File#insert-after) - Insert text after a specific string
207+
- [File.remove](/api-reference/core/File#remove) - Remove a specific string
208208

209209
```python
210210
# Get a file
@@ -230,7 +230,7 @@ file.insert_after("def end():\npass")
230230
file.remove()
231231
```
232232

233-
You can frequently do bulk modifictions via the [`.edit(...)`](/api-reference/core/Editable#edit) method or [`.replace(...)`](/api-reference/core/File#replace) method.
233+
You can frequently do bulk modifictions via the [.edit(...)](/api-reference/core/Editable#edit) method or [.replace(...)](/api-reference/core/File#replace) method.
234234

235235
<Note>
236236
Most useful operations will have bespoke APIs that handle edge cases, update
@@ -239,7 +239,7 @@ You can frequently do bulk modifictions via the [`.edit(...)`](/api-reference/co
239239

240240
## Moving and Renaming Files
241241

242-
Files can be manipulated through methods like [`File.update_filepath()`](/api-reference/core/File#update-filepath), [`File.rename()`](/api-reference/core/File#rename), and [`File.remove()`](/api-reference/core/File#remove):
242+
Files can be manipulated through methods like [File.update_filepath()](/api-reference/core/File#update-filepath), [File.rename()](/api-reference/core/File#rename), and [File.remove()](/api-reference/core/File#remove):
243243

244244
```python
245245
# Move/rename a file
@@ -263,7 +263,7 @@ for file in codebase.files:
263263

264264
## Directories
265265

266-
[`Directories`](/api-reference/core/Directory) expose a similar API to the [File](/api-reference/core/File.mdx) class, with the addition of the `subdirectories` property.
266+
[Directories](/api-reference/core/Directory) expose a similar API to the [File](/api-reference/core/File.mdx) class, with the addition of the `subdirectories` property.
267267

268268
```python
269269
# Get a directory

docs/building-with-codegen/git-operations.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ sidebarTitle: "Git Operations"
44
icon: "code-branch"
55
---
66

7-
Many workflows require Git operations. Codegen provides a high-level API for common Git operations through the [`Codebase`](/api-reference/core/Codebase) class, including:
7+
Many workflows require Git operations. Codegen provides a high-level API for common Git operations through the [Codebase](/api-reference/core/Codebase) class, including:
88

9-
- [`Codebase.git_commit(...)`](/api-reference/core/Codebase#git_commit)
10-
- [`Codebase.checkout(...)`](/api-reference/core/Codebase#checkout)
9+
- [Codebase.git_commit(...)](/api-reference/core/Codebase#git_commit)
10+
- [Codebase.checkout(...)](/api-reference/core/Codebase#checkout)
1111

1212
## Committing Changes to Git
1313

14-
You can commit changes to Git using the [`Codebase.git_commit(...)`](/api-reference/core/Codebase#git_commit):
14+
You can commit changes to Git using the [Codebase.git_commit(...)](/api-reference/core/Codebase#git_commit):
1515

1616
```python
1717
# Make some changes and call `commit()` to sync them to disk
@@ -31,8 +31,8 @@ if commit:
3131

3232
<Note>
3333
`git_commit` will only commit changes that have been synced to the filesystem
34-
by calling [`Codebase.commit()`](/api-reference/core/Codebase#commit). See
35-
[`Commit and Reset`](/building-with-codegen/commit-and-reset) for more
34+
by calling [Codebase.commit()](/api-reference/core/Codebase#commit). See
35+
[Commit and Reset](/building-with-codegen/commit-and-reset) for more
3636
details.
3737
</Note>
3838

@@ -53,7 +53,7 @@ if current:
5353

5454
## Checking Out Branches and Commits
5555

56-
The [`Codebase.checkout(...)`](/api-reference/core/Codebase#checkout) method allows you to switch between branches and commits.
56+
The [Codebase.checkout(...)](/api-reference/core/Codebase#checkout) method allows you to switch between branches and commits.
5757

5858
This will automatically re-parse the codebase to reflect the new state.
5959

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/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)
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 ([`TSTypeAlias`](/api-reference/typescript/TSTypeAlias), [`TSInterface`](/api-reference/typescript/TSInterface))
95-
- **Exports**: Module exports and re-exports ([`TSExport`](/api-reference/typescript/TSExport))
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/moving-symbols.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ iconType: "solid"
77

88
Codegen provides fast, configurable and safe APIs for moving symbols (functions, classes, variables) between files while automatically handling imports and dependencies.
99

10-
The key API is [`Symbol.move_to_file(...)`](/api-reference/core/Symbol#move-to-file).
10+
The key API is [Symbol.move_to_file(...)](/api-reference/core/Symbol#move-to-file).
1111

1212
## Basic Symbol Movement
1313

14-
Simply call [`Symbol.move_to_file(...)`](/api-reference/core/Symbol#move-to-file) to move a symbol to a new file.
14+
Simply call [Symbol.move_to_file(...)](/api-reference/core/Symbol#move-to-file) to move a symbol to a new file.
1515

1616
```python
1717
# Manipulation code:
@@ -35,7 +35,7 @@ helper_func.move_to_file(file2)
3535

3636
## Moving Strategies
3737

38-
The [`Symbol.move_to_file(...)`](/api-reference/core/Symbol#move-to-file) method accepts a `strategy` parameter, which can be used to control how imports are updated.
38+
The [Symbol.move_to_file(...)](/api-reference/core/Symbol#move-to-file) method accepts a `strategy` parameter, which can be used to control how imports are updated.
3939

4040
Your options are:
4141

@@ -51,7 +51,7 @@ Your options are:
5151

5252
## Moving Symbols in Bulk
5353

54-
Make sure to call [`Codebase.commit(...)`](/api-reference/core/Codebase#commit) _after_ moving symbols in bulk for performant symbol movement.
54+
Make sure to call [Codebase.commit(...)](/api-reference/core/Codebase#commit) _after_ moving symbols in bulk for performant symbol movement.
5555

5656
```python
5757
# Move all functions with a specific prefix

docs/building-with-codegen/type-annotations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function.set_return_type("List[str]")
158158

159159
### Type Resolution
160160

161-
Type resolution uses [`Type.resolved_value`](/api-reference/core/Type#resolved-value) to get the actual symbols that a type refers to:
161+
Type resolution uses [Type.resolved_value](/api-reference/core/Type#resolved-value) to get the actual symbols that a type refers to:
162162

163163
```python
164164
# Get the actual symbols for a type

docs/introduction/work-with-ai.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525

2626
The [Codegen CLI](/cli/about) provides commands to generate `.md` files that can be fed to any AI assistant for more accurate and contextual help.
2727

28-
When you create a new codemod via [`codegen create`](/cli/create):
28+
When you create a new codemod via [codegen create](/cli/create):
2929

3030
```bash
3131
codegen create delete-dead-imports --description "Delete unused imports"
@@ -41,7 +41,7 @@ You can find this generated prompt in the `.codegen/prompts/<codemod-name>-syste
4141

4242
<Note>
4343
All contents of the `.codegen/prompts` directory are by default ignored the
44-
`.gitignore` file. after running [`codegen init`](/cli/init)
44+
`.gitignore` file. after running [codegen init](/cli/init)
4545
</Note>
4646

4747
This `.md` file can be used with any AI assistant (Claude, GPT-4, etc.) to get more accurate and contextual help.
@@ -50,7 +50,7 @@ This `.md` file can be used with any AI assistant (Claude, GPT-4, etc.) to get m
5050

5151
<Steps>
5252
<Step title="Create a codemod with description">
53-
Use the [`create` command](/cli/create) with a detailed description of what you want to accomplish:
53+
Use the [create command](/cli/create) with a detailed description of what you want to accomplish:
5454
```bash
5555
codegen create modernize-components --description "Convert class components to functional components with hooks"
5656
```

docs/tutorials/creating-documentation.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ iconType: "solid"
88
This guide demonstrates how to determine docs coverage and create documentation for your codebase.
99

1010
This primarily leverages two APIs:
11-
- [`codebase.ai(...)`](/api-reference/core/Codebase#ai) for generating docstrings
12-
- [`function.set_docstring(...)`](/api-reference/core/HasBlock#set-docstring) for modifying them
11+
- [codebase.ai(...)](/api-reference/core/Codebase#ai) for generating docstrings
12+
- [function.set_docstring(...)](/api-reference/core/HasBlock#set-docstring) for modifying them
1313

1414
## Determining Documentation Coverage
1515

@@ -74,7 +74,7 @@ Which provides the following output:
7474

7575
To identify areas of low documentation coverage, you can iterate through all directories and count the number of functions with docstrings.
7676

77-
<Note>Learn more about [`Directories` here](/building-with-codegen/files-and-directories).</Note>
77+
<Note>Learn more about [Directories here](/building-with-codegen/files-and-directories).</Note>
7878

7979
```python python
8080
# Track directory stats

src/codegen/cli/workspace/initialize_workspace.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def modify_gitignore(codegen_folder: Path):
147147
"__pycache__/",
148148
"*.py[cod]",
149149
"*$py.class",
150+
"*.txt",
151+
"*.pyc",
150152
"",
151153
"# Keep config.toml and codemods",
152154
"!config.toml",

0 commit comments

Comments
 (0)