MCPcopy
hub / github.com/Col-E/Recaf / loadDocs

Method loadDocs

src/main/java/me/coley/recaf/workspace/JavaResource.java:377–400  ·  view source on GitHub ↗

@param path File containing documentation. @return Map of class names to their documentation. @throws IOException When the file could not be fetched or parsed.

(Path path)

Source from the content-addressed store, hash-verified

375 * When the file could not be fetched or parsed.
376 */
377 protected Map<String, Javadocs> loadDocs(Path path) throws IOException {
378 Map<String, Javadocs> map = new HashMap<>(512, 1F);
379 // Will throw IO exception if the file couldn't be opened as an archive
380 try (ZipFile zip = new ZipFile(path.toFile())) {
381 Enumeration<? extends ZipEntry> entries = zip.entries();
382 while (entries.hasMoreElements()) {
383 ZipEntry entry = entries.nextElement();
384 String name = entry.getName();
385 if (!name.endsWith(".html"))
386 continue;
387 if (name.contains("-") || name.contains("index"))
388 continue;
389 String src = IOUtils.toString(zip.getInputStream(entry), StandardCharsets.UTF_8);
390 try {
391 Javadocs docs = new Javadocs(name, src);
392 docs.parse();
393 map.put(docs.getInternalName(), docs);
394 } catch(DocumentationParseException ex) {
395 error(ex, "Failed to parse docs: {} in {}", name, path);
396 }
397 }
398 }
399 return map;
400 }
401
402 /**
403 * Loads the source code from the given file.

Callers 1

setClassDocsMethod · 0.95

Calls 7

parseMethod · 0.95
getInternalNameMethod · 0.95
getNameMethod · 0.65
containsMethod · 0.45
toStringMethod · 0.45
putMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected