MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / parse_docs_catalog

Function parse_docs_catalog

xtask/src/extension_catalog.rs:943–978  ·  view source on GitHub ↗
(path: &Path)

Source from the content-addressed store, hash-verified

941}
942
943fn parse_docs_catalog(path: &Path) -> Result<BTreeMap<String, DocsCatalogEntry>> {
944 let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?;
945 let mut entries = BTreeMap::new();
946 let mut current = DocsCatalogEntryBuilder::default();
947 let mut in_entry = false;
948 for line in text.lines() {
949 let trimmed = line.trim();
950 if trimmed == "{" {
951 in_entry = true;
952 current = DocsCatalogEntryBuilder::default();
953 continue;
954 }
955 if !in_entry {
956 continue;
957 }
958 if trimmed == "}," || trimmed == "}" {
959 if let Some(entry) = std::mem::take(&mut current).finish() {
960 entries.insert(entry.import_name.clone(), entry);
961 }
962 in_entry = false;
963 continue;
964 }
965 if let Some(value) = parse_string_field(trimmed, "name") {
966 current.name = Some(value.to_owned());
967 } else if let Some(value) = parse_string_field(trimmed, "importPath") {
968 current.import_path = Some(value.to_owned());
969 } else if let Some(value) = parse_string_field(trimmed, "importName") {
970 current.import_name = Some(value.to_owned());
971 } else if let Some(value) = parse_u64_field(trimmed, "size") {
972 current.size = Some(value);
973 } else if let Some(tags) = parse_tags_field(trimmed) {
974 current.tags = tags;
975 }
976 }
977 Ok(entries)
978}
979
980fn parse_package_exports(path: &Path) -> Result<BTreeMap<String, String>> {
981 let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?;

Callers 1

discover_catalogFunction · 0.85

Calls 5

parse_string_fieldFunction · 0.85
parse_u64_fieldFunction · 0.85
parse_tags_fieldFunction · 0.85
finishMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected