Module luadoc.util

Module with several utilities that could not fit in a specific module

Functions

trim (s) Removes spaces from the begining and end of a given string
trim_comment (s) Removes spaces from the begining and end of a given string, considering the string is inside a lua comment.
line_empty (line) Checks if a given line is empty
concat (str1, str2) Appends two string, but if the first one is nil, use to second one
split (delim, text) Split text into a list consisting of the strings in text, separated by strings matching delim (which may be a pattern).
comment (text) Comments a paragraph.
wrap (s, w, i1, i2) Wrap a string into a paragraph.
lfs.open (filename, mode) Opens a file, creating the directories if necessary


Functions

trim (s)
Removes spaces from the begining and end of a given string

Parameters

  • s: string to be trimmed

Return value:

trimmed string
trim_comment (s)
Removes spaces from the begining and end of a given string, considering the string is inside a lua comment.

Parameters

  • s: string to be trimmed

Return value:

trimmed string See also: trim
line_empty (line)
Checks if a given line is empty

Parameters

  • line: string with a line

Return value:

true if line is empty, false otherwise
concat (str1, str2)
Appends two string, but if the first one is nil, use to second one

Parameters

  • str1: first string, can be nil
  • str2: second string

Return value:

str1 .. " " .. str2, or str2 if str1 is nil
split (delim, text)
Split text into a list consisting of the strings in text, separated by strings matching delim (which may be a pattern).

Parameters

  • delim: if delim is "" then action is the same as %s+ except that field 1 may be preceeded by leading whitespace
  • text:

Return value:

array with strings See also: table.concat
comment (text)
Comments a paragraph.

Parameters

  • text: text to comment with "--", may contain several lines

Return value:

commented text
wrap (s, w, i1, i2)
Wrap a string into a paragraph.

Parameters

  • s: string to wrap
  • w: width to wrap to [80]
  • i1: indent of first line [0]
  • i2: indent of subsequent lines [0]

Return value:

wrapped paragraph
lfs.open (filename, mode)
Opens a file, creating the directories if necessary

Parameters

  • filename: full path of the file to open (or create)
  • mode: mode of opening

Return value:

file handle

Valid XHTML 1.0!