snake_case for module names
This commit is contained in:
parent
569563a564
commit
7c4cf38110
|
@ -6,6 +6,7 @@ use crate::gen::schema::*;
|
|||
use preserves::value::Map;
|
||||
|
||||
use super::CompilerConfig;
|
||||
use super::names;
|
||||
use super::types;
|
||||
|
||||
pub struct ModuleContext<'m> {
|
||||
|
@ -59,7 +60,7 @@ impl<'m> ModuleContext<'m> {
|
|||
} else {
|
||||
let mut items = Vec::new();
|
||||
items.push(item(self.config.fully_qualified_module_prefix.to_owned()));
|
||||
for p in &r.module.0 { items.push(item(p.to_owned())); }
|
||||
for p in &r.module.0 { items.push(item(names::render_modname(p))) }
|
||||
items.push(item(r.name.to_owned()));
|
||||
item(name(items))
|
||||
}
|
||||
|
|
|
@ -95,8 +95,9 @@ pub fn compile(config: &CompilerConfig) -> Result<(), std::io::Error> {
|
|||
for (k, v) in config.bundle.iter() {
|
||||
let mut output_path = config.output_dir.clone();
|
||||
output_path.extend(k);
|
||||
output_path.set_extension("rs");
|
||||
let module_name = output_path.file_stem().unwrap().to_str().unwrap().to_owned();
|
||||
let module_name = names::render_modname(&module_name);
|
||||
output_path.set_file_name(format!("{}.rs", module_name));
|
||||
DirBuilder::new().recursive(true).create(output_path.parent().unwrap())?;
|
||||
let mut m = context::ModuleContext::new(config);
|
||||
|
||||
|
|
|
@ -7,3 +7,7 @@ pub fn render_constructor(n: &str) -> String {
|
|||
pub fn render_fieldname(n: &str) -> String {
|
||||
n.to_case(Case::Snake)
|
||||
}
|
||||
|
||||
pub fn render_modname(n: &str) -> String {
|
||||
n.to_case(Case::Snake)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue