Skip to content

Commit

Permalink
Merge pull request #144 from cornucopia-rs/convert_codegen_inner_attr…
Browse files Browse the repository at this point in the history
…s_to_outer

✨ Replace generated inner attrs with outer attrs.
  • Loading branch information
LouisGariepy authored Aug 28, 2022
2 parents 428c689 + f9e45f2 commit 0b8dad3
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 37 deletions.
13 changes: 9 additions & 4 deletions bench/usage/cornucopia_benches/generated_async.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod bench {
use cornucopia_async::GenericClient;
Expand Down
13 changes: 9 additions & 4 deletions bench/usage/cornucopia_benches/generated_sync.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod bench {
use postgres::{fallible_iterator::FallibleIterator, GenericClient};
Expand Down
13 changes: 9 additions & 4 deletions codegen_test/src/cornucopia_async.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {
pub mod public {
#[derive(serde::Serialize, Debug, postgres_types::FromSql, Clone, PartialEq)]
Expand Down Expand Up @@ -839,6 +840,10 @@ pub mod types {
}
}
}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod copy {
use cornucopia_async::GenericClient;
Expand Down
13 changes: 9 additions & 4 deletions codegen_test/src/cornucopia_sync.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {
pub mod public {
#[derive(serde::Serialize, Debug, postgres_types::FromSql, Clone, PartialEq)]
Expand Down Expand Up @@ -837,6 +838,10 @@ pub mod types {
}
}
}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod copy {
use postgres::{fallible_iterator::FallibleIterator, GenericClient};
Expand Down
27 changes: 18 additions & 9 deletions cornucopia/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,14 @@ fn gen_type_modules(
gen!(w, "pub mod {schema} {{ {tys_str} }}");
});

gen!(w, "pub mod types {{ {modules_str} }}");
gen!(
w,
"#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {{ {modules_str} }}"
);
}

pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> String {
Expand All @@ -626,13 +633,7 @@ pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> S
} else {
"use postgres::{{fallible_iterator::FallibleIterator,GenericClient}};"
};
let mut buff = "// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
"
.to_string();
let mut buff = "// This file was generated with `cornucopia`. Do not modify.\n\n".to_string();
// Generate database type
gen_type_modules(&mut buff, &preparation.types, settings);
// Generate queries
Expand All @@ -652,6 +653,14 @@ pub(crate) fn generate(preparation: Preparation, settings: CodegenSettings) -> S
module.info.name
);
});
gen!(&mut buff, "pub mod queries {{ {} }}", query_modules);
gen!(
&mut buff,
"#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {{ {} }}",
query_modules
);
buff
}
13 changes: 9 additions & 4 deletions examples/auto_build/src/cornucopia.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod module_1 {
use cornucopia_async::GenericClient;
Expand Down
13 changes: 9 additions & 4 deletions examples/basic_async/src/cornucopia.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {
pub mod public {
#[derive(
Expand All @@ -16,6 +17,10 @@ pub mod types {
}
}
}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod module_1 {
use cornucopia_async::GenericClient;
Expand Down
13 changes: 9 additions & 4 deletions examples/basic_sync/src/cornucopia.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// This file was generated with `cornucopia`. Do not modify.
#![allow(clippy::all, clippy::pedantic)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]

#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod types {
pub mod public {
#[derive(
Expand All @@ -16,6 +17,10 @@ pub mod types {
}
}
}
#[allow(clippy::all, clippy::pedantic)]
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
pub mod queries {
pub mod module_1 {
use postgres::{fallible_iterator::FallibleIterator, GenericClient};
Expand Down

0 comments on commit 0b8dad3

Please sign in to comment.