From e8420e90b067497e314bad8c97d3f601129a80f6 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Thu, 23 May 2024 06:33:10 +0300 Subject: [PATCH] fix docsrs --- nextgraph/Cargo.toml | 5 ++++- nextgraph/src/local_broker.rs | 5 +++-- ng-oxigraph/Cargo.toml | 5 ++++- ng-oxigraph/src/lib.rs | 1 - ng-oxigraph/src/oxigraph/sparql/mod.rs | 2 +- ng-oxigraph/src/oxigraph/storage/backend/mod.rs | 4 ++-- ng-oxigraph/src/oxigraph/store.rs | 3 +-- ng-repo/src/object.rs | 4 ++-- ng-verifier/Cargo.toml | 7 +++++-- ng-verifier/src/verifier.rs | 11 ++++++++--- 10 files changed, 30 insertions(+), 17 deletions(-) diff --git a/nextgraph/Cargo.toml b/nextgraph/Cargo.toml index a978e48..6bb9a0f 100644 --- a/nextgraph/Cargo.toml +++ b/nextgraph/Cargo.toml @@ -32,9 +32,12 @@ ng-wallet = { path = "../ng-wallet", version = "0.1.0-preview.1" } ng-client-ws = { path = "../ng-client-ws", version = "0.1.0-preview.1" } ng-verifier = { path = "../ng-verifier", version = "0.1.0-preview.1" } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(all(not(target_arch = "wasm32"),not(doc)))'.dependencies] ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" } +[package.metadata.docs.rs] +rustc-args = [ "--cfg" , "doc"] + [[example]] name = "in_memory" required-features = [] diff --git a/nextgraph/src/local_broker.rs b/nextgraph/src/local_broker.rs index 2215bcb..3692c8d 100644 --- a/nextgraph/src/local_broker.rs +++ b/nextgraph/src/local_broker.rs @@ -46,7 +46,7 @@ use ng_wallet::{create_wallet_first_step_v0, create_wallet_second_step_v0, types use ng_client_ws::remote_ws::ConnectionWebSocket; #[cfg(target_arch = "wasm32")] use ng_client_ws::remote_ws_wasm::ConnectionWebSocket; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_family = "wasm"),not(doc)))] use ng_storage_rocksdb::block_storage::RocksDbBlockStorage; #[doc(hidden)] @@ -824,6 +824,7 @@ impl LocalBroker { (VerifierType::Memory, LocalBrokerConfig::BasePath(_)) => { VerifierConfigType::Memory } + #[cfg(all(not(target_family = "wasm"),not(doc)))] (VerifierType::Save, LocalBrokerConfig::BasePath(base)) => { let mut path = base.clone(); path.push(format!("user{}", config.user_id().to_hash_string())); @@ -910,7 +911,7 @@ impl LocalBroker { Arc::new(std::sync::RwLock::new(HashMapBlockStorage::new())) as Arc> } else { - #[cfg(not(target_family = "wasm"))] + #[cfg(all(not(target_family = "wasm"),not(doc)))] { let key_material = wallet .client() diff --git a/ng-oxigraph/Cargo.toml b/ng-oxigraph/Cargo.toml index 28b5ac9..7caee18 100644 --- a/ng-oxigraph/Cargo.toml +++ b/ng-oxigraph/Cargo.toml @@ -44,7 +44,7 @@ quick-xml = ">=0.29, <0.32" memchr = "2.5" peg = "0.8" -[target.'cfg(not(target_family = "wasm"))'.dependencies] +[target.'cfg(all(not(target_family = "wasm"),not(doc)))'.dependencies] libc = "0.2" ng-rocksdb = { version = "0.21.0", git = "https://git.nextgraph.org/NextGraph/rust-rocksdb.git", branch = "master", features = [ ] } @@ -56,6 +56,9 @@ js-sys = { version = "0.3.60", optional = true } codspeed-criterion-compat = "2.3.3" zstd = ">=0.12, <0.14" +[package.metadata.docs.rs] +rustc-args = [ "--cfg" , "doc"] + [lints.rust] absolute_paths_not_starting_with_crate = "warn" elided_lifetimes_in_paths = "warn" diff --git a/ng-oxigraph/src/lib.rs b/ng-oxigraph/src/lib.rs index df9b74b..a57d060 100644 --- a/ng-oxigraph/src/lib.rs +++ b/ng-oxigraph/src/lib.rs @@ -1,4 +1,3 @@ -#![doc = include_str!("../README.md")] #![doc(test(attr(deny(warnings))))] #![doc(test(attr(allow(deprecated))))] #![cfg_attr(docsrs, feature(doc_auto_cfg))] diff --git a/ng-oxigraph/src/oxigraph/sparql/mod.rs b/ng-oxigraph/src/oxigraph/sparql/mod.rs index 2aeb2e2..3e5bbac 100644 --- a/ng-oxigraph/src/oxigraph/sparql/mod.rs +++ b/ng-oxigraph/src/oxigraph/sparql/mod.rs @@ -1,6 +1,6 @@ //! [SPARQL](https://www.w3.org/TR/sparql11-overview/) implementation. //! -//! Stores execute SPARQL. See [`Store`](crate::store::Store::query()) for an example. +//! Stores execute SPARQL. See [`Store`](crate::oxigraph::store::Store::query()) for an example. mod algebra; mod dataset; diff --git a/ng-oxigraph/src/oxigraph/storage/backend/mod.rs b/ng-oxigraph/src/oxigraph/storage/backend/mod.rs index b94eb65..b2412d1 100644 --- a/ng-oxigraph/src/oxigraph/storage/backend/mod.rs +++ b/ng-oxigraph/src/oxigraph/storage/backend/mod.rs @@ -1,12 +1,12 @@ //! A storage backend //! RocksDB is available, if not in memory -#[cfg(any(target_family = "wasm"))] +#[cfg(any(target_family = "wasm", doc))] pub use fallback::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; #[cfg(all(not(target_family = "wasm")))] pub use oxi_rocksdb::{ColumnFamily, ColumnFamilyDefinition, Db, Iter, Reader, Transaction}; -#[cfg(any(target_family = "wasm"))] +#[cfg(any(target_family = "wasm", doc))] mod fallback; #[cfg(all(not(target_family = "wasm")))] mod oxi_rocksdb; diff --git a/ng-oxigraph/src/oxigraph/store.rs b/ng-oxigraph/src/oxigraph/store.rs index d5f105c..310901e 100644 --- a/ng-oxigraph/src/oxigraph/store.rs +++ b/ng-oxigraph/src/oxigraph/store.rs @@ -99,7 +99,7 @@ impl Store { /// /// Only one read-write [`Store`] can exist at the same time. /// If you want to have extra [`Store`] instance opened on a same data - /// use [`Store::open_secondary`] or [`Store::open_read_only`]. + /// use [`Store::open_read_only`]. #[cfg(all(not(target_family = "wasm")))] pub fn open(path: impl AsRef) -> Result { Ok(Self { @@ -155,7 +155,6 @@ impl Store { /// Opens a read-only [`Store`] from disk. /// /// Opening as read-only while having an other process writing the database is undefined behavior. - /// [`Store::open_secondary`] should be used in this case. #[cfg(all(not(target_family = "wasm")))] pub fn open_read_only( path: impl AsRef, diff --git a/ng-repo/src/object.rs b/ng-repo/src/object.rs index fe372e1..2a6cdb7 100644 --- a/ng-repo/src/object.rs +++ b/ng-repo/src/object.rs @@ -426,7 +426,7 @@ impl Object { /// Load an Object from BlockStorage (taking a reference) /// - /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec)) of missing BlockIds + /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId)) of missing BlockIds pub fn load_ref(reference: &ObjectRef, store: &Store) -> Result { Self::load(reference.id.clone(), Some(reference.key.clone()), store) } @@ -484,7 +484,7 @@ impl Object { /// Load an Object from BlockStorage /// - /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec)) of missing BlockIds + /// Returns Ok(Object) or an Err(ObjectParseError::MissingBlocks(Vec of ObjectId )) of missing BlockIds pub fn load( id: ObjectId, key: Option, diff --git a/ng-verifier/Cargo.toml b/ng-verifier/Cargo.toml index 8c6f431..88de00c 100644 --- a/ng-verifier/Cargo.toml +++ b/ng-verifier/Cargo.toml @@ -37,9 +37,12 @@ ng-oxigraph = { path = "../ng-oxigraph", version = "0.4.0-alpha.7-ngpreview" } [target.'cfg(target_arch = "wasm32")'.dependencies] ng-oxigraph = { path = "../ng-oxigraph", version = "0.4.0-alpha.7-ngpreview", features = ["js"] } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +[target.'cfg(all(not(target_arch = "wasm32"),not(doc)))'.dependencies] ng-storage-rocksdb = { path = "../ng-storage-rocksdb", version = "0.1.0-preview.1" } getrandom = "0.2.7" [dev-dependencies] -ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1", features = ["testing"] } \ No newline at end of file +ng-repo = { path = "../ng-repo", version = "0.1.0-preview.1", features = ["testing"] } + +[package.metadata.docs.rs] +rustc-args = [ "--cfg" , "doc"] \ No newline at end of file diff --git a/ng-verifier/src/verifier.rs b/ng-verifier/src/verifier.rs index 19b5677..12ed5a2 100644 --- a/ng-verifier/src/verifier.rs +++ b/ng-verifier/src/verifier.rs @@ -13,9 +13,11 @@ use core::fmt; use std::cmp::max; use std::collections::BTreeMap; use std::collections::HashSet; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(all(not(target_family = "wasm"), not(doc)))] use std::fs::create_dir_all; +#[cfg(all(not(target_family = "wasm"), not(doc)))] use std::fs::{read, File, OpenOptions}; +#[cfg(all(not(target_family = "wasm"), not(doc)))] use std::io::Write; use std::{collections::HashMap, sync::Arc}; @@ -56,7 +58,7 @@ use ng_net::{ }; use crate::commits::*; -#[cfg(not(target_family = "wasm"))] +#[cfg(all(not(target_family = "wasm"), not(doc)))] use crate::rocksdb_user_storage::RocksDbUserStorage; use crate::types::*; use crate::user_storage::InMemoryUserStorage; @@ -712,6 +714,7 @@ impl Verifier { } Ok(res) } + #[cfg(all(not(target_family = "wasm"), not(doc)))] VerifierConfigType::RocksDb(path) => { let mut path = path.clone(); path.push(format!("outbox{}", self.peer_id.to_hash_string())); @@ -791,6 +794,7 @@ impl Verifier { serde_bare::to_vec(&e)?, )?; } + #[cfg(all(not(target_family = "wasm"), not(doc)))] VerifierConfigType::RocksDb(path) => { let mut path = path.clone(); std::fs::create_dir_all(path.clone()).unwrap(); @@ -1964,6 +1968,7 @@ impl Verifier { let res = (js.last_seq_function)(self.peer_id, qty)?; self.max_reserved_seq_num = res + qty as u64; } + #[cfg(all(not(target_family = "wasm"), not(doc)))] VerifierConfigType::RocksDb(path) => { let mut path = path.clone(); std::fs::create_dir_all(path.clone()).unwrap(); @@ -2023,7 +2028,7 @@ impl Verifier { Some(Box::new(InMemoryUserStorage::new()) as Box), Some(block_storage), ), - #[cfg(not(target_family = "wasm"))] + #[cfg(all(not(target_family = "wasm"), not(doc)))] VerifierConfigType::RocksDb(path) => { let mut path_oxi = path.clone(); path_oxi.push("graph");