https://github.com/tamdaz/crygen
A library that allows to generate the Crystal code
https://github.com/tamdaz/crygen
code-generator crystal nette
Last synced: 3 months ago
JSON representation
A library that allows to generate the Crystal code
- Host: GitHub
- URL: https://github.com/tamdaz/crygen
- Owner: tamdaz
- License: mit
- Created: 2025-01-16T22:11:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-30T18:05:53.000Z (6 months ago)
- Last Synced: 2026-01-02T04:56:39.042Z (6 months ago)
- Topics: code-generator, crystal, nette
- Language: Crystal
- Homepage: https://tamdaz.github.io/crygen/
- Size: 924 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - crygen - A library that allows to generate the Crystal code (Project Generators)
README
# crygen






**crygen** is a library that allows to generate a Crystal file. It is inspired by the PHP
library : [nette/php-generator](https://github.com/nette/php-generator).
- Crygen documentation: https://tamdaz.github.io/crygen/
- API documentation: https://crystaldoc.info/github/tamdaz/crygen/main/index.html
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
crygen:
github: tamdaz/crygen
version: ~> 1.3.0
```
2. Run `shards install`
3. Finally, import `crygen` from the entrypoint file:
```cr
require "crygen"
module App
VERSION = "1.0.0"
class_type = CGT::Class.new("MyClass")
method_type = CGT::Method.new("my_method", "String")
class_type.add_method(method_type)
puts class_type.generate
# or
puts class_type
# Output:
# class MyClass
# def my_method : String
# end
# end
# You can save the generated code into the .cr file.
File.write("src/classes/my_class.cr", class_type)
end
```
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors