(path: &Path)
| 941 | } |
| 942 | |
| 943 | fn 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 | |
| 980 | fn parse_package_exports(path: &Path) -> Result<BTreeMap<String, String>> { |
| 981 | let text = fs::read_to_string(path).with_context(|| format!("read {}", path.display()))?; |
no test coverage detected