class Crycco::Section

Overview

Section

Document contents are organized in sections, which have docs and code. The docs are markdown extracted from comments and the code is the actual code.

Sections can be converted to HTML using the #docs_html and #code_html methods.

Defined in:

crycco.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(language : Language) #

On initialization we get the language definition and create a lexer and formatter for code highlighting.


[View source]

Instance Method Detail

def code : String #

[View source]
def code=(code : String) #

[View source]
def code_html #

All the code is passed through the formatter to get syntax highlighting


[View source]
def docs : String #

[View source]
def docs=(docs : String) #

[View source]
def docs_html #

#docs_html converts the docs to HTML using the Markd library. The md_to_html is a thin wrapper around Markd that changes how some specific things are rendered, specifically source code. You can see the implementation in markd.cr


[View source]
def language : Language #

[View source]
def language=(language : Language) #

[View source]
def to_h : Hash(String, String) #

The #to_h method is used to turn the section into something that can be handled by the Crinja template engine. Just takes the data and put it in a hash.


[View source]
def to_literate : String #

#to_literate converts the section into valid markdown with code blocks as indented blocks.


[View source]
def to_markdown : String #

#to_markdown converts the section into valid markdown with code blocks for the source code.


[View source]
def to_source : String #

#to_source regenerates valid source code out of the section. This way if the section was generated by a literate document, we can extract the code and comments from it and save it to a file.


[View source]