@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)
| 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. |
no test coverage detected