Class AdocPackages

java.lang.Object
network.ike.docs.plugin.packages.AdocPackages

public final class AdocPackages extends Object
The packages layout of an AsciiDoc root (dev-adoc-packages, IKE-Network/ike-issues#1341): the first directory under the root is the owning group written as one dotted segment, network.ike.lab, and the directory under that is the topic domain, so a topic is network.ike.lab/dev/gitflow-overview.adoc and its package is network.ike.lab/dev. A library whose group ends in its only domain may use the group directory itself as the domain package: the ANF kompendium's topics are network.ike.kompendium.anf/determine-topic.adoc, in the package network.ike.kompendium.anf. META-INF is reserved for what describes the artifact; every group begins with a top-level domain, so the two never meet.

This class enumerates the packages a root holds and what each holds, the reading the manifest and the lint share.

Since:
136
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    One package of a root.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
    A group directory's name: a reverse-DNS group as one dotted segment, at least two labels of lowercase letters, digits, hyphens and underscores, as a Maven group id is written.
    static final String
    The directory inside a package that holds its images.
    static final String
    The reserved directory for artifact metadata, never a package.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Path>
    children(Path directory)
    The immediate entries of a directory in name order.
    static List<Path>
    The group directories of a root: its immediate subdirectories whose name is a dotted group.
    headers(Path root, Path directory)
    Parse the header of every .adoc file under a directory, in path order, paths relative to the root; symbolic links and the directories TopicRegistry.SKIPPED_DIRS are left out.
    static boolean
    Whether a group directory is itself the domain package: it holds an .adoc file directly, as the ANF library's group directory does.
    static String
    metaDirectory(String groupId, String artifactId)
    The metadata directory of an artifact inside the zip and the union, keyed by its coordinates so that it cannot collide: META-INF/ike/<groupId>/<artifactId>.
    packages(Path root, String libraryPackage)
    Enumerate the packages of a root: for each group directory, the group itself when it holds topics directly, otherwise each subdirectory of it as <group>/<domain>, hidden directories left out.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • META_INF

      public static final String META_INF
      The reserved directory for artifact metadata, never a package.
      See Also:
    • IMAGES

      public static final String IMAGES
      The directory inside a package that holds its images.
      See Also:
    • GROUP

      public static final Pattern GROUP
      A group directory's name: a reverse-DNS group as one dotted segment, at least two labels of lowercase letters, digits, hyphens and underscores, as a Maven group id is written.
  • Method Details

    • metaDirectory

      public static String metaDirectory(String groupId, String artifactId)
      The metadata directory of an artifact inside the zip and the union, keyed by its coordinates so that it cannot collide: META-INF/ike/<groupId>/<artifactId>.
      Parameters:
      groupId - the artifact's group id
      artifactId - the artifact's artifact id
      Returns:
      the relative path with / separators
    • groupDirectories

      public static List<Path> groupDirectories(Path root) throws IOException
      The group directories of a root: its immediate subdirectories whose name is a dotted group.
      Parameters:
      root - the AsciiDoc root
      Returns:
      the directories in name order
      Throws:
      IOException - if the root cannot be listed
    • isDomainPackage

      public static boolean isDomainPackage(Path group) throws IOException
      Whether a group directory is itself the domain package: it holds an .adoc file directly, as the ANF library's group directory does.
      Parameters:
      group - the group directory
      Returns:
      true when the group directory holds topics directly
      Throws:
      IOException - if the directory cannot be listed
    • packages

      public static List<AdocPackages.Package> packages(Path root, String libraryPackage) throws IOException
      Enumerate the packages of a root: for each group directory, the group itself when it holds topics directly, otherwise each subdirectory of it as <group>/<domain>, hidden directories left out. Every .adoc file under a package is parsed for its header, which is what the kind and the lint's domain rule are decided by.
      Parameters:
      root - the AsciiDoc root
      libraryPackage - the package ike.adoc.library-package names as the library's own, or null
      Returns:
      the packages in name order
      Throws:
      IOException - if the tree cannot be read
    • headers

      public static List<TopicHeader> headers(Path root, Path directory) throws IOException
      Parse the header of every .adoc file under a directory, in path order, paths relative to the root; symbolic links and the directories TopicRegistry.SKIPPED_DIRS are left out.
      Parameters:
      root - the AsciiDoc root paths are relative to
      directory - the directory to walk, under the root
      Returns:
      the parsed headers
      Throws:
      IOException - if a file cannot be read
    • children

      public static List<Path> children(Path directory) throws IOException
      The immediate entries of a directory in name order.
      Parameters:
      directory - the directory
      Returns:
      its entries
      Throws:
      IOException - if it cannot be listed