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: (File) ⇒ Boolean, steps: Vector[((Path) ⇒ DocumentType, (File) ⇒ Boolean) ⇒ Kleisli[F, InputTree[F], InputTree[F]]], fileRoots: Vector[File])(implicit F: Sync[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 addClasspathResource(name: String, mountPoint: Path)(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 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.

  5. 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.

  6. def addDirectories(dirs: Seq[File])(implicit codec: Codec): InputTreeBuilder[F]

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

  7. def addDirectory(dir: File, 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.

  8. def addDirectory(dir: File)(implicit codec: Codec): InputTreeBuilder[F]

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

  9. 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.

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

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

  11. 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.

  12. def addFile(file: File, 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.

  13. 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.

  14. 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.

  15. 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.

  16. def addStream(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 addString(str: 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.

  18. 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 Laika is not based on interim HTML results.

  19. 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.

  20. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  21. 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.

  22. 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.

  23. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  24. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  26. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  27. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  30. def merge(other: InputTree[F]): InputTreeBuilder[F]

    Merges this input tree with the specified tree, recursively.

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

    Merges this input tree with the specified tree, recursively.

  32. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  33. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  35. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  40. def withFileFilter(filter: (File) ⇒ Boolean): 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.

Inherited from AnyRef

Inherited from Any

Ungrouped