Skip to content

Commit d9de949

Browse files
authored
Rpatel/embedded codemod widget (#63)
# Motivation <!-- Why is this change necessary? --> Adds a widget that allows the ability to run a codemod on some string content and view the output # Content <!-- Please include a summary of the change --> Adds an iframe on the overview.mdx doc page that points a codemod widget # 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 - [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 2ba1363 commit d9de949

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/introduction/overview.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,40 @@ iconType: "solid"
99

1010
It provides a scriptable interface to a powerful, multi-lingual language server built on top of [Tree-sitter](https://tree-sitter.github.io/tree-sitter/).
1111

12-
<iframe src="https://chadcode.sh/embedded/123" className="w-full h-96"></iframe>
12+
export const intoSnippet = `# grabs codebase content
13+
14+
file = codebase.files[0] # or .get_file("test.py")
15+
function = codebase.functions[0] # or .get_symbol("my_func")
16+
17+
# print logs
18+
19+
print(f'# of files: {len(codebase.files)}')
20+
print(f'# of functions: {len(codebase.functions)}')
21+
22+
# make edits
23+
24+
file.edit('🌈' + file.content) # edit contents
25+
function.rename('new_name') # rename
26+
function.set_docstring('new docstring') # set docstring
27+
28+
# ... etc.
29+
30+
`
31+
32+
<iframe
33+
width="100%"
34+
height="300px"
35+
scrolling="no"
36+
src={`https://www.chadcode.sh/embedded/codemod/?code=${encodeURIComponent(
37+
intoSnippet
38+
)}`}
39+
className="rounded-md"
40+
style={{
41+
borderRadius: "0.5rem",
42+
borderColor: "rgb(var(--primary-light))",
43+
borderWidth: "1px",
44+
}}
45+
></iframe>
1346

1447
## Installation
1548

0 commit comments

Comments
 (0)