Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ Parameters:

Removes leading blank lines from a `Doc`.

#### nontext

`nontext (str[, width])`

Parameters:

`str`
: non-textual string

`width`
: effective width; defaults to 0

Creates a `Doc` value that contains the raw string and behaves as
if it had the specified width. A typical use-case are in-band
formatting commands.

#### nowrap

`nowrap (doc)`
Expand Down
21 changes: 20 additions & 1 deletion src/HsLua/Module/DocLayout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module HsLua.Module.DocLayout (
, literal
, nest
, nestle
, nontext
, nowrap
, parens
, prefixed
Expand Down Expand Up @@ -171,6 +172,7 @@ functions =
, literal
, nest
, nestle
, nontext
, nowrap
, parens
, prefixed
Expand Down Expand Up @@ -444,7 +446,7 @@ literal :: LuaError e => DocumentedFunction e
literal = defun "literal"
### liftPure Doc.literal
<#> textParam "text" "literal value"
=#> docResult "doc contatining just the literal string"
=#> docResult "doc containing just the literal string"
#? "Creates a `Doc` from a string."

-- | Indents a @'Doc'@ by the specified number of spaces.
Expand All @@ -464,6 +466,23 @@ nestle = defun "nestle"
=#> docResult "`doc` with leading blanks removed"
#? "Removes leading blank lines from a `Doc`."

-- | Create a @Doc@ value that contains in-band formatting commands or
-- similar information. The width of such commands can be specified
-- explicitly.
nontext :: LuaError e => DocumentedFunction e
nontext = defun "nontext"
### (liftPure2 $ \text -> \case
Nothing -> Doc.Text 0 text
Just width -> Doc.Text width text)
<#> textParam "str" "non-textual string"
<#> opt (integralParam "width" "effective width; defaults to 0")
=#> docResult "The literal string, treated as having the given width."
#? T.unlines
[ "Creates a `Doc` value that contains the raw string and behaves as"
, "if it had the specified width. A typical use-case are in-band"
, "formatting commands."
]

-- | Makes a @'Doc'@ non-reflowable.
nowrap :: LuaError e => DocumentedFunction e
nowrap = defun "nowrap"
Expand Down