MCPcopy Create free account
hub / github.com/csskit/csskit / get_spec_versions

Function get_spec_versions

crates/csskit_spec_generator/src/fetch_cached.rs:103–120  ·  view source on GitHub ↗

Gets a map of spec name to list of available versions For example: "align" -> [3, 4] Parses spec directory names in the format "css-{name}-{version}"

(client: &Client)

Source from the content-addressed store, hash-verified

101///
102/// Parses spec directory names in the format "css-{name}-{version}"
103pub async fn get_spec_versions(client: &Client) -> Result<HashMap<String, Vec<usize>>> {
104 let text = fetch_cached(client, GITHUB_CSSWG_TREE_URL, "index.json").await?;
105 let v: Value = serde_json::from_str(&text)?;
106 let paths = extract_tree_directories(&v)?;
107
108 let mut map: HashMap<String, Vec<usize>> = HashMap::new();
109 for path in paths {
110 if let Some((name, version)) = parse_spec_path(&path) {
111 map.entry(name).or_default().push(version);
112 }
113 }
114
115 for versions in map.values_mut() {
116 versions.sort();
117 }
118
119 Ok(map)
120}
121
122/// Gets the commit SHA of the csswg-drafts repository main branch
123///

Callers 1

mainFunction · 0.85

Calls 3

fetch_cachedFunction · 0.85
extract_tree_directoriesFunction · 0.85
parse_spec_pathFunction · 0.85

Tested by

no test coverage detected