- 所有超级接口:
Docile
- 所有已知实现类:
Doc.Cat,Doc.Column,Doc.Empty,Doc.FlatAlt,Doc.HyperLinked,Doc.Line,Doc.Nest,Doc.Nesting,Doc.PageWidth,Doc.PlainText,Doc.SpecialSymbol,Doc.Styled,Doc.Union
public sealed interface Doc
extends Docile
permits Doc.HyperLinked, Doc.Nest, Doc.Union, Doc.FlatAlt, Doc.Styled, Doc.Empty, Doc.PlainText, Doc.SpecialSymbol, Doc.Line, Doc.Cat, Doc.Column, Doc.Nesting, Doc.PageWidth
This class reimplemented Haskell
PrettyPrint library's Doc module.
-
嵌套类概要
嵌套类修饰符和类型接口说明static final recordConcatenation of two documentsstatic final recordA document that will react on the current cursor position.static final recordThe empty document; conceptually the unit of 'Cat'static final recordLay out the defaultDoc 'Doc', but when flattened (via 'group'), prefer the preferWhenFlatten.static final recordA clickable text line without '\n'.static final recordHard line breakstatic final recordDocument indented by a number of columnsstatic final recordA document that will react on the current nest level.static final recordA document that will react on the page width.static final recordA plain text line without '\n'.static final recordA special symbol that may get rendered in a special waystatic final recordStyled documentstatic final recordThe first lines of first document should be shorter than the first lines of the second one, so the layout algorithm can pick the one that fits best. -
字段概要
字段 -
方法概要
修饰符和类型方法说明static @NotNull Docalign lays out the document with the nesting level set to the current column.static @NotNull Docdefault @NotNull kala.collection.SeqLike<Doc>asSeq()static @NotNull Docstatic @NotNull Doccat tries laying out the documents separated with nothing, and if this does not fit the page, separates them with newlines.static @NotNull Docstatic @NotNull DocCreates a C-style indented block of statements.static @NotNull Doccolumn(@NotNull IntFunction<Doc> docBuilder) Layout a document depending on which column it starts at.static @NotNull Docdefault @NotNull StringProduce unicode and 80-width outputdefault @NotNull StringProduce ASCII and infinite-width outputstatic @NotNull Docempty()The empty document; conceptually the unit of 'Cat'static @NotNull DocReturn conditionalempty()static @NotNull Docstatic @NotNull DocBy default, flatAlt renders as .static @NotNull Dochang lays out the document with a nesting level set to the /current column/ plus .static @NotNull Docstatic @NotNull Docdefault booleanstatic @NotNull Docstatic @NotNull Docstatic @NotNull Docstatic @NotNull Docline()Unconditionally line breakstatic @NotNull Docstatic @NotNull Docstatic @NotNull Doclays out the document with the current nesting level (indentation of the following lines) increased by .static @NotNull Docnesting(@NotNull IntFunction<Doc> docBuilder) Layout a document depending on the current 'nest'-ing level.static @NotNull Docordinal(int n) static @NotNull DocpageWidth(@NotNull IntFunction<Doc> docBuilder) Layout a document depending on the page width, if one has been specified.static @NotNull DocIndents by columns, and then indent the first line again by columns.static @NotNull Docstatic @NotNull DocPlain text documentdefault <Out,Config extends PrinterConfig>
Outdefault @NotNull Stringdefault @NotNull StringrenderToHtml(boolean withHeader) default @NotNull StringrenderToString(@NotNull StringPrinterConfig config) default @NotNull Stringdefault @NotNull StringrenderWithPageWidth(int pageWidth, boolean unicode) static @NotNull Docstatic @NotNull DocfillSep concatenates the documents horizontally with a space as long as it fits the page, then inserts a 'line' and continues doing that for all documents in .static @NotNull DocsepNonEmpty(@NotNull kala.collection.SeqLike<Doc> docs) static @NotNull DocsepNonEmpty(Doc @NotNull ... docs) static @NotNull DocstickySep concatenates all documents horizontally with a space, i.e. it puts a space between all entries.static @NotNull Docstatic @NotNull Docstatic @NotNull Docstatic @NotNull Docstatic @NotNull Docstatic @NotNull Docdefault @NotNull DoctoDoc()static @NotNull Docstatic @NotNull Docstatic @NotNull DocvcatNonEmpty(@NotNull kala.collection.SeqLike<Doc> docs) static @NotNull DocvcatNonEmpty(Doc @NotNull ... docs) static @NotNull Doc
-
字段详细资料
-
ONE_WS
-
ALT_WS
-
COMMA
-
-
方法详细资料
-
isNotEmpty
default boolean isNotEmpty() -
toDoc
-
asSeq
-
renderToString
-
renderToHtml
-
renderToHtml
-
renderToTeX
-
render
@NotNull default <Out,Config extends PrinterConfig> Out render(@NotNull @NotNull Printer<Out, Config> printer, @NotNull Config config) -
renderWithPageWidth
-
debugRender
Produce ASCII and infinite-width output -
commonRender
Produce unicode and 80-width output -
linkDef
-
linkRef
-
hyperLink
-
hyperLink
-
styled
-
styled
-
styled
-
styled
-
licit
-
wrap
-
braced
-
angled
-
parened
-
emptyIf
Return conditionalempty()- 参数:
cond- conditionotherwise- otherwise- 返回:
Doc.Emptywhencondis true, otherwiseotherwise
-
empty
The empty document; conceptually the unit of 'Cat'- 返回:
- empty document
-
flatAlt
@Contract("_, _ -> new") @NotNull static @NotNull Doc flatAlt(@NotNull @NotNull Doc defaultDoc, @NotNull @NotNull Doc preferWhenFlattened) By default, flatAlt renders as . However, when 'group'-ed, will be preferred, with as the fallback for the case when doesn't fit.- 参数:
defaultDoc- default documentpreferWhenFlattened- document selected when flattened- 返回:
- alternative document
-
column
@Contract("_ -> new") @NotNull static @NotNull Doc column(@NotNull @NotNull IntFunction<Doc> docBuilder) Layout a document depending on which column it starts at.align(Doc)is implemented in terms ofcolumn.- 参数:
docBuilder- document generator when current position provided- 返回:
- column action document
-
nesting
@Contract("_ -> new") @NotNull static @NotNull Doc nesting(@NotNull @NotNull IntFunction<Doc> docBuilder) Layout a document depending on the current 'nest'-ing level.align(Doc)is implemented in terms ofnesting.- 参数:
docBuilder- document generator when current nest level provided- 返回:
- nest level action document
-
pageWidth
@Contract("_ -> new") @NotNull static @NotNull Doc pageWidth(@NotNull @NotNull IntFunction<Doc> docBuilder) Layout a document depending on the page width, if one has been specified.- 参数:
docBuilder- document generator when page width provided- 返回:
- page width action document
-
nest
lays out the document with the current nesting level (indentation of the following lines) increased by . Negative values are allowed, and decrease the nesting level accordingly.- 参数:
indent- indentation of the following linesdoc- the document to lay out- 返回:
- indented document
-
align
align lays out the document with the nesting level set to the current column. It is used for example to implementhang(int, Doc).As an example, we will put a document right above another one, regardless of the current nesting level. Without 'align'-ment, the second line is put simply below everything we've had so far,
If we add an 'align' to the mix, the @'vsep'@'s contents all start in the same column,
- 参数:
doc- document to be aligned- 返回:
- aligned document
-
hang
@Contract("_, _ -> new") @NotNull static @NotNull Doc hang(int deltaNest, @NotNull @NotNull Doc doc) hang lays out the document with a nesting level set to the /current column/ plus . Negative values are allowed, and decrease the nesting level accordingly.This differs from
nest(int, Doc), which is based on the /current nesting level/ plusindent. When you're not sure, try the more efficient 'nest' first. In our example, this would yield- 参数:
deltaNest- change of nesting level, relative to the start of the first linedoc- document to indent- 返回:
- hang-ed document
-
par
Indents by columns, and then indent the first line again by columns.- 参数:
indent- the indented nesting leveldoc- document to indent- 返回:
- indented document
-
cblock
@Contract("_, _, _ -> new") @NotNull static @NotNull Doc cblock(@NotNull @NotNull Doc prefix, int indent, @NotNull @NotNull Doc block) Creates a C-style indented block of statements.prefix { [indent]block } -
ordinal
-
plain
Plain text document- 参数:
text- text that may not contain '\n'- 返回:
- text document of the whole text
-
english
-
symbol
- 参数:
text- '\n' not allowed!- 返回:
- special symbol
-
cat
@Contract("_ -> new") @NotNull static @NotNull Doc cat(@NotNull @NotNull kala.collection.SeqLike<Doc> docs) cat tries laying out the documents separated with nothing, and if this does not fit the page, separates them with newlines. This is what differentiates it from 'vcat', which always lays out its contents beneath each other.- 参数:
docs- documents to concat- 返回:
- cat document
-
cat
- 另请参阅:
-
vcat
-
vcat
-
vcatNonEmpty
-
vcatNonEmpty
-
stickySep
@Contract("_ -> new") @NotNull static @NotNull Doc stickySep(@NotNull @NotNull kala.collection.SeqLike<@NotNull Doc> docs) stickySep concatenates all documents horizontally with a space, i.e. it puts a space between all entries.stickySep does not introduce line breaks on its own, even when the page is too narrow:
- 参数:
docs- documents to separate- 返回:
- separated documents
-
stickySep
-
sep
fillSep concatenates the documents horizontally with a space as long as it fits the page, then inserts a 'line' and continues doing that for all documents in . ('line' means that if 'group'ed, the documents are separated with a 'space' instead of newlines. Usecat(kala.collection.SeqLike<org.aya.pretty.doc.Doc>)if you do not want a 'space'.Let's print some words to fill the line:
- 参数:
docs- documents to separate- 返回:
- separated documents
-
sep
-
sepNonEmpty
-
sepNonEmpty
-
commaList
-
join
-
join
-
line
Unconditionally line break- 返回:
- hard line document
-