Skip to content

Commit a2bfe98

Browse files
committed
CG-10491: Move skills testing + utils into tests/
1 parent 53e7e8a commit a2bfe98

File tree

131 files changed

+919
-1333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+919
-1333
lines changed

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import os
33

4-
from codegen.sdk.testing.models import Size
4+
from tests.shared.codemod.models import Size
55

66

77
def find_dirs_to_ignore(start_dir, prefix):

docs/introduction/about.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ We believe in the power of open source software. Our core library, [codegen](htt
6767
<Note>
6868
Want to learn more about what we're building? Check out our [getting started
6969
guide](/introduction/getting-started) or join our [community
70-
Slack](https://join.slack.com/t/codegen-community/shared_invite/...).
70+
Slack](https://community.codegen.com).
7171
</Note>

docs/introduction/community.mdx

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

8+
import {
9+
COMMUNITY_SLACK_URL,
10+
CODEGEN_SDK_GITHUB_URL,
11+
} from "/snippets/links.mdx";
12+
813
Join the growing Codegen community! We're excited to have you be part of our journey to make codebase manipulation and transformation more accessible.
914

1015
<CardGroup cols={2}>
11-
<Card
12-
title="Join our Slack"
13-
icon="slack"
14-
href="https://join.slack.com/t/codegen-community/shared_invite/..."
15-
>
16+
<Card title="Join our Slack" icon="slack" href={COMMUNITY_SLACK_URL}>
1617
Connect with the community, get help, and share your Codegen projects in our
1718
active Slack workspace.
1819
</Card>
19-
<Card
20-
title="GitHub"
21-
icon="github"
22-
href="https://github.com/codegen-sh/codegen-sdk"
23-
>
20+
<Card title="GitHub" icon="github" href={CODEGEN_SDK_GITHUB_URL}>
2421
Star us on GitHub, report issues, submit PRs, and contribute to the project.
2522
</Card>
2623
<Card title="Twitter (X)" icon="twitter" href="https://twitter.com/codegen">
@@ -43,7 +40,7 @@ Join the growing Codegen community! We're excited to have you be part of our jou
4340

4441
### Slack
4542

46-
Our Slack community is where you can:
43+
Our [Slack community](https://community.codegen.com) is where you can:
4744

4845
- Get help and support
4946
- Share your Codegen projects
@@ -52,7 +49,7 @@ Our Slack community is where you can:
5249

5350
### GitHub
5451

55-
Codegen is open source and we welcome contributions! On GitHub you can:
52+
Codegen is [open source](https://github.com/codegen-sh/codegen-sdk) and we welcome contributions! On GitHub you can:
5653

5754
- Report issues
5855
- Submit pull requests
@@ -61,7 +58,7 @@ Codegen is open source and we welcome contributions! On GitHub you can:
6158

6259
### Twitter (X)
6360

64-
Follow us on Twitter/X to:
61+
Follow us on [Twitter/X](https://x.com/codegen) to:
6562

6663
- Get the latest updates
6764
- See community highlights

docs/introduction/faq.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ iconType: "solid"
3737
title="How can I contribute if I'm new to the project?"
3838
icon="hand-holding-heart"
3939
>
40-
Start by trying out Codegen, joining our Slack community, and looking for
41-
issues labeled "good first issue" on GitHub. We welcome contributions to
40+
Start by trying out Codegen, joining our [Slack community](https://community.codegen.com), and looking for
41+
issues labeled "good first issue" on [GitHub](https://github.com/codegen-sh/codegen-sdk). We welcome contributions to
4242
documentation, examples, and code improvements.
4343
</Accordion>
4444
<Accordion title="Is Codegen free to use?" icon="scale-balanced">
4545
Yes, Codegen is [open source](https://github.com/codegen-sh/codegen-sdk) and free to use under the [Apache 2.0
46-
license](https://github.com/codegen-sh/codegen-cli?tab=Apache-2.0-1-ov-file).
46+
license](https://github.com/codegen-sh/codegen-sdk?tab=Apache-2.0-1-ov-file).
4747
You can use it for both personal and commercial projects.
4848
</Accordion>
4949
<Accordion title="Where can I get help if I'm stuck?" icon="life-ring">

docs/introduction/how-it-works.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Codegen performs advanced static analysis to build a rich graph representation o
1414
[rustworkx](https://github.com/Qiskit/rustworkx) and has implemented most
1515
language server features from scratch.
1616
</Note>
17+
<Info>
18+
Codegen is open source. Check out the [source
19+
code](https://github.com/codegen-sh/codegen-sdk) to learn more!
20+
</Info>
1721

1822
## The Codebase Graph
1923

@@ -71,7 +75,7 @@ Currently, Codegen supports:
7175

7276
We've started with these ecosystems but designed our architecture to be extensible. The graph-based approach provides a consistent interface across languages while handling language-specific details under the hood.
7377

74-
## Join the Journey
78+
## Build with Us
7579

7680
Codegen is just getting started, and we're excited about the possibilities ahead. We enthusiastically welcome contributions from the community, whether it's:
7781

@@ -82,4 +86,4 @@ Codegen is just getting started, and we're excited about the possibilities ahead
8286
- Adding new transformations
8387
- Improving documentation
8488

85-
Check out our [contribution guide](/introduction/community) to get involved!
89+
Check out our [community guide](/introduction/community) to get involved!

docs/introduction/overview.mdx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ pip install codegen
5252

5353
## Get Started
5454

55+
import {
56+
COMMUNITY_SLACK_URL,
57+
CODEGEN_SDK_GITHUB_URL,
58+
} from "/snippets/links.mdx";
59+
5560
<CardGroup cols={2}>
5661
<Card
5762
title="Get Started"
@@ -63,18 +68,10 @@ pip install codegen
6368
<Card title="Tutorials" icon="diagram-project" href="/tutorials/at-a-glance">
6469
Learn how to use Codegen for common code transformation tasks.
6570
</Card>
66-
<Card
67-
title="View on GitHub"
68-
icon="github"
69-
href="https://github.com/codegen-sh/codegen-sdk"
70-
>
71+
<Card title="View on GitHub" icon="github" href={CODEGEN_SDK_GITHUB_URL}>
7172
Star us on GitHub and contribute to the project.
7273
</Card>
73-
<Card
74-
title="Join our Slack"
75-
icon="slack"
76-
href="https://join.slack.com/t/codegen-community/shared_invite/..."
77-
>
74+
<Card title="Join our Slack" icon="slack" href={COMMUNITY_SLACK_URL}>
7875
Get help and connect with the Codegen community.
7976
</Card>
8077
</CardGroup>

docs/snippets/links.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const COMMUNITY_SLACK_URL = "https://community.codegen.com";
2+
3+
export const CODEGEN_SDK_GITHUB_URL =
4+
"https://github.com/codegen-sh/codegen-sdk";
5+
6+
export const CODEGEN_SDK_EXAMPLES_GITHUB_URL =
7+
"https://github.com/codegen-sh/codegen-examples";

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@ dependencies = [
2323
"networkx>=3.4.1",
2424
"wrapt<2.0.0,>=1.16.0",
2525
"pyright<2.0.0,>=1.1.372",
26-
"jsbeautifier<2.0.0,>=1.15.1",
2726
"watchfiles<1.1.0,>=1.0.0",
2827
"loguru<1.0.0,>=0.7.2",
2928
"rich<14.0.0,>=13.7.1",
30-
"inflection<1.0.0,>=0.5.1",
3129
"pydantic<3.0.0,>=2.9.2",
3230
"docstring-parser<1.0,>=0.16",
3331
"plotly<6.0.0,>=5.24.0",
3432
"humanize<5.0.0,>=4.10.0",
35-
"autoflake>=2.3.1",
36-
"black>=24.8.0",
3733
"pytest-snapshot>=0.9.0",
38-
"isort>=5.13.2",
3934
"anthropic==0.23.1",
4035
"pyjson5==1.6.8",
4136
"mini-racer>=0.12.4",
@@ -52,7 +47,6 @@ dependencies = [
5247
"hatchling>=1.25.0",
5348
"pyinstrument>=5.0.0",
5449
"pip>=24.3.1", # This is needed for some NPM/YARN/PNPM post-install scripts to work!
55-
"emoji>=2.14.0",
5650
"rich-click>=1.8.5",
5751
"python-dotenv>=1.0.1",
5852
"giturlparse",
@@ -110,6 +104,12 @@ dev-dependencies = [
110104
"deptry>=0.22.0",
111105
"cibuildwheel[uv]>=2.22.0",
112106
"sybil[pytest]>=9.0.0",
107+
"jsbeautifier<2.0.0,>=1.15.1",
108+
"inflection<1.0.0,>=0.5.1",
109+
"autoflake>=2.3.1",
110+
"black>=24.8.0",
111+
"isort>=5.13.2",
112+
"emoji>=2.14.0",
113113
]
114114
keyring-provider = "subprocess"
115115
#extra-index-url = ["https://[email protected]/pypi/codegen/simple/"]

src/codegen/gscli/generate/commands.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
import shutil
66

77
import click
8-
import inflection
98
from termcolor import colored
109

1110
from codegen.gscli.generate.runner_imports import _generate_runner_imports
1211
from codegen.gscli.generate.utils import LanguageType, generate_builtins_file
1312
from codegen.sdk.code_generation.codegen_sdk_codebase import get_codegen_sdk_codebase
1413
from codegen.sdk.code_generation.doc_utils.generate_docs_json import generate_docs_json
15-
from codegen.sdk.code_generation.doc_utils.skills import format_all_skills
1614
from codegen.sdk.code_generation.mdx_docs_generation import render_mdx_page_for_class
17-
from codegen.sdk.python import PyClass
18-
from codegen.sdk.skills.core.utils import get_all_skills, get_guide_skills_dict
1915

2016
logger = logging.getLogger(__name__)
2117

@@ -113,26 +109,6 @@ def generate_docs(docs_dir: str) -> None:
113109
# generate_guides(docs_dir)
114110

115111

116-
def generate_guides(docs_dir: str):
117-
"""Updates code snippets in the guides with the latest skill implementations"""
118-
guide_skills = get_guide_skills_dict()
119-
for guide_relative_path in guide_skills:
120-
guide_file_path = os.path.join(docs_dir, "api-reference", str(guide_relative_path) + ".mdx")
121-
122-
with open(guide_file_path) as f:
123-
file_content = f.read()
124-
125-
for skill in guide_skills[guide_relative_path]:
126-
# Perform the regex search and replace
127-
target_name = inflection.camelize(skill.name)
128-
pattern = get_snippet_pattern(target_name)
129-
replacement = f"[//]: # (--{target_name}--)\n[//]: # (--{AUTO_GENERATED_COMMENT}--)\n\n{skill.generate_snippet()}"
130-
file_content = re.sub(pattern, replacement, file_content, flags=re.DOTALL)
131-
132-
with open(guide_file_path, "w") as f:
133-
f.write(file_content)
134-
135-
136112
def get_snippet_pattern(target_name: str) -> str:
137113
pattern = rf"\[//\]: # \(--{re.escape(target_name)}--\)\s*(?:\[//\]: # \(--{re.escape(AUTO_GENERATED_COMMENT)}--\)\s*)?"
138114
pattern += CODE_SNIPPETS_REGEX
@@ -210,29 +186,3 @@ def generate_codegen_sdk_docs(docs_dir: str) -> None:
210186
json.dump(mint_data, mint_file, indent=2)
211187

212188
print(colored("Updated mint.json with new page sets", "green"))
213-
214-
215-
def generate_skills_docs(docs_dir: str) -> None:
216-
"""Generates docs for all skills"""
217-
print(colored("Generating skills docs", "green"))
218-
# Interim Modification: We need to refactor all skills
219-
skills = [skill for skill in get_all_skills() if not skill.guide]
220-
skills_doc = format_all_skills(skills)
221-
222-
# =====[ Write the skills docs to the file system ]=====
223-
core_dir = os.path.join(docs_dir, "codebase-sdk", "examples")
224-
file_path = os.path.join(core_dir, "skills.mdx")
225-
print(colored(f"> Writing to {file_path}", "green"))
226-
open(file_path, "w").write(skills_doc)
227-
228-
229-
def document_skill(skill: PyClass):
230-
return "skill" in [decorator.name for decorator in skill.decorators]
231-
232-
233-
def filter_class(cls: PyClass):
234-
for method in cls.methods:
235-
for decorator in method.decorators:
236-
if decorator.name == "skill_impl" and "external=True" in decorator.source:
237-
return True
238-
return False

src/codegen/gscli/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import click
55

6-
from codegen.gscli.codemod.commands import codemod
76
from codegen.gscli.generate.commands import generate
87

98

@@ -13,7 +12,6 @@ def cli() -> None:
1312

1413

1514
# ============= Import all command groups =============
16-
cli.add_command(codemod)
1715
cli.add_command(generate)
1816

1917

0 commit comments

Comments
 (0)