Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/rariPublic

fix(baseline): include data for discouraged features#311

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
LeoMcA wants to merge4 commits intomain
base:main
Choose a base branch
Loading
frombaseline-discouraged
Draft
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
feat(baseline): add urls for discouraged alternatives
  • Loading branch information
@LeoMcA
LeoMcA committedSep 17, 2025
commitf853a76ce986b53c01c712d9230d4ab96dbee6ca
38 changes: 38 additions & 0 deletionscrates/rari-data/src/baseline.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,16 +14,26 @@ use serde_json::Value;
use url::Url;

use crate::error::Error;
use crate::feature_urls::get_mdn_url;

#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct Baseline<'a> {
#[serde(flatten)]
pub support: &'a SupportStatus,
#[serde(skip_serializing_if = "std::ops::Not::not")]
pub asterisk: bool,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub alternatives: Vec<Alternative>,
pub feature: &'a FeatureData,
}

#[derive(Deserialize, Serialize, Clone, Debug, JsonSchema)]
pub struct Alternative {
pub name: String,
pub description: String,
pub mdn_url: String,
}

#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct WebFeatures {
pub features: IndexMap<String, FeatureData>,
Expand DownExpand Up@@ -169,9 +179,37 @@ impl WebFeatures {
_ => true,
}
};

let alternatives = match feature.discouraged.clone() {
Some(discouraged) => discouraged
.alternatives
.iter()
.filter_map(|alternative| {
self.feature_data_by_name(alternative).and_then(|feature| {
match get_mdn_url(alternative) {
Some(url) => Some(Alternative {
name: feature.name.clone(),
description: feature.description.clone(),
mdn_url: url.to_string(),
}),
None => {
tracing::warn!(
"Couldn't find url for {} web feature",
alternative
);
None
}
}
})
})
.collect(),
_ => Vec::new(),
};

return Some(Baseline {
support: status_for_key,
asterisk,
alternatives,
feature,
});
}
Expand Down
44 changes: 44 additions & 0 deletionscrates/rari-data/src/feature_urls.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
use indexmap::IndexMap;
use std::sync::LazyLock;

static FEATURE_MDN_URLS: LazyLock<IndexMap<&'static str, &'static str>> = LazyLock::new(|| {
[
("async-clipboard", "/docs/Web/API/Clipboard_API"),
("background-color", "/docs/Web/CSS/background-color"),
("clip-path", "/docs/Web/CSS/clip-path"),
("color", "/docs/Web/CSS/color"),
("container-style-queries", "/docs/Web/CSS/@container"),
(
"contenteditable",
"/docs/Web/HTML/Reference/Global_attributes/contenteditable",
),
("css-object-model", "/docs/Web/API/CSS_Object_Model"),
(
"destructuring",
"/docs/Web/JavaScript/Reference/Operators/Destructuring",
),
("dom", "/docs/Web/API/Document_Object_Model"),
("font-face", "/docs/Web/CSS/@font-face"),
(
"get-computed-style",
"/docs/Web/API/Window/getComputedStyle",
),
("media-queries", "/docs/Web/CSS/@media"),
("mutationobserver", "/docs/Web/API/MutationObserver"),
(
"navigation-timing",
"/docs/Web/API/Performance_API/Navigation_timing",
),
("page-breaks", "/docs/Web/CSS/break-after"),
("performance", "/docs/Web/API/Performance_API"),
("scheduler", "/docs/Web/API/Prioritized_Task_Scheduling_API"),
("svg", "/docs/Web/SVG"),
("webxr-device", "/docs/Web/API/WebXR_Device_API"),
]
.into_iter()
.collect()
});

pub fn get_mdn_url(feature_key: &str) -> Option<&'static str> {
FEATURE_MDN_URLS.get(feature_key).copied()
}
1 change: 1 addition & 0 deletionscrates/rari-data/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
pub mod baseline;
pub mod error;
pub mod feature_urls;
pub mod specs;
Loading

[8]ページ先頭

©2009-2025 Movatter.jp