class Crycco::Collection

Overview

A Collection is a group of sources that will be processed together and saved to the same output directory while preserving the directory structure of the sources.

This way the logic for path manipulation is centrallized here and the Document class can be simpler.

Defined in:

collection.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(sources : Array(String), out_dir : String, template : String, mode : String, theme : String = "default-dark") #

On initialization, we create documents for each source file


[View source]

Instance Method Detail

def common_prefix : String #

Find the common prefix of the sources, this is used to preserve the directory structure when saving the documents.


[View source]
def dst_path(doc : Document) : Path #

Calculate destionation paths for the documents. If the as_source option is set, the output should be a source file, so it will have the language's extension and use the source template.

If the source is literate (eg: foo.yml.md), the destination will have the same name as the source but without the final ".md"

When the output is a document, ".html" is appended to the destination.


[View source]
def save #

Save the documents to the output directory.

As extra context for rendering, we pass links to all the documents in the collection and the theme context which contains a selection of colors from the theme.


[View source]