MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / write_index_file

Method write_index_file

sea-orm-codegen/src/entity/writer.rs:301–339  ·  view source on GitHub ↗
(&self, lib: bool, prelude: bool, seaography: bool)

Source from the content-addressed store, hash-verified

299 }
300
301 pub fn write_index_file(&self, lib: bool, prelude: bool, seaography: bool) -> OutputFile {
302 let mut lines = Vec::new();
303 Self::write_doc_comment(&mut lines);
304 let code_blocks: Vec<TokenStream> = self.entities.iter().map(Self::gen_mod).collect();
305 if prelude {
306 Self::write(
307 &mut lines,
308 vec![quote! {
309 pub mod prelude;
310 }],
311 );
312 lines.push("".to_owned());
313 }
314 Self::write(&mut lines, code_blocks);
315 if !self.enums.is_empty() {
316 Self::write(
317 &mut lines,
318 vec![quote! {
319 pub mod sea_orm_active_enums;
320 }],
321 );
322 }
323
324 if seaography {
325 lines.push("".to_owned());
326 let ts = Self::gen_seaography_entity_mod(&self.entities, &self.enums);
327 Self::write(&mut lines, vec![ts]);
328 }
329
330 let file_name = match lib {
331 true => "lib.rs".to_owned(),
332 false => "mod.rs".to_owned(),
333 };
334
335 OutputFile {
336 name: file_name,
337 content: lines.join("\n"),
338 }
339 }
340
341 pub fn write_prelude(&self, with_prelude: WithPrelude, frontend_format: bool) -> OutputFile {
342 let mut lines = Vec::new();

Callers 1

generateMethod · 0.80

Calls 3

pushMethod · 0.80
joinMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected