class Crycco::Section
- Crycco::Section
- Reference
- Object
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.crConstructors
-
.new(language : Language)
On initialization we get the language definition and create a lexer and formatter for code highlighting.
Instance Method Summary
- #code : String
- #code=(code : String)
-
#code_html
All the code is passed through the formatter to get syntax highlighting
- #docs : String
- #docs=(docs : String)
-
#docs_html
#docs_html
converts the docs to HTML using the Markd library. - #language : Language
- #language=(language : Language)
-
#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. -
#to_literate : String
#to_literate
converts the section into valid markdown with code blocks as indented blocks. -
#to_markdown : String
#to_markdown
converts the section into valid markdown with code blocks for the source code. -
#to_source : String
#to_source
regenerates valid source code out of the section.
Constructor Detail
On initialization we get the language definition and create a lexer and formatter for code highlighting.
Instance Method Detail
#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
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.
#to_literate
converts the section into valid markdown with code blocks
as indented blocks.
#to_markdown
converts the section into valid markdown with code blocks
for the source code.
#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.