Skip to content

Commit

Permalink
Publish v0.14.1 with support for rustdoc JSON v28 format. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi authored Dec 24, 2023
1 parent 932eeb4 commit 5521cbb
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 9 deletions.
22 changes: 21 additions & 1 deletion Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trustfall_rustdoc"
version = "0.14.0"
version = "0.14.1"
edition = "2021"
authors = ["Predrag Gruevski <obi1kenobi82@gmail.com>"]
license = "Apache-2.0 OR MIT"
Expand All @@ -17,8 +17,10 @@ serde = { version = "1.0.145", features = ["derive"] }
trustfall = "0.7.1"
trustfall-rustdoc-adapter-v26 = { package = "trustfall-rustdoc-adapter", version = ">=26.3.0,<26.4.0", optional = true }
trustfall-rustdoc-adapter-v27 = { package = "trustfall-rustdoc-adapter", version = ">=27.1.0,<27.2.0", optional = true }
trustfall-rustdoc-adapter-v28 = { package = "trustfall-rustdoc-adapter", version = ">=28.0.0,<28.1.0", optional = true }

[features]
default = ["v26", "v27"]
default = ["v26", "v27", "v28"]
v26 = ["dep:trustfall-rustdoc-adapter-v26"]
v27 = ["dep:trustfall-rustdoc-adapter-v27"]
v28 = ["dep:trustfall-rustdoc-adapter-v28"]
7 changes: 7 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ pub fn load_rustdoc(path: &Path) -> anyhow::Result<VersionedCrate> {
format_version,
)?)),

#[cfg(feature = "v28")]
28 => Ok(VersionedCrate::V28(parse_or_report_error(
path,
&file_data,
format_version,
)?)),

_ => bail!(
"rustdoc format v{format_version} for file {} is not supported",
path.display()
Expand Down
5 changes: 5 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ impl<'a> VersionedRustdocAdapter<'a> {
VersionedRustdocAdapter::V27(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
}

#[cfg(feature = "v28")]
VersionedRustdocAdapter::V28(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
}
}
}
}
53 changes: 47 additions & 6 deletions src/versioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ macro_rules! add_version_method {

#[cfg(feature = "v27")]
Self::V27(..) => 27,

#[cfg(feature = "v28")]
Self::V28(..) => 28,
}
}
};
Expand All @@ -25,6 +28,9 @@ pub enum VersionedCrate {

#[cfg(feature = "v27")]
V27(trustfall_rustdoc_adapter_v27::Crate),

#[cfg(feature = "v28")]
V28(trustfall_rustdoc_adapter_v28::Crate),
}

#[non_exhaustive]
Expand All @@ -35,6 +41,9 @@ pub enum VersionedIndexedCrate<'a> {

#[cfg(feature = "v27")]
V27(trustfall_rustdoc_adapter_v27::IndexedCrate<'a>),

#[cfg(feature = "v28")]
V28(trustfall_rustdoc_adapter_v28::IndexedCrate<'a>),
}

#[non_exhaustive]
Expand All @@ -50,6 +59,12 @@ pub enum VersionedRustdocAdapter<'a> {
Schema,
Arc<trustfall_rustdoc_adapter_v27::RustdocAdapter<'a>>,
),

#[cfg(feature = "v28")]
V28(
Schema,
Arc<trustfall_rustdoc_adapter_v28::RustdocAdapter<'a>>,
),
}

impl VersionedCrate {
Expand All @@ -60,6 +75,9 @@ impl VersionedCrate {

#[cfg(feature = "v27")]
VersionedCrate::V27(c) => c.crate_version.as_deref(),

#[cfg(feature = "v28")]
VersionedCrate::V28(c) => c.crate_version.as_deref(),
}
}

Expand All @@ -78,6 +96,11 @@ impl<'a> VersionedIndexedCrate<'a> {
VersionedCrate::V27(c) => {
Self::V27(trustfall_rustdoc_adapter_v27::IndexedCrate::new(c))
}

#[cfg(feature = "v28")]
VersionedCrate::V28(c) => {
Self::V28(trustfall_rustdoc_adapter_v28::IndexedCrate::new(c))
}
}
}

Expand Down Expand Up @@ -132,6 +155,27 @@ impl<'a> VersionedRustdocAdapter<'a> {
))
}

#[cfg(feature = "v28")]
(VersionedIndexedCrate::V28(c), Some(VersionedIndexedCrate::V28(b))) => {
let adapter = Arc::new(trustfall_rustdoc_adapter_v28::RustdocAdapter::new(
c,
Some(b),
));
Ok(VersionedRustdocAdapter::V28(
trustfall_rustdoc_adapter_v28::RustdocAdapter::schema(),
adapter,
))
}

#[cfg(feature = "v28")]
(VersionedIndexedCrate::V28(c), None) => {
let adapter = Arc::new(trustfall_rustdoc_adapter_v28::RustdocAdapter::new(c, None));
Ok(VersionedRustdocAdapter::V28(
trustfall_rustdoc_adapter_v28::RustdocAdapter::schema(),
adapter,
))
}

(c, Some(b)) => {

Check warning on line 179 in src/versioned.rs

View workflow job for this annotation

GitHub Actions / Run tests

unreachable pattern

Check warning on line 179 in src/versioned.rs

View workflow job for this annotation

GitHub Actions / Run tests

unreachable pattern
bail!(
"version mismatch between current (v{}) and baseline (v{}) format versions",
Expand All @@ -144,17 +188,14 @@ impl<'a> VersionedRustdocAdapter<'a> {

pub fn schema(&self) -> &Schema {
match self {
#[cfg(feature = "v23")]
VersionedRustdocAdapter::V23(schema, ..) => schema,

#[cfg(feature = "v24")]
VersionedRustdocAdapter::V24(schema, ..) => schema,

#[cfg(feature = "v26")]
VersionedRustdocAdapter::V26(schema, ..) => schema,

#[cfg(feature = "v27")]
VersionedRustdocAdapter::V27(schema, ..) => schema,

#[cfg(feature = "v28")]
VersionedRustdocAdapter::V28(schema, ..) => schema,
}
}

Expand Down

0 comments on commit 5521cbb

Please sign in to comment.