Skip to content

Commit 794ebd1

Browse files
committed
Ensure all function parameters have a description
1 parent 765627f commit 794ebd1

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/HsLua/Module/DocLayout.hs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ render :: LuaError e => DocumentedFunction e
244244
render = defun "render"
245245
### liftPure2 (flip Doc.render)
246246
<#> docParam "doc"
247-
<#> opt (integralParam "colwidth" "")
247+
<#> opt (integralParam "colwidth" "planned maximum line length")
248248
=#> functionResult pushText "Doc" "rendered doc"
249249
#? ("Render a @'Doc'@. The text is reflowed on breakable spaces" <>
250250
"to match the given line length. Text is not reflowed if the" <>
@@ -286,7 +286,7 @@ update_column :: LuaError e => DocumentedFunction e
286286
update_column = defun "update_column"
287287
### liftPure2 Doc.updateColumn
288288
<#> docParam "doc"
289-
<#> integralParam "i" ""
289+
<#> integralParam "i" "start column"
290290
=#> integralResult "column number"
291291
#? ("Returns the column that would be occupied by the last " <>
292292
"laid out character.")
@@ -306,7 +306,7 @@ height = defun "height"
306306
real_length :: DocumentedFunction e
307307
real_length = defun "real_length"
308308
### liftPure Doc.realLength
309-
<#> textParam "str" ""
309+
<#> textParam "str" "UTF-8 string to measure"
310310
=#> integralResult "text length"
311311
#? ("Returns the real length of a string in a monospace font: " <>
312312
"0 for a combining chaeracter, 1 for a regular character, " <>
@@ -321,10 +321,12 @@ real_length = defun "real_length"
321321
after_break :: LuaError e => DocumentedFunction e
322322
after_break = defun "after_break"
323323
### liftPure Doc.afterBreak
324-
<#> textParam "text" ""
324+
<#> textParam "text" "content to include when placed after a break"
325325
=#> docResult "new doc"
326-
#? ("Creates a `Doc` which is conditionally included only if it" <>
327-
"comes at the beginning of a line.")
326+
#? ("Creates a `Doc` which is conditionally included only if it " <>
327+
"comes at the beginning of a line.\n\n" <>
328+
"An example where this is useful is for escaping line-initial " <>
329+
"`.` in roff man.")
328330

329331
-- | Conditionally includes the given @'Doc'@ unless it is
330332
-- followed by a blank space.
@@ -340,7 +342,7 @@ before_non_blank = defun "before_non_blank"
340342
blanklines :: LuaError e => DocumentedFunction e
341343
blanklines = defun "blanklines"
342344
### liftPure Doc.blanklines
343-
<#> integralParam "n" ""
345+
<#> integralParam "n" "number of blank lines"
344346
=#> docResult "conditional blank lines"
345347
#? "Inserts blank lines unless they exist already."
346348

@@ -365,7 +367,7 @@ cblock :: LuaError e => DocumentedFunction e
365367
cblock = defun "cblock"
366368
### liftPure2 (flip Doc.cblock)
367369
<#> docParam "doc"
368-
<#> parameter peekIntegral "integer" "width" "block width in chars"
370+
<#> integralParam "width" "block width in chars"
369371
=#> docResult ("doc, aligned centered in a block with max" <>
370372
"`width` chars per line.")
371373
#? ("Creates a block with the given width and content, " <>
@@ -410,7 +412,7 @@ hang :: LuaError e => DocumentedFunction e
410412
hang = defun "hang"
411413
### liftPure3 (\doc ind start -> Doc.hang ind start doc)
412414
<#> docParam "doc"
413-
<#> parameter peekIntegral "integer" "ind" "indentation width"
415+
<#> integralParam "ind" "indentation width"
414416
<#> docParam "start"
415417
=#> docResult ("`doc` prefixed by `start` on the first line, " <>
416418
"subsequent lines indented by `ind` spaces.")
@@ -432,7 +434,7 @@ lblock :: LuaError e => DocumentedFunction e
432434
lblock = defun "lblock"
433435
### liftPure2 (flip Doc.lblock)
434436
<#> docParam "doc"
435-
<#> parameter peekIntegral "integer" "width" "block width in chars"
437+
<#> integralParam "width" "block width in chars"
436438
=#> docResult "doc put into block with max `width` chars per line."
437439
#? ("Creates a block with the given width and content, " <>
438440
"aligned to the left.")
@@ -441,7 +443,7 @@ lblock = defun "lblock"
441443
literal :: LuaError e => DocumentedFunction e
442444
literal = defun "literal"
443445
### liftPure Doc.literal
444-
<#> textParam "string" ""
446+
<#> textParam "text" "literal value"
445447
=#> docResult "doc contatining just the literal string"
446448
#? "Creates a `Doc` from a string."
447449

@@ -450,7 +452,7 @@ nest :: LuaError e => DocumentedFunction e
450452
nest = defun "nest"
451453
### liftPure2 (flip Doc.nest)
452454
<#> docParam "doc"
453-
<#> parameter peekIntegral "integer" "ind" "indentation size"
455+
<#> integralParam "ind" "indentation size"
454456
=#> docResult "`doc` indented by `ind` spaces"
455457
#? "Indents a `Doc` by the specified number of spaces."
456458

@@ -486,7 +488,7 @@ prefixed :: LuaError e => DocumentedFunction e
486488
prefixed = defun "prefixed"
487489
### liftPure2 (flip Doc.prefixed)
488490
<#> docParam "doc"
489-
<#> parameter peekString "string" "prefix" "prefix for each line"
491+
<#> stringParam "prefix" "prefix for each line"
490492
=#> docResult "prefixed `doc`"
491493
#? ("Uses the specified string as a prefix for every line of " <>
492494
"the inside document (except the first, if not at the " <>
@@ -505,7 +507,7 @@ rblock :: LuaError e => DocumentedFunction e
505507
rblock = defun "rblock"
506508
### liftPure2 (flip Doc.rblock)
507509
<#> docParam "doc"
508-
<#> parameter peekIntegral "integer" "width" "block width in chars"
510+
<#> integralParam "width" "block width in chars"
509511
=#> docResult ("doc, right aligned in a block with max" <>
510512
"`width` chars per line.")
511513
#? ("Creates a block with the given width and content, " <>
@@ -517,7 +519,7 @@ rblock = defun "rblock"
517519
vfill :: LuaError e => DocumentedFunction e
518520
vfill = defun "vfill"
519521
### liftPure Doc.vfill
520-
<#> textParam "border" ""
522+
<#> textParam "border" "vertically expanded characters"
521523
=#> docResult "automatically expanding border Doc"
522524
#? ("An expandable border that, when placed next to a box, " <>
523525
"expands to the height of the box. Strings cycle through the " <>

test/test-doclayout.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ return {
232232
assert.are_equal(doclayout.real_length('a'), 1)
233233
assert.are_equal(doclayout.real_length(''), 1)
234234
assert.are_equal(doclayout.real_length(''), 2)
235+
assert.are_equal(doclayout.real_length('four'), 4)
235236
end),
236237

237238
test('update_column', function ()

0 commit comments

Comments
 (0)