Skip to content
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

Restructure #247

Merged
merged 12 commits into from
Jun 28, 2024
Prev Previous commit
Next Next commit
new crates + string concatenation
Brendonovich committed Jun 16, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 239464398175a2b853320bc1a6b3c8b66c1c954f
140 changes: 3 additions & 137 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,137 +1,3 @@
[package]
name = "specta"
description = "Easily export your Rust types to other languages"
version = "2.0.0-rc.12"
authors = ["Oscar Beaumont <oscar@otbeaumont.me>"]
edition = "2021"
license = "MIT"
include = ["/src", "/examples", "/LICENCE", "/README.md"]
repository = "https://github.com/oscartbeaumont/specta"
documentation = "https://docs.rs/specta/latest/specta"
keywords = ["async", "specta", "rspc", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]
autotests = false

# /bin/sh RUSTDOCFLAGS="--cfg docsrs2" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = ["--cfg", "docsrs2"] # TODO: Rename to `docsrs2` once Tokio fixes https://github.com/tokio-rs/tokio/pull/6360

[[test]]
name = "integration_tests"
path = "tests/lib.rs"
harness = true

# Run `node ./.github/features.js` to update the docs
[features]
default = []

#! Features
## Support for exporting the types of Rust functions.
function = ["serde", "specta-macros/function"]

#! Languages
## Support for [TypeScript](https://www.typescriptlang.org) language exporting
typescript = ["serde"] # TODO: Probally don't keep `serde` here for v2???
## Support for [JSDoc](https://jsdoc.app) exporting helpers.
## Also requires `typescript` feature to be enabled.
js_doc = []
# ## Support for [Rust](https://www.rust-lang.org) language exporting
# rust = []
# ## Support for [Swift](https://www.swift.org/) language exporting
# swift = []
# ## Support for [Kotlin](https://kotlinlang.org/) language exporting
# kotlin = []
# ## Support for [Go Lang](https://go.dev/) language exporting
# go = []
# ## Support for [OpenAPI](https://www.openapis.org) language exporting
# openapi = ["dep:openapiv3"]

#! Compatability
## Support for [serde](https://serde.rs)
serde = ["dep:serde", "specta-macros/serde"]
## Support for [serde-json](https://github.com/serde-rs/json)
serde_json = ["dep:serde_json"]
## Support for [serde_yaml](https://github.com/dtolnay/serde-yaml)
serde_yaml = ["dep:serde_yaml"]
## Support for [toml](https://github.com/toml-rs/toml)
toml = ["dep:toml"]

#! External types
## [uuid](https://docs.rs/uuid) crate
uuid = ["dep:uuid"]
## [uuid](https://docs.rs/ulid) crate
ulid = ["dep:ulid"]
## [chrono](https://docs.rs/chrono) crate
chrono = ["dep:chrono"]
## [time](https://docs.rs/time) crate
time = ["dep:time"]
## [bigdecimal](https://docs.rs/bigdecimal) crate
bigdecimal = ["dep:bigdecimal"]
## [rust_decimal](https://docs.rs/rust_decimal) crate
rust_decimal = ["dep:rust_decimal"]
## [indexmap](https://docs.rs/indexmap) crate
indexmap = ["dep:indexmap"]
## [ipnetwork](https://docs.rs/ipnetwork) crate
ipnetwork = ["dep:ipnetwork"]
## [mac_address](https://docs.rs/mac_address) crate
mac_address = ["dep:mac_address"]
## [bit-vec](https://docs.rs/bit-vec) crate
bit-vec = ["dep:bit-vec"]
## [bson](https://docs.rs/bson) crate
bson = ["dep:bson"]
## [uhlc](https://docs.rs/uhlc) crate
uhlc = ["dep:uhlc"]
## [bytesize](https://docs.rs/bytesize) crate
bytesize = ["dep:bytesize"]
## [glam](https://docs.rs/glam) crate
glam = ["dep:glam"]
## [tokio](https://docs.rs/tokio) crate
tokio = ["dep:tokio"]
## [url](https://docs.rs/url) crate
url = ["dep:url"]
## [either](https://docs.rs/either) crate
either = ["dep:either"]
# [bevy_ecs](https://docs.rs/bevy_ecs) crate
bevy_ecs = ["dep:bevy_ecs"]
# [bevy_input](https://docs.rs/bevy_input) crate
bevy_input = ["dep:bevy_input", "dep:bevy_ecs", "dep:glam"]

# Internal features (unstable)
interop = ["dep:specta1"]

[dependencies]
specta-macros = { version = "=2.0.0-rc.10", path = "./macros" }
serde = { version = "1.0.183", optional = true, default-features = false, features = ["derive"] }
serde_json = { version = "1.0.104", optional = true, default-features = false, features = ["std"] }
serde_yaml = { version = "0.9.25", optional = true, default-features = false, features = [] }
toml = { version = "0.7.6", optional = true, default-features = false }
ulid = { version = "1.1.0", optional = true, default-features = false, features = [] }
uuid = { version = "1.4.1", optional = true, default-features = false, features = [] }
chrono = { version = "0.4.26", optional = true, default-features = false, features = ["clock"] }
time = { version = "0.3.25", optional = true, default-features = false, features = [] }
bigdecimal = { version = "0.4.1", optional = true, default-features = false, features = [] }
rust_decimal = { version = "1.31.0", optional = true, default-features = false, features = [] }
indexmap = { version = "2.0.0", optional = true, default-features = false, features = ["std"] } # TODO: Don't require `std`
ipnetwork = { version = "0.20.0", optional = true, default-features = false, features = [] }
mac_address = { version = "1.1.5", optional = true, default-features = false, features = [] }
bit-vec = { version = "0.6.3", optional = true, default-features = false, features = [] }
bson = { version = "2.6.1", optional = true, default-features = false, features = [] }
openapiv3 = { version = "1.0.2", optional = true, default-features = false, features = [] }
uhlc = { version = "0.6.0", optional = true, default-features = false, features = [] }
bytesize = { version = "1.2.0", optional = true, default-features = false, features = [] }
glam = { version = "0.25", optional = true, default-features = false, features = ["std"] }
tokio = { version = "1.30", optional = true, default-features = false, features = ["sync"] }
url = { version = "2.4.0", optional = true, default-features = false }
either = { version = "1.9.0", optional = true, default-features = false }
bevy_ecs = { version = "0.13.2", optional = true, default-features = false }
bevy_input = { version = "0.13.2", optional = true, default-features = false }
thiserror = "1.0.44"
paste = "1.0.14"
specta1 = { package = "specta", version = "1", optional = true, default-features = false }

[dev-dependencies]
doc-comment = "0.3.3"
serde = { version = "1.0.183", features = ["derive"] }
trybuild = "1.0.82"
wasm-bindgen = "0.2.89"
[workspace]
members = ["specta", "specta-*"]
resolver = "2"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions crates/util/Cargo.toml → specta-util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export = ["dep:ctor", "specta-macros/export"]
typescript = []

[dependencies]
specta = { path = "../../" }
specta-macros = { path = "../../macros" }
specta = { path = "../specta" }
specta-macros = { path = "../specta-macros" }
ctor = { version = "0.2.4", optional = true }
once_cell = "1.18.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/zod/Cargo.toml → specta-zod/Cargo.toml
Original file line number Diff line number Diff line change
@@ -11,5 +11,5 @@ keywords = ["async", "specta", "rspc", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]

[dependencies]
specta = { path = "../../", features = ["typescript"] }
specta = { path = "../specta", features = ["typescript"] }
thiserror = "1.0.60"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
137 changes: 137 additions & 0 deletions specta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
[package]
name = "specta"
description = "Easily export your Rust types to other languages"
version = "2.0.0-rc.12"
authors = ["Oscar Beaumont <oscar@otbeaumont.me>"]
edition = "2021"
license = "MIT"
include = ["/src", "/examples", "/LICENCE", "/README.md"]
repository = "https://github.com/oscartbeaumont/specta"
documentation = "https://docs.rs/specta/latest/specta"
keywords = ["async", "specta", "rspc", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]
autotests = false

# /bin/sh RUSTDOCFLAGS="--cfg docsrs2" cargo +nightly doc --all-features
[package.metadata."docs.rs"]
all-features = true
rustdoc-args = ["--cfg", "docsrs2"] # TODO: Rename to `docsrs2` once Tokio fixes https://github.com/tokio-rs/tokio/pull/6360

[[test]]
name = "integration_tests"
path = "tests/lib.rs"
harness = true

# Run `node ./.github/features.js` to update the docs
[features]
default = []

#! Features
## Support for exporting the types of Rust functions.
function = ["serde", "specta-macros/function"]

#! Languages
## Support for [TypeScript](https://www.typescriptlang.org) language exporting
typescript = ["serde"] # TODO: Probally don't keep `serde` here for v2???
## Support for [JSDoc](https://jsdoc.app) exporting helpers.
## Also requires `typescript` feature to be enabled.
js_doc = []
# ## Support for [Rust](https://www.rust-lang.org) language exporting
# rust = []
# ## Support for [Swift](https://www.swift.org/) language exporting
# swift = []
# ## Support for [Kotlin](https://kotlinlang.org/) language exporting
# kotlin = []
# ## Support for [Go Lang](https://go.dev/) language exporting
# go = []
# ## Support for [OpenAPI](https://www.openapis.org) language exporting
# openapi = ["dep:openapiv3"]

#! Compatability
## Support for [serde](https://serde.rs)
serde = ["dep:serde", "specta-macros/serde"]
## Support for [serde-json](https://github.com/serde-rs/json)
serde_json = ["dep:serde_json"]
## Support for [serde_yaml](https://github.com/dtolnay/serde-yaml)
serde_yaml = ["dep:serde_yaml"]
## Support for [toml](https://github.com/toml-rs/toml)
toml = ["dep:toml"]

#! External types
## [uuid](https://docs.rs/uuid) crate
uuid = ["dep:uuid"]
## [uuid](https://docs.rs/ulid) crate
ulid = ["dep:ulid"]
## [chrono](https://docs.rs/chrono) crate
chrono = ["dep:chrono"]
## [time](https://docs.rs/time) crate
time = ["dep:time"]
## [bigdecimal](https://docs.rs/bigdecimal) crate
bigdecimal = ["dep:bigdecimal"]
## [rust_decimal](https://docs.rs/rust_decimal) crate
rust_decimal = ["dep:rust_decimal"]
## [indexmap](https://docs.rs/indexmap) crate
indexmap = ["dep:indexmap"]
## [ipnetwork](https://docs.rs/ipnetwork) crate
ipnetwork = ["dep:ipnetwork"]
## [mac_address](https://docs.rs/mac_address) crate
mac_address = ["dep:mac_address"]
## [bit-vec](https://docs.rs/bit-vec) crate
bit-vec = ["dep:bit-vec"]
## [bson](https://docs.rs/bson) crate
bson = ["dep:bson"]
## [uhlc](https://docs.rs/uhlc) crate
uhlc = ["dep:uhlc"]
## [bytesize](https://docs.rs/bytesize) crate
bytesize = ["dep:bytesize"]
## [glam](https://docs.rs/glam) crate
glam = ["dep:glam"]
## [tokio](https://docs.rs/tokio) crate
tokio = ["dep:tokio"]
## [url](https://docs.rs/url) crate
url = ["dep:url"]
## [either](https://docs.rs/either) crate
either = ["dep:either"]
# [bevy_ecs](https://docs.rs/bevy_ecs) crate
bevy_ecs = ["dep:bevy_ecs"]
# [bevy_input](https://docs.rs/bevy_input) crate
bevy_input = ["dep:bevy_input", "dep:bevy_ecs", "dep:glam"]

# Internal features (unstable)
interop = ["dep:specta1"]

[dependencies]
specta-macros = { version = "=2.0.0-rc.10", path = "../specta-macros" }
serde = { version = "1.0.183", optional = true, default-features = false, features = ["derive"] }
serde_json = { version = "1.0.104", optional = true, default-features = false, features = ["std"] }
serde_yaml = { version = "0.9.25", optional = true, default-features = false, features = [] }
toml = { version = "0.7.6", optional = true, default-features = false }
ulid = { version = "1.1.0", optional = true, default-features = false, features = [] }
uuid = { version = "1.4.1", optional = true, default-features = false, features = [] }
chrono = { version = "0.4.26", optional = true, default-features = false, features = ["clock"] }
time = { version = "0.3.25", optional = true, default-features = false, features = [] }
bigdecimal = { version = "0.4.1", optional = true, default-features = false, features = [] }
rust_decimal = { version = "1.31.0", optional = true, default-features = false, features = [] }
indexmap = { version = "2.0.0", optional = true, default-features = false, features = ["std"] } # TODO: Don't require `std`
ipnetwork = { version = "0.20.0", optional = true, default-features = false, features = [] }
mac_address = { version = "1.1.5", optional = true, default-features = false, features = [] }
bit-vec = { version = "0.6.3", optional = true, default-features = false, features = [] }
bson = { version = "2.6.1", optional = true, default-features = false, features = [] }
openapiv3 = { version = "1.0.2", optional = true, default-features = false, features = [] }
uhlc = { version = "0.6.0", optional = true, default-features = false, features = [] }
bytesize = { version = "1.2.0", optional = true, default-features = false, features = [] }
glam = { version = "0.25", optional = true, default-features = false, features = ["std"] }
tokio = { version = "1.30", optional = true, default-features = false, features = ["sync"] }
url = { version = "2.4.0", optional = true, default-features = false }
either = { version = "1.9.0", optional = true, default-features = false }
bevy_ecs = { version = "0.13.2", optional = true, default-features = false }
bevy_input = { version = "0.13.2", optional = true, default-features = false }
thiserror = "1.0.44"
paste = "1.0.14"
specta1 = { package = "specta", version = "1", optional = true, default-features = false }

[dev-dependencies]
doc-comment = "0.3.3"
serde = { version = "1.0.183", features = ["derive"] }
trybuild = "1.0.82"
wasm-bindgen = "0.2.89"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/lang/ts/error.rs → specta/src/lang/ts/error.rs
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@ pub enum ExportError {
DuplicateTypeName(Cow<'static, str>, ImplLocation, ImplLocation),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("fmt error: {0}")]
Fmt(#[from] std::fmt::Error),
#[error("Failed to export '{0}' due to error: {1}")]
Other(ExportPath, String),
}
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src/lang/ts/js_doc.rs → specta/src/lang/ts/js_doc.rs
Original file line number Diff line number Diff line change
@@ -34,7 +34,8 @@ fn typedef_named_datatype_inner(

let name = sanitise_type_name(ctx.clone(), NamedLocation::Type, name)?;

let inline_ts = datatype_inner(ctx.clone(), &typ.inner, type_map)?;
let mut inline_ts = String::new();
datatype_inner(ctx.clone(), &typ.inner, type_map, &mut inline_ts)?;

let mut builder = ts::comments::js_doc_builder(CommentFormatterArgs {
docs,
Loading