Skip to content

Commit dda3f5e

Browse files
committed
fix feature dependencies
1 parent b1ac3a2 commit dda3f5e

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

html2rdf/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ exclude = [
1717
]
1818

1919
[features]
20-
default = ["html", "http", "xhtml"]
20+
default = ["html", "vocab-online", "xhtml"]
2121
html = ["dep:scraper"]
2222
xhtml = ["dep:uppsala"]
23-
http = ["dep:reqwest"]
23+
vocab-online = ["dep:reqwest", "html"]
2424

2525
[dependencies]
2626
bergshamra-c14n = "0.3.1"

html2rdf/src/algorithms/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ mod property_copying;
44
mod vocabulary_expansion;
55

66
pub use property_copying::property_copying;
7-
pub use vocabulary_expansion::{
8-
OfflineVocabularyResolver, OnlineVocabularyResolver, VocabularyResolver, vocabulary_expansion,
9-
};
7+
8+
#[cfg(feature = "html")]
9+
pub use vocabulary_expansion::OfflineVocabularyResolver;
10+
11+
#[cfg(feature = "vocab-online")]
12+
pub use vocabulary_expansion::OnlineVocabularyResolver;
13+
14+
pub use vocabulary_expansion::{VocabularyResolver, vocabulary_expansion};

html2rdf/src/algorithms/vocabulary_expansion.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use oxrdf::{
66
vocab::{rdf, rdfs},
77
};
88

9-
use crate::{
10-
host_language::Html5,
11-
vocab::{owl, rdfa},
12-
};
9+
use crate::vocab::{owl, rdfa};
1310

1411
pub trait VocabularyResolver {
1512
fn resolve(&self, vocab_iri: &str) -> Option<Cow<'_, Graph>>;
@@ -23,12 +20,12 @@ impl<T: VocabularyResolver> VocabularyResolver for &T {
2320

2421
/// Allows resolving vocabularies by fetching their target IRIs
2522
/// over HTTP(S).
26-
#[cfg(feature = "http")]
23+
#[cfg(feature = "vocab-online")]
2724
pub struct OnlineVocabularyResolver {
2825
client: reqwest::blocking::Client,
2926
}
3027

31-
#[cfg(feature = "http")]
28+
#[cfg(feature = "vocab-online")]
3229
impl Default for OnlineVocabularyResolver {
3330
fn default() -> Self {
3431
Self {
@@ -38,8 +35,9 @@ impl Default for OnlineVocabularyResolver {
3835
}
3936

4037
// yo dawg
38+
#[cfg(feature = "html")]
4139
fn vocab_from_html(html: &str, base: Iri<&str>) -> Graph {
42-
let (o_graph, ()) = crate::doc_to_graphs::<Html5, ()>(
40+
let (o_graph, ()) = crate::doc_to_graphs::<crate::host_language::Html5, ()>(
4341
html,
4442
base.as_ref(),
4543
crate::Options::default(), // we explicitly do _not_ enable expansion on vocabularies
@@ -48,7 +46,7 @@ fn vocab_from_html(html: &str, base: Iri<&str>) -> Graph {
4846
o_graph
4947
}
5048

51-
#[cfg(feature = "http")]
49+
#[cfg(feature = "vocab-online")]
5250
impl VocabularyResolver for OnlineVocabularyResolver {
5351
fn resolve(&self, vocab_iri: &str) -> Option<Cow<'_, Graph>> {
5452
use tracing::debug;
@@ -79,16 +77,19 @@ impl VocabularyResolver for OnlineVocabularyResolver {
7977
/// Allows resolving vocabularies through a preloaded
8078
/// set of vocabulary documents, for offline processing.
8179
#[derive(Default)]
80+
#[cfg(feature = "html")]
8281
pub struct OfflineVocabularyResolver {
8382
vocabularies: std::collections::HashMap<String, Graph>,
8483
}
8584

85+
#[cfg(feature = "html")]
8686
impl VocabularyResolver for OfflineVocabularyResolver {
8787
fn resolve(&self, vocab_iri: &str) -> Option<Cow<'_, Graph>> {
8888
self.vocabularies.get(vocab_iri).map(Cow::Borrowed)
8989
}
9090
}
9191

92+
#[cfg(feature = "html")]
9293
impl OfflineVocabularyResolver {
9394
pub fn insert(&mut self, vocab_iri: String, graph: Graph) {
9495
self.vocabularies.insert(vocab_iri, graph);

html2rdf/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! The following features are available, all enabled by default:
1919
//! - `html`: enables HTML5 processing (via `scraper`)
2020
//! - `xhtml`: enables XHTML processing (via `uppsala`)
21-
//! - `http`: enables the use of [`algorithms::OnlineVocabularyProcessor`]
21+
//! - `vocab-online`: enables the use of [`algorithms::OnlineVocabularyProcessor`] (this also enables `html`)
2222
//!
2323
//! ## Known Issues
2424
//! - `XMLLiteral` values are not yet correctly canonicalized in HTML5

0 commit comments

Comments
 (0)