udoprog/genco
关于
A whitespace-aware quasiquoter for beautiful code generation.
开发工具实测星标增长
- 24小时
- +1
- 7天
- +1
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文genco
A whitespace-aware quasiquoter for beautiful code generation.
Central to genco are the quote! and quote_in! procedural macros which
ease the construction of token streams.
This project solves the following language-specific concerns:
Imports — Generates and groups import statements as they are used. So you only import what you use, with no redundancy. We also do our best to solve namespace conflicts.
String Quoting — genco knows how to quote strings. And can even interpolate values into the quoted string if it's supported by the language.
Structural Indentation — The quoter relies on intuitive whitespace detection to structurally sort out spacings and indentation. Allowing genco to generate beautiful readable code with minimal effort. This is also a requirement for generating correctly behaving code in languages like Python where indentation is meaningful.
Language Customization — Building support for new languages is a piece of cake with the help of the impl_lang! macro.
Supported Languages
The following are languages which have built-in support in genco.
Is your favorite language missing? Open an issue!
You can run one of the examples by:
cargo run --example rust
Rust Example
The following is a simple program producing Rust code to stdout with custom configuration:
use genco::prelude::*;
let hash_map = rust::import("std::collections", "HashMap");
let tokens: rust::Tokens = quote! {
fn main() {
let mut m = $hash_map::new();
m.insert(1u32, 2u32);
}
};
println!("{}", tokens.to_file_string()?);
This would produce:
use std::collections::HashMap;
fn main() {
let mut m = HashMap::new();
m.insert(1u32, 2u32);
}
探索相关项目
加载中…