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

Explore sharing docs between crates #91

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
94 changes: 93 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/bitwarden-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ wasm = [
"bitwarden-error-macro/wasm",
"dep:js-sys",
"dep:tsify-next",
"dep:wasm-bindgen"
"dep:wasm-bindgen",
]

[dependencies]
bitwarden-error-macro = { workspace = true }
js-sys = { workspace = true, optional = true }
tsify-next = { workspace = true, optional = true }
wasm-bindgen = { workspace = true, optional = true }
documented = "0.9.1"

[lints]
workspace = true
Expand Down
7 changes: 7 additions & 0 deletions crates/bitwarden-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub use ::tsify_next;
#[cfg(feature = "wasm")]
#[doc(hidden)]
pub use ::wasm_bindgen;
use documented::docs_const;

pub mod prelude {
pub use bitwarden_error_macro::*;
Expand All @@ -23,3 +24,9 @@ pub mod prelude {
#[cfg(feature = "wasm")]
pub use crate::wasm::SdkJsError;
}

/// A test function.
#[docs_const]
pub fn test() {
println!("Hello, world!");
}
3 changes: 3 additions & 0 deletions crates/bitwarden-wasm-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ serde_json = ">=1.0.96, <2.0"
wasm-bindgen = { version = "=0.2.99", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.41"

[build-dependencies]
bitwarden-error = { version = "1.0.0", path = "../bitwarden-error" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions crates/bitwarden-wasm-internal/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::{env, process::Command};

fn main() {

std::fs::write("doc/test.md", bitwarden_error::TEST_DOCS).unwrap();

// Use the SDK_VERSION environment variable if it is set (e.g. by CI) or get it from Git
let sdk_version = env::var("SDK_VERSION")
.or_else(|_| version_from_git_info())
Expand Down
5 changes: 5 additions & 0 deletions crates/bitwarden-wasm-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ mod vault;
pub use client::BitwardenClient;
pub use crypto::CryptoClient;
pub use vault::{folders::ClientFolders, VaultClient};

#[doc = include_str!("../doc/test.md")]
pub fn test2() {
println!("Hello, world!");
}
Loading