{"id":16376621,"url":"https://github.com/udoprog/genco","last_synced_at":"2025-05-15T04:06:32.364Z","repository":{"id":37740770,"uuid":"105711977","full_name":"udoprog/genco","owner":"udoprog","description":"A whitespace-aware quasiquoter for beautiful code generation.","archived":false,"fork":false,"pushed_at":"2025-04-28T03:02:06.000Z","size":734,"stargazers_count":191,"open_issues_count":6,"forks_count":13,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-15T04:06:23.935Z","etag":null,"topics":["code-generation","proc-macro","quasiquoter","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/udoprog.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-03T22:56:05.000Z","updated_at":"2025-04-27T23:54:30.000Z","dependencies_parsed_at":"2023-12-16T15:47:10.420Z","dependency_job_id":"60bbda01-b049-402e-949b-62d8771c1196","html_url":"https://github.com/udoprog/genco","commit_stats":{"total_commits":363,"total_committers":9,"mean_commits":"40.333333333333336","dds":0.03581267217630857,"last_synced_commit":"b376f2aeb0cb03dffb0a33e897a6ffc0d8a69828"},"previous_names":[],"tags_count":101,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udoprog%2Fgenco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udoprog%2Fgenco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udoprog%2Fgenco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udoprog%2Fgenco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/udoprog","download_url":"https://codeload.github.com/udoprog/genco/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270646,"owners_count":22042859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","proc-macro","quasiquoter","rust"],"created_at":"2024-10-11T03:25:20.730Z","updated_at":"2025-05-15T04:06:27.349Z","avatar_url":"https://github.com/udoprog.png","language":"Rust","readme":"# genco\n\n[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/github-udoprog/genco-8da0cb?style=for-the-badge\u0026logo=github\" height=\"20\"\u003e](https://github.com/udoprog/genco)\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/genco.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/genco)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-genco-66c2a5?style=for-the-badge\u0026logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K\" height=\"20\"\u003e](https://docs.rs/genco)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/udoprog/genco/ci.yml?branch=main\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/udoprog/genco/actions?query=branch%3Amain)\n\nA whitespace-aware quasiquoter for beautiful code generation.\n\nCentral to genco are the [quote!] and [quote_in!] procedural macros which\nease the construction of [token streams].\n\nThis project solves the following language-specific concerns:\n\n* **Imports** — Generates and groups [import statements] as they are used.\n  So you only import what you use, with no redundancy. We also do our best\n  to [solve namespace conflicts].\n\n* **String Quoting** — genco knows how to [quote strings]. And can even\n  [interpolate] values *into* the quoted string if it's supported by the\n  language.\n\n* **Structural Indentation** — The quoter relies on intuitive\n  [whitespace detection] to structurally sort out spacings and indentation.\n  Allowing genco to generate beautiful readable code with minimal effort.\n  This is also a requirement for generating correctly behaving code in\n  languages like Python where [indentation is meaningful].\n\n* **Language Customization** — Building support for new languages is a\n  piece of cake with the help of the [impl_lang!] macro.\n\n\u003cbr\u003e\n\nTo support line changes during [whitespace detection], we depend on the\nnightly [`proc_macro_span` feature]. On stable we can only detect column\nchanges.\n\n*Until this is stabilized* and you want fully functional whitespace\ndetection you must build and run projects using genco with a `nightly`\ncompiler. This is important for whitespace-sensitive languages like python.\n\nYou can try the difference between:\n\n```bash\ncargo run --example rust\n```\n\nAnd:\n\n```bash\ncargo +nightly run --example rust\n```\n\n[`proc_macro_span` feature]: https://github.com/rust-lang/rust/issues/54725\n\n\u003cbr\u003e\n\n## Supported Languages\n\nThe following are languages which have built-in support in genco.\n\n* [🦀 \u003cb\u003eRust\u003c/b\u003e][rust]\u003cbr\u003e\n  \u003csmall\u003e[Example][rust-example]\u003c/small\u003e\n\n* [☕ \u003cb\u003eJava\u003c/b\u003e][java]\u003cbr\u003e\n  \u003csmall\u003e[Example][java-example]\u003c/small\u003e\n\n* [🎼 \u003cb\u003eC#\u003c/b\u003e][c#]\u003cbr\u003e\n  \u003csmall\u003e[Example][c#-example]\u003c/small\u003e\n\n* [🐿️ \u003cb\u003eGo\u003c/b\u003e][go]\u003cbr\u003e\n  \u003csmall\u003e[Example][go-example]\u003c/small\u003e\n\n* [🎯 \u003cb\u003eDart\u003c/b\u003e][dart]\u003cbr\u003e\n  \u003csmall\u003e[Example][dart-example]\u003c/small\u003e\n\n* [🌐 \u003cb\u003eJavaScript\u003c/b\u003e][js]\u003cbr\u003e\n  \u003csmall\u003e[Example][js-example]\u003c/small\u003e\n\n* [🇨 \u003cb\u003eC\u003c/b\u003e][c]\u003cbr\u003e\n  \u003csmall\u003e[Example][c-example]\u003c/small\u003e\n\n* [🐍 \u003cb\u003ePython\u003c/b\u003e][python]\u003cbr\u003e\n  \u003csmall\u003e[Example][python-example]\u003c/small\u003e\u003cbr\u003e\n  **Requires a `nightly` compiler**\n\n\u003csmall\u003eIs your favorite language missing? \u003cb\u003e[Open an issue!]\u003c/b\u003e\u003c/small\u003e\n\nYou can run one of the examples by:\n\n```bash\ncargo +nightly run --example rust\n```\n\n\u003cbr\u003e\n\n## Rust Example\n\nThe following is a simple program producing Rust code to stdout with custom\nconfiguration:\n\n```rust\nuse genco::prelude::*;\n\nlet hash_map = rust::import(\"std::collections\", \"HashMap\");\n\nlet tokens: rust::Tokens = quote! {\n    fn main() {\n        let mut m = $hash_map::new();\n        m.insert(1u32, 2u32);\n    }\n};\n\nprintln!(\"{}\", tokens.to_file_string()?);\n```\n\nThis would produce:\n\n```rust,no_test\nuse std::collections::HashMap;\n\nfn main() {\n    let mut m = HashMap::new();\n    m.insert(1u32, 2u32);\n}\n```\n\n\u003cbr\u003e\n\n[c-example]: https://github.com/udoprog/genco/blob/master/examples/c.rs\n[c]: https://docs.rs/genco/latest/genco/lang/c/index.html\n[c#-example]: https://github.com/udoprog/genco/blob/master/examples/csharp.rs\n[c#]: https://docs.rs/genco/latest/genco/lang/csharp/index.html\n[dart-example]: https://github.com/udoprog/genco/blob/master/examples/dart.rs\n[dart]: https://docs.rs/genco/latest/genco/lang/dart/index.html\n[go-example]: https://github.com/udoprog/genco/blob/master/examples/go.rs\n[go]: https://docs.rs/genco/latest/genco/lang/go/index.html\n[impl_lang!]: https://docs.rs/genco/latest/genco/macro.impl_lang.html\n[import statements]: https://docs.rs/genco/latest/genco/macro.quote.html#imports\n[indentation is meaningful]: https://docs.python.org/3/faq/design.html#why-does-python-use-indentation-for-grouping-of-statements\n[interpolate]: https://docs.rs/genco/latest/genco/macro.quote.html#quoted-string-interpolation\n[java-example]: https://github.com/udoprog/genco/blob/master/examples/java.rs\n[java]: https://docs.rs/genco/latest/genco/lang/java/index.html\n[js-example]: https://github.com/udoprog/genco/blob/master/examples/js.rs\n[js]: https://docs.rs/genco/latest/genco/lang/js/index.html\n[Open an issue!]: https://github.com/udoprog/genco/issues/new\n[python-example]: https://github.com/udoprog/genco/blob/master/examples/python.rs\n[python]: https://docs.rs/genco/latest/genco/lang/python/index.html\n[quote strings]: https://docs.rs/genco/latest/genco/macro.quote.html#string-quoting\n[quote_in!]: https://docs.rs/genco/latest/genco/macro.quote_in.html\n[quote!]: https://docs.rs/genco/latest/genco/macro.quote.html\n[quoted()]: https://docs.rs/genco/latest/genco/tokens/fn.quoted.html\n[rust-example]: https://github.com/udoprog/genco/blob/master/examples/rust.rs\n[rust]: https://docs.rs/genco/latest/genco/lang/rust/index.html\n[solve namespace conflicts]: https://docs.rs/genco/latest/genco/lang/csharp/fn.import.html\n[token streams]: https://docs.rs/genco/latest/genco/tokens/struct.Tokens.html\n[whitespace detection]: https://docs.rs/genco/latest/genco/macro.quote.html#whitespace-detection\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudoprog%2Fgenco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fudoprog%2Fgenco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudoprog%2Fgenco/lists"}