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

Release v0.15 with support for rustdoc JSON format v29. #34

Merged
merged 1 commit into from
Apr 21, 2024
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ jobs:
run: cargo test --no-run --all-features

# Test features individually
- name: test rustdoc v26
run: cargo test --no-default-features --features v26

- name: test rustdoc v27
run: cargo test --no-default-features --features v27

- name: test rustdoc v28
run: cargo test --no-default-features --features v28

- name: test rustdoc v29
run: cargo test --no-default-features --features v29

# Test all features at once; keep this last for caching purposes.
- name: test all features
run: cargo test --all-features
Expand Down
34 changes: 17 additions & 17 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "trustfall_rustdoc"
version = "0.14.1"
version = "0.15.0"
edition = "2021"
authors = ["Predrag Gruevski <obi1kenobi82@gmail.com>"]
license = "Apache-2.0 OR MIT"
Expand All @@ -15,12 +15,12 @@ anyhow = "1.0.65"
serde_json = "1.0.85"
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 }
trustfall-rustdoc-adapter-v29 = { package = "trustfall-rustdoc-adapter", version = ">=29.0.0,<29.1.0", optional = true }

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

match format_version {
#[cfg(feature = "v26")]
26 => Ok(VersionedCrate::V26(parse_or_report_error(
#[cfg(feature = "v27")]
27 => Ok(VersionedCrate::V27(parse_or_report_error(
path,
&file_data,
format_version,
)?)),

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

#[cfg(feature = "v28")]
28 => Ok(VersionedCrate::V28(parse_or_report_error(
#[cfg(feature = "v29")]
29 => Ok(VersionedCrate::V29(parse_or_report_error(
path,
&file_data,
format_version,
Expand Down
10 changes: 5 additions & 5 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ impl<'a> VersionedRustdocAdapter<'a> {
vars: BTreeMap<K, V>,
) -> anyhow::Result<Box<dyn Iterator<Item = QueryResult> + 'a>> {
match self {
#[cfg(feature = "v26")]
VersionedRustdocAdapter::V26(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
}

#[cfg(feature = "v27")]
VersionedRustdocAdapter::V27(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
Expand All @@ -27,6 +22,11 @@ impl<'a> VersionedRustdocAdapter<'a> {
VersionedRustdocAdapter::V28(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
}

#[cfg(feature = "v29")]
VersionedRustdocAdapter::V29(_, adapter) => {
execute_query(self.schema(), adapter.clone(), query, vars)
}
}
}
}
94 changes: 47 additions & 47 deletions src/versioned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
() => {
pub fn version(&self) -> u32 {
match self {
#[cfg(feature = "v26")]
Self::V26(..) => 26,

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

#[cfg(feature = "v28")]
Self::V28(..) => 28,

#[cfg(feature = "v29")]
Self::V29(..) => 29,
}
}
};
Expand All @@ -23,37 +23,31 @@
#[non_exhaustive]
#[derive(Debug)]
pub enum VersionedCrate {
#[cfg(feature = "v26")]
V26(trustfall_rustdoc_adapter_v26::Crate),

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

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

#[cfg(feature = "v29")]
V29(trustfall_rustdoc_adapter_v29::Crate),
}

#[non_exhaustive]
#[derive(Debug)]
pub enum VersionedIndexedCrate<'a> {
#[cfg(feature = "v26")]
V26(trustfall_rustdoc_adapter_v26::IndexedCrate<'a>),

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

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

#[cfg(feature = "v29")]
V29(trustfall_rustdoc_adapter_v29::IndexedCrate<'a>),
}

#[non_exhaustive]
pub enum VersionedRustdocAdapter<'a> {
#[cfg(feature = "v26")]
V26(
Schema,
Arc<trustfall_rustdoc_adapter_v26::RustdocAdapter<'a>>,
),

#[cfg(feature = "v27")]
V27(
Schema,
Expand All @@ -65,19 +59,25 @@
Schema,
Arc<trustfall_rustdoc_adapter_v28::RustdocAdapter<'a>>,
),

#[cfg(feature = "v29")]
V29(
Schema,
Arc<trustfall_rustdoc_adapter_v29::RustdocAdapter<'a>>,
),
}

impl VersionedCrate {
pub fn crate_version(&self) -> Option<&str> {
match self {
#[cfg(feature = "v26")]
VersionedCrate::V26(c) => c.crate_version.as_deref(),

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

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

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

Expand All @@ -87,11 +87,6 @@
impl<'a> VersionedIndexedCrate<'a> {
pub fn new(crate_: &'a VersionedCrate) -> Self {
match &crate_ {
#[cfg(feature = "v26")]
VersionedCrate::V26(c) => {
Self::V26(trustfall_rustdoc_adapter_v26::IndexedCrate::new(c))
}

#[cfg(feature = "v27")]
VersionedCrate::V27(c) => {
Self::V27(trustfall_rustdoc_adapter_v27::IndexedCrate::new(c))
Expand All @@ -101,6 +96,11 @@
VersionedCrate::V28(c) => {
Self::V28(trustfall_rustdoc_adapter_v28::IndexedCrate::new(c))
}

#[cfg(feature = "v29")]
VersionedCrate::V29(c) => {
Self::V29(trustfall_rustdoc_adapter_v29::IndexedCrate::new(c))
}
}
}

Expand All @@ -113,27 +113,6 @@
baseline: Option<&'a VersionedIndexedCrate>,
) -> anyhow::Result<Self> {
match (current, baseline) {
#[cfg(feature = "v26")]
(VersionedIndexedCrate::V26(c), Some(VersionedIndexedCrate::V26(b))) => {
let adapter = Arc::new(trustfall_rustdoc_adapter_v26::RustdocAdapter::new(
c,
Some(b),
));
Ok(VersionedRustdocAdapter::V26(
trustfall_rustdoc_adapter_v26::RustdocAdapter::schema(),
adapter,
))
}

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

#[cfg(feature = "v27")]
(VersionedIndexedCrate::V27(c), Some(VersionedIndexedCrate::V27(b))) => {
let adapter = Arc::new(trustfall_rustdoc_adapter_v27::RustdocAdapter::new(
Expand Down Expand Up @@ -176,7 +155,28 @@
))
}

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

#[cfg(feature = "v29")]
(VersionedIndexedCrate::V29(c), None) => {
let adapter = Arc::new(trustfall_rustdoc_adapter_v29::RustdocAdapter::new(c, None));
Ok(VersionedRustdocAdapter::V29(
trustfall_rustdoc_adapter_v29::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

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",
c.version(),
Expand All @@ -188,14 +188,14 @@

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

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

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

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

Expand Down