Skip to content

Rename export feature to collect #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub enum MyEnum {
}

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
pub struct DontExportMe {
field: String,
}
Expand Down
2 changes: 1 addition & 1 deletion specta-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ proc-macro = true
[features]
default = []
# These will be enabled by `specta` or `specta-util` automatically as required. They depend on certain exports of it so enabling them manually is not useful.
DO_NOT_USE_export = []
DO_NOT_USE_collect = []
DO_NOT_USE_function = []

[lints]
Expand Down
2 changes: 1 addition & 1 deletion specta-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod utils;
/// Specta also introduces some of it's own attributes:
/// - `#[specta(optional)]` - When paired with an `Option<T>` field, this will result in `{ a?: T | null }` instead of `{ a: T | null }`.
/// - `#[specta(type = ::std::string::String)]` - Will override the type of a item, variant or field to a given type.
/// - `#[specta(export = false)]` - When using the `export` feature, this will prevent the specific type from being exported.
/// - `#[specta(collect = false)]` - When using the `collect` feature, this will prevent the specific type from being automatically collected.
///
/// ## Example
///
Expand Down
2 changes: 1 addition & 1 deletion specta-macros/src/type/attr/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl_parse! {
},
"inline" => out.inline = attr.parse_bool().unwrap_or(true),
"remote" => out.remote = out.remote.take().or(Some(attr.parse_path()?.to_token_stream())),
"export" => out.export = out.export.take().or(Some(attr.parse_bool().unwrap_or(true))),
"collect" => out.export = out.export.take().or(Some(attr.parse_bool().unwrap_or(true))),
"transparent" => out.transparent = attr.parse_bool().unwrap_or(true),
}
}
Expand Down
2 changes: 1 addition & 1 deletion specta-macros/src/type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn derive(input: proc_macro::TokenStream) -> syn::Result<proc_macro::TokenSt
}
});

let export = (cfg!(feature = "DO_NOT_USE_export") && container_attrs.export.unwrap_or(true))
let export = (cfg!(feature = "DO_NOT_USE_collect") && container_attrs.export.unwrap_or(true))
.then(|| {
let export_fn_name = format_ident!("__push_specta_type_{}", raw_ident);

Expand Down
2 changes: 1 addition & 1 deletion specta-typescript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ serde_yaml = "0.9.34"

[dev-dependencies]
serde = { version = "1", features = ["derive"] }
specta = { version = "=2.0.0-rc.22", path = "../specta", features = ["derive", "export"] }
specta = { version = "=2.0.0-rc.22", path = "../specta", features = ["derive", "collect"] }
specta-util = { path = "../specta-util", features = ["serde"] }
6 changes: 3 additions & 3 deletions specta-typescript/examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ pub struct Something {
// }

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
struct B {
b: u32,
c: C,
}

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
struct C {
b: u32,
}

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
struct A {
a: B,
c: C,
Expand Down
4 changes: 2 additions & 2 deletions specta-typescript/examples/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use std::{collections::HashMap, convert::Infallible, sync::Arc};
use specta::{Type, TypeCollection};

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
pub struct A {
pub a: String,
}

#[derive(Type)]
#[specta(export = false)]
#[specta(collect = false)]
pub struct B {
#[specta(flatten)]
pub a: A,
Expand Down
Loading
Loading