Skip to content

Commit 771f8f1

Browse files
committed
Support for complex deprecated definition and any type.
1 parent 274e05a commit 771f8f1

5 files changed

Lines changed: 55 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.2.1
2+
3+
- Support for complex deprecated definition and any type.
4+
15
# 0.2.0
26

37
- Added a namespace tree view sidebar.
@@ -29,11 +33,10 @@
2933

3034
- Number type attributes now run an `avg` query when a dataset is clicked
3135
- Template type attributes:
32-
- Now render with the `.<key>` suffix in the name
33-
- The dictionary, discovered from Honeycomb, is displayed in a `keys` section with query links
36+
- Now render with the `.<key>` suffix in the name
37+
- The dictionary, discovered from Honeycomb, is displayed in a `keys` section with query links
3438
- Added a favicon
3539

36-
3740
# 0.1.5
3841

3942
- Uses `cargo-dist` for build and release.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "honey-explore"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
authors = ["Jeremy Blythe <jeremyblythe@gmail.com>"]
66
repository = "https://github.com/jerbly/honey-explore"

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async fn main() -> anyhow::Result<()> {
154154
{
155155
Ok(hclient) => hclient,
156156
Err(e) => {
157-
eprintln!("Failed to get honeycomb client: {}", e);
157+
eprintln!("Failed to get honeycomb client: {e}");
158158
None
159159
}
160160
};
@@ -197,10 +197,10 @@ async fn main() -> anyhow::Result<()> {
197197
// run it
198198
let listener = tokio::net::TcpListener::bind(args.addr).await?;
199199
let local_addr = listener.local_addr()?;
200-
println!("listening on {}", local_addr);
200+
println!("listening on {local_addr}");
201201
// open a browser
202-
if let Err(e) = open::that(format!("http://{}", local_addr)) {
203-
eprintln!("Failed to open browser: {}", e);
202+
if let Err(e) = open::that(format!("http://{local_addr}")) {
203+
eprintln!("Failed to open browser: {e}");
204204
}
205205
axum::serve(listener, app).await?;
206206
Ok(())
@@ -310,7 +310,7 @@ async fn honeycomb_exists_handler(
310310
}
311311
Simple(PrimitiveType::TemplateOfInt)
312312
| Simple(PrimitiveType::TemplateOfDouble) => {
313-
let column_with_suffix = format!("{}.{}", column, suffix);
313+
let column_with_suffix = format!("{column}.{suffix}");
314314
if let Ok(avg) =
315315
hc.get_avg_query_url(&dataset, &column_with_suffix).await
316316
{
@@ -323,7 +323,7 @@ async fn honeycomb_exists_handler(
323323
| Simple(PrimitiveType::TemplateOfArrayOfInt)
324324
| Simple(PrimitiveType::TemplateOfArrayOfDouble)
325325
| Simple(PrimitiveType::TemplateOfArrayOfBoolean) => {
326-
let column_with_suffix = format!("{}.{}", column, suffix);
326+
let column_with_suffix = format!("{column}.{suffix}");
327327
if let Ok(exists) = hc
328328
.get_exists_query_url(&dataset, &column_with_suffix, false)
329329
.await
@@ -440,7 +440,7 @@ fn get_links(names: &Vec<String>) -> Vec<String> {
440440
if prev.is_empty() {
441441
prev = name.clone();
442442
} else {
443-
prev = format!("{}.{}", prev, name);
443+
prev = format!("{prev}.{name}");
444444
}
445445
links.push(prev.clone());
446446
}

src/semconv.rs

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub enum MemberValue {
1717
impl Display for MemberValue {
1818
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1919
match self {
20-
MemberValue::StringType(s) => write!(f, "{}", s),
21-
MemberValue::IntegerType(i) => write!(f, "{}", i),
20+
MemberValue::StringType(s) => write!(f, "{s}"),
21+
MemberValue::IntegerType(i) => write!(f, "{i}"),
2222
}
2323
}
2424
}
@@ -62,6 +62,7 @@ impl Display for ComplexType {
6262
#[derive(Debug, Deserialize, Clone)]
6363
#[serde(untagged)]
6464
pub enum PrimitiveType {
65+
Any,
6566
String,
6667
Int,
6768
Double,
@@ -83,6 +84,7 @@ pub enum PrimitiveType {
8384
impl Display for PrimitiveType {
8485
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
8586
match self {
87+
PrimitiveType::Any => write!(f, "any"),
8688
PrimitiveType::String => write!(f, "string"),
8789
PrimitiveType::Int => write!(f, "int"),
8890
PrimitiveType::Double => write!(f, "double"),
@@ -110,6 +112,7 @@ where
110112
let s: serde_yaml::Value = serde::Deserialize::deserialize(deserializer)?;
111113
match s {
112114
serde_yaml::Value::String(s) => match s.as_str() {
115+
"any" => Ok(PrimitiveType::Any),
113116
"string" => Ok(PrimitiveType::String),
114117
"int" => Ok(PrimitiveType::Int),
115118
"double" => Ok(PrimitiveType::Double),
@@ -143,8 +146,8 @@ pub enum Type {
143146
impl Display for Type {
144147
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
145148
match self {
146-
Type::Simple(s) => write!(f, "{}", s),
147-
Type::Complex(c) => write!(f, "{}", c),
149+
Type::Simple(s) => write!(f, "{s}"),
150+
Type::Complex(c) => write!(f, "{c}"),
148151
}
149152
}
150153
}
@@ -156,6 +159,7 @@ pub enum ValueType {
156159
Bool(bool),
157160
Integer(i64),
158161
Float(f64),
162+
Any(String),
159163
ArrayString(Vec<String>),
160164
ArrayBool(Vec<bool>),
161165
ArrayInteger(Vec<i64>),
@@ -165,14 +169,15 @@ pub enum ValueType {
165169
impl Display for ValueType {
166170
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
167171
match self {
168-
ValueType::String(s) => write!(f, "{}", s),
169-
ValueType::Bool(b) => write!(f, "{}", b),
170-
ValueType::Integer(i) => write!(f, "{}", i),
171-
ValueType::Float(fl) => write!(f, "{}", fl),
172-
ValueType::ArrayString(s) => write!(f, "{:?}", s),
173-
ValueType::ArrayBool(b) => write!(f, "{:?}", b),
174-
ValueType::ArrayInteger(i) => write!(f, "{:?}", i),
175-
ValueType::ArrayFloat(fl) => write!(f, "{:?}", fl),
172+
ValueType::String(s) => write!(f, "{s}"),
173+
ValueType::Bool(b) => write!(f, "{b}"),
174+
ValueType::Integer(i) => write!(f, "{i}"),
175+
ValueType::Float(fl) => write!(f, "{fl}"),
176+
ValueType::Any(s) => write!(f, "{s}"),
177+
ValueType::ArrayString(s) => write!(f, "{s:?}"),
178+
ValueType::ArrayBool(b) => write!(f, "{b:?}"),
179+
ValueType::ArrayInteger(i) => write!(f, "{i:?}"),
180+
ValueType::ArrayFloat(fl) => write!(f, "{fl:?}"),
176181
}
177182
}
178183
}
@@ -191,13 +196,30 @@ pub struct Attribute {
191196
pub brief: Option<String>,
192197
pub note: Option<String>,
193198
pub examples: Option<Examples>,
194-
pub deprecated: Option<String>,
199+
pub deprecated: Option<Deprecated>,
195200
pub used_by: Option<Vec<String>>,
196201
pub registry_name: Option<String>,
197202
pub defined_in: Option<String>,
198203
pub template_suffixes: Option<BTreeMap<String, Vec<String>>>,
199204
}
200205

206+
#[derive(Debug, Deserialize, Clone)]
207+
pub struct Deprecated {
208+
pub reason: String,
209+
}
210+
211+
impl Display for Deprecated {
212+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
213+
write!(f, "Deprecated: {}", self.reason)
214+
}
215+
}
216+
217+
impl AsRef<str> for Deprecated {
218+
fn as_ref(&self) -> &str {
219+
&self.reason
220+
}
221+
}
222+
201223
impl Attribute {
202224
pub fn is_template_type(&self) -> bool {
203225
matches!(
@@ -246,7 +268,10 @@ impl SemanticConventions {
246268
let entry = entry?;
247269
// print the trailing part of the path after the root_dir
248270
let defined_in = entry.strip_prefix(root_dir)?.to_str().unwrap_or("");
249-
271+
// ignore registry_manifest files
272+
if defined_in.contains("registry_manifest") {
273+
continue;
274+
}
250275
sc.read_file(&entry, registry_name, defined_in)?;
251276
}
252277
}
@@ -259,7 +284,7 @@ impl SemanticConventions {
259284
registry_name: &str,
260285
defined_in: &str,
261286
) -> anyhow::Result<()> {
262-
// println!("reading file: {:?}", path);
287+
//println!("reading file: {:?}", path);
263288
let groups: Groups = serde_yaml::from_reader(&File::open(path)?)?;
264289
for group in groups.groups {
265290
if let Some(attributes) = group.attributes {

0 commit comments

Comments
 (0)