c

laika.io.model

InputTreeBuilder

class InputTreeBuilder[F[_]] extends AnyRef

Builder API for freely constructing input trees from directories, files, classpath resources, in-memory strings or pre-constructed AST trees.

If your input is just one or more directories, you can use the corresponding shortcuts on the parser or transformer instances, e.g. transformer.fromDirectory(...).toDirectory(...). This builder is meant to be used for situations where more flexibility is required.

All the specified inputs will be combined into a single logical tree and each document gets a virtual path assigned that describes its logical position within the tree. As a consequence all cross-linking or referencing of images can happen within the virtual path abstraction, meaning a resource from the file system can point to an input constructed in-memory via a relative, virtual path.

When adding strings, files or directories you need to specify a "mount point" that signals where within the virtual tree the inputs should be placed. For adding directories the mount point is optional, when omitted the directory becomes the virtual root of the input tree.

The resulting input tree can be passed to parsers, transformers and theme builders.

Example for composing inputs from two directories, a template loaded from the classpath and a CSS file generated in-memory:

val inputs = InputTree[F]
  .addDirectory("/path-to-my/markup-files")
  .addDirectory("/path-to-my/images", Root / "images")
  .addClasspathResource("my-templates/default.template.html", DefaultTemplatePath.forHTML)
  .addString(generateMyStyles(), Root / "css" / "site.css")

These inputs can then be configured for the sbt plugin:

laikaInputs := inputs

Or passed to a TreeTransformer instance:

val res: F[RenderedTreeRoot[F]] = transformer.use {
  _.fromInputTree(inputs)
   .toDirectory("target")
   .transform
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. InputTreeBuilder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InputTreeBuilder(exclude: FileFilter, steps: Vector[BuilderStep[F]], fileRoots: Vector[FilePath])(implicit F: Async[F])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addBinaryStream(stream: Stream[F, Byte], mountPoint: Path): InputTreeBuilder[F]

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

    If the content type is text-based the stream will be decoded as UTF-8. In case a different codec is required, use addTextStream and decode the text beforehand.

  5. def addClassLoaderResource(name: String, mountPoint: Path, classLoader: ClassLoader = getClass.getClassLoader)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified classpath resource to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified classpath resource to the input tree, placing it at the specified mount point in the virtual tree. The specified name must be compatible with Java's ClassLoader.getResource. The optional ClassLoader argument can be used to ensure the resource is found in an application or plugin that uses multiple class loaders. If the call site is in the same module as the classpath resource, simply using getClass.getClassLoader should suffice.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

  6. def addClassResource[T](name: String, mountPoint: Path)(implicit arg0: ClassTag[T], codec: Codec): InputTreeBuilder[F]

    Adds the specified classpath resource to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified classpath resource to the input tree, placing it at the specified mount point in the virtual tree. The specified name must be compatible with Java's Class.getResource. Relative paths will be interpreted as relative to the package name of the referenced class, with all . replaced by /.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

  7. def addConfig(config: Config, treePath: Path): InputTreeBuilder[F]

    Adds the specified configuration instance and assigns it to the specified tree path in a way that is equivalent to having a HOCON file called directory.conf in that directory.

  8. def addDirectories(dirs: Seq[FilePath])(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified directories to the input tree, merging them all into a single virtual root, recursively.

  9. def addDirectory(dir: FilePath, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified directories to the input tree, placing it at the specified mount point in the virtual tree.

  10. def addDirectory(dir: FilePath)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified directories to the input tree, placing it in the virtual root.

  11. def addDirectory(name: String, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified directories to the input tree, placing it at the specified mount point in the virtual tree.

  12. def addDirectory(name: String)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified directories to the input tree, placing it in the virtual root.

  13. def addDocument(doc: Document): InputTreeBuilder[F]

    Adds the specified document AST to the input tree, by-passing the parsing step.

    Adds the specified document AST to the input tree, by-passing the parsing step.

    In some cases when generating input on the fly, it might be more convenient or more type-safe to construct the AST directly than to generate the text markup as input for the parser.

  14. def addFile(file: FilePath, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified file to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified file to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

  15. def addFile(name: String, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified file to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified file to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

  16. def addInputStream(stream: F[InputStream], mountPoint: Path, autoClose: Boolean = true)(implicit codec: Codec): InputTreeBuilder[F]

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

    The autoClose argument indicates whether the stream should be closed after use. In some integration scenarios with 3rd-party libraries, e.g. for PDF creation, autoClose is not guaranteed as the handling of the stream is entirely managed by the 3rd party tool.

  17. def addProvidedPath(path: Path): InputTreeBuilder[F]

    Adds a path to the input tree that represents a document getting processed by some external tool.

    Adds a path to the input tree that represents a document getting processed by some external tool. Such a path will be used in link validation, but no further processing for this document will be performed.

  18. def addProvidedPaths(paths: Seq[Path]): InputTreeBuilder[F]

    Adds the specified paths to the input tree that represent documents getting processed by some external tool.

    Adds the specified paths to the input tree that represent documents getting processed by some external tool. Such a path will be used in link validation, but no further processing for this document will be performed.

  19. def addString(input: String, mountPoint: Path): InputTreeBuilder[F]

    Adds the specified string resource to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified string resource to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. * doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

  20. def addStyles(styles: Set[StyleDeclaration], path: Path, precedence: Precedence = Precedence.High): InputTreeBuilder[F]

    Adds the specified styles for PDF to the input tree.

    Adds the specified styles for PDF to the input tree. These type of style declarations are only used in the context of Laika's "CSS for PDF" support which works slightly differently than web CSS as PDF generation in Laika is not based on interim HTML results.

  21. def addTemplate(doc: TemplateDocument): InputTreeBuilder[F]

    Adds the specified template AST to the input tree, by-passing the parsing step.

    Adds the specified template AST to the input tree, by-passing the parsing step.

    In some cases when generating input on the fly, it might be more convenient or more type-safe to construct the AST directly than to generate the template as a string as input for the template parser.

  22. def addTextStream(stream: Stream[F, String], mountPoint: Path): InputTreeBuilder[F]

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    Adds the specified input stream to the input tree, placing it at the specified mount point in the virtual tree.

    The content type of the stream will be determined by the suffix of the virtual path, e.g. doc.md would be passed to the markup parser, doc.template.html to the template parser, and so on.

    If the target content type is binary the stream will be encoded as UTF-8. In case a different codec is required, use addBinaryStream and encode the text beforehand.

  23. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  24. def build(docTypeMatcher: (Path) ⇒ DocumentType): F[InputTree[F]]

    Builds the tree based on the inputs added to this instance and the specified custom document type matcher.

    Builds the tree based on the inputs added to this instance and the specified custom document type matcher.

    The method is effectful as it might involve scanning directories to determine the tree structure.

    This method is normally not called by application code directly, as the parser and transformer APIs expect an InputTreeBuilder instance.

  25. def build: F[InputTree[F]]

    Builds the tree based on the inputs added to this instance.

    Builds the tree based on the inputs added to this instance.

    The method is effectful as it might involve scanning directories to determine the tree structure.

    This method is normally not called by application code directly, as the parser and transformer APIs expect an InputTreeBuilder instance.

  26. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  27. def describe(docTypeMatcher: (Path) ⇒ DocumentType): F[TreeInputDescriptor]

    Provides a description of this input tree.

    Provides a description of this input tree. Input directories will be scanned or reported in case they don't exist. Documents added to this builder individually will be listed without additional checks.

    This functionality is mostly intended for tooling support.

  28. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  30. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  31. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  32. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  33. def merge(other: InputTree[F]): InputTreeBuilder[F]

    Merges this input tree with the specified tree, recursively.

  34. def merge(other: InputTreeBuilder[F]): InputTreeBuilder[F]

    Merges this input tree with the specified tree, recursively.

  35. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  37. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  38. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  39. def toString(): String
    Definition Classes
    AnyRef → Any
  40. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  41. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. def withFileFilter(newFilter: FileFilter): InputTreeBuilder[F]

    Adds the specified file filter to this input tree.

    Adds the specified file filter to this input tree.

    The filter will only be used for scanning directories when calling addDirectory on this builder, not for any of the other methods.

Deprecated Value Members

  1. def addClasspathResource(name: String, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.0) Use addClassResource or addClassLoaderResource

  2. def addDirectory(dir: File, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.0) use addDirectory(String, Path) or addDirectory(FilePath, Path)

  3. def addDirectory(dir: File)(implicit codec: Codec): InputTreeBuilder[F]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.0) use addDirectory(String) or addDirectory(FilePath)

  4. def addFile(file: File, mountPoint: Path)(implicit codec: Codec): InputTreeBuilder[F]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.0) use addFile(String) or addFile(FilePath)

  5. def addStream(stream: F[InputStream], mountPoint: Path, autoClose: Boolean = true)(implicit codec: Codec): InputTreeBuilder[F]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.19.0) use addInputStream

  6. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped