diff --git a/README.md b/README.md index 7298ee3de..f448a7d61 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Graph sitter [![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-blue)](https://docs.codegen.com) -[![Upload Python Package](https://github.com/codegen-sh/codegen-sdk/actions/workflows/release.yml/badge.svg)](https://github.com/codegen-sh/codegen-sdk/actions/workflows/release.yml) [![Unit Tests](https://github.com/codegen-sh/codegen-sdk/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/codegen-sh/codegen-sdk/actions/workflows/unit-tests.yml) [Codegen](https://docs.codegen.com) is a python library for manipulating codebases. diff --git a/examples.md b/examples.md new file mode 100644 index 000000000..d46b0e7c5 --- /dev/null +++ b/examples.md @@ -0,0 +1,7 @@ +# Codegen Examples + +For practical examples of using Codegen in real-world scenarios, please visit our dedicated examples repository: + +[github.com/codegen-sh/codegen-examples](https://github.com/codegen-sh/codegen-examples) + +For docs and tutorials, please visit [docs.codegen.com](https://docs.codegen.com) diff --git a/python2_to_python3/README.md b/python2_to_python3/README.md deleted file mode 100644 index 4c9cbeb7b..000000000 --- a/python2_to_python3/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# Python 2 to Python 3 Migration Example - -[![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-blue)](https://docs.codegen.com/tutorials/python2-to-python3) - -This example demonstrates how to use Codegen to automatically migrate Python 2 code to Python 3. For a complete walkthrough, check out our [tutorial](https://docs.codegen.com/tutorials/python2-to-python3). - -## What This Example Does - -The migration script handles five key transformations: - -1. **Convert Print Statements** - ```python - # From: - print "Hello, world!" - print x, y, z - - # To: - print("Hello, world!") - print(x, y, z) - ``` - -2. **Update Unicode to str** - ```python - # From: - from __future__ import unicode_literals - text = unicode("Hello") - prefix = u"prefix" - - # To: - text = str("Hello") - prefix = "prefix" - ``` - -3. **Convert raw_input to input** - ```python - # From: - name = raw_input("Enter your name: ") - - # To: - name = input("Enter your name: ") - ``` - -4. **Update Exception Handling** - ```python - # From: - try: - process_data() - except ValueError, e: - print(e) - - # To: - try: - process_data() - except ValueError as e: - print(e) - ``` - -5. **Modernize Iterator Methods** - ```python - # From: - class MyIterator: - def next(self): - return self.value - - # To: - class MyIterator: - def __next__(self): - return self.value - ``` - -## Running the Example - -```bash -# Install Codegen -pip install codegen - -# Run the migration -python run.py -``` - -The script will process all Python files in the `repo-before` directory and apply the transformations in the correct order. - -## Understanding the Code - -- `run.py` - The migration script -- `repo-before/` - Sample Python 2 code to migrate -- `guide.md` - Additional notes and explanations - -## Learn More - -- [Full Tutorial](https://docs.codegen.com/tutorials/python2-to-python3) -- [Python 3 Documentation](https://docs.python.org/3/) -- [What's New in Python 3](https://docs.python.org/3/whatsnew/3.0.html) -- [Codegen Documentation](https://docs.codegen.com) \ No newline at end of file diff --git a/unittest_to_pytest/README.md b/unittest_to_pytest/README.md deleted file mode 100644 index 72cce5076..000000000 --- a/unittest_to_pytest/README.md +++ /dev/null @@ -1,95 +0,0 @@ -# unittest to pytest Migration Example - -[![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-blue)](https://docs.codegen.com/tutorials/unittest-to-pytest) - -This example demonstrates how to use Codegen to automatically migrate unittest test suites to pytest. For a complete walkthrough, check out our [tutorial](https://docs.codegen.com/tutorials/unittest-to-pytest). - -## What This Example Does - -The migration script handles four key transformations: - -1. **Convert Test Classes and Setup Methods** - ```python - # From: - class TestUsers(unittest.TestCase): - def setUp(self): - self.db = setup_test_db() - - def test_create_user(self): - user = self.db.create_user("test") - self.assertEqual(user.name, "test") - - # To: - @pytest.fixture - def db(): - db = setup_test_db() - yield db - - def test_create_user(db): - user = db.create_user("test") - assert user.name == "test" - ``` - -2. **Update Assertions** - ```python - # From: - def test_validation(self): - self.assertTrue(is_valid("test")) - self.assertEqual(count_items(), 0) - self.assertRaises(ValueError, parse_id, "invalid") - - # To: - def test_validation(): - assert is_valid("test") - assert count_items() == 0 - with pytest.raises(ValueError): - parse_id("invalid") - ``` - -3. **Convert Test Discovery** - ```python - # From: - if __name__ == '__main__': - unittest.main() - - # To: - # Remove unittest.main() and rename files to test_*.py - ``` - -4. **Modernize Fixtures** - ```python - # From: - @classmethod - def setUpClass(cls): - cls.conn = create_db() - - # To: - @pytest.fixture(scope="session") - def conn(): - return create_db() - ``` - -## Running the Example - -```bash -# Install Codegen -pip install codegen - -# Run the migration -python run.py -``` - -The script will process all Python test files in the `repo-before` directory and apply the transformations in the correct order. - -## Understanding the Code - -- `run.py` - The migration script -- `repo-before/` - Sample unittest test suite to migrate -- `guide.md` - Additional notes and explanations - -## Learn More - -- [Full Tutorial](https://docs.codegen.com/tutorials/unittest-to-pytest) -- [pytest Documentation](https://docs.pytest.org/) -- [unittest Documentation](https://docs.python.org/3/library/unittest.html) -- [Codegen Documentation](https://docs.codegen.com) \ No newline at end of file