module

CRDoc::Render

Terminal output. Every renderer writes to an IO and honors Context#color?.

Constants

CELL_LIMIT = 36
GUTTER = 2
LONG_LIST = 10
MIN_COLUMNS = 3

Lists of at least this many cells that lay out in fewer columns than MIN_COLUMNS get their longest cells shortened to CELL_LIMIT.

SEARCH_GROUPS = [{"Types", ->(kind : Entry::Kind) do kind.type? end}, {"Constructors", ->(kind : Entry::Kind) do kind.constructor? end}, {"Class methods", ->(kind : Entry::Kind) do kind.class_method? end}, {"Macros", ->(kind : Entry::Kind) do kind.macro? end}, {"Instance methods", ->(kind : Entry::Kind) do kind.instance_method? end}, {"Constants", ->(kind : Entry::Kind) do kind.constant? end}, {"Enum members", ->(kind : Entry::Kind) do kind.enum_member? end}]
SKIPPED_ANCESTORS = ["Object", "Reference", "Value"]

Ancestors that add nothing to the "From ..." lines.

SUMMARY_MIN_ROOM = 12

Smallest summary worth showing.

SUMMARY_MIN_WIDTH = 50

Below this width, one-line members drop their summaries.

TIOCGWINSZ = 21523_u64

Class methods

column_layout(cells : Array(Cell), available : Int32, limit : Int32 = Int32::MAX) : Tuple(Int32, Array(Int32))

Picks the most columns that fit, searching down from the most that could fit at all. Cells wider than limit count as limit wide. Returns the row count and column widths.

Source
declaration(entry : Entry, name : String = entry.name) : String

name followed by its signature, as a method or constant is declared.

Source
entry_cells(entries : Array(Entry)) : Array(Cell)

Cells of full names, labeled with the source when several sources are present.

Source
list(result : Resolver::ListResult, io : IO, context : Context) : Nil
Source
markdown(text : String, io : IO, context : Context, indent : Int32 = 0) : Nil

Markdown doc text to ANSI (or plain) text, indented by indent spaces.

Source
members(result : Resolver::MemberResult, io : IO, context : Context) : Nil
Source
multiple_sources?(entries : Array(Entry)) : Bool
Source
not_found(result : Resolver::NotFoundResult, io : IO, context : Context) : Nil
Source
paged(enabled : Bool, & : IO -> ) : Nil

Yields an IO that pages through $PAGER (default less -R) when enabled and stdout is a TTY and the output is taller than the terminal.

Source
pager_command(pager : String | Nil) : Tuple(String, Array(String))

Command and arguments for a $PAGER value. Bare less gets -R.

Source
search_results(matches : Array(Search::Match), io : IO, context : Context, highlight : Regex | Nil = nil) : Nil

Grouped by kind, with the matching doc line as an excerpt.

Source
shell_word(word : String) : String

Quotes word for a shell command line when it needs it.

Source
signatures(entries : Array(Entry), io : IO, context : Context) : Nil

Full names in terminal-width columns, like ls. One line per method: full name and signature.

Source
source_label(entry : Entry) : String | Nil

[shard:fake] for entries from a non-stdlib source, else nil.

Source
taller_than?(text : String, rows : Int32) : Bool

True when text has more lines than fit in rows.

Source
terminal_size

Terminal size as {columns, rows}, from the tty, then COLUMNS/LINES, then 80x24.

Source
topic(topic : Cheats::Topic, also : Array(Entry), io : IO, context : Context) : Nil
Source
truncate(text : String, limit : Int32) : String

Cuts text to limit characters, ending with … when it cuts.

Source
truncate_middle(text : String, limit : Int32) : String

Cuts text to limit characters, keeping both ends around a ….

Source
type_page(result : Resolver::TypeResult, index : Index, io : IO, context : Context, full : Bool = false) : Nil

Type doc plus one-line member summaries, or every member in full when full.

Source
write_columns(cells : Array(Cell), io : IO, context : Context, indent : Int32 = 0) : Nil

Writes cells in ls-style columns: column-major, each column as wide as its widest cell, two spaces between columns, as many columns as fit.

Source
write_list(result : Resolver::ListResult, io : IO, context : Context) : Nil
Source
write_members(entries : Array(Entry), io : IO, context : Context) : Nil

Writes each entry in full: header, source line and doc.

Source
write_not_found(result : Resolver::NotFoundResult, io : IO, context : Context) : Nil
Source
write_paged(enabled : Bool, & : IO -> ) : Nil

Yields an IO that pages through $PAGER (default less -R) when enabled and stdout is a TTY and the output is taller than the terminal.

Source
write_search_results(matches : Array(Search::Match), io : IO, context : Context, highlight : Regex | Nil = nil) : Nil
Source
write_signatures(entries : Array(Entry), io : IO, context : Context) : Nil
Source
write_topic(topic : Cheats::Topic, also : Array(Entry), io : IO, context : Context) : Nil
Source
write_type_page(result : Resolver::TypeResult, index : Index, io : IO, context : Context, full : Bool) : Nil
Source

Nested types