Class Help

A user friendlier API to the module lua-help

User gives 0..2 arguments to class Help's constructor, which are interpreted as exact strings or regular expressions depending on which will give the most specific output.

Different methods are tried where arguments are interpreted either literary or as a regular expression, one or two (or none) is passed to Help's constructor until the best possible match is output.

I.e. output is either a text for a specific subject or a list of topics if no exact mach is found.

Prerequisites:

Install the lua-help back-end

$ luarocks install lua-help

Installs the lua-help module for your Lua VM's version {5.1 ... 5.4} For each build-step dependency failure, follow instructions (circa 4 iterations)

Usage:

  •  Help()
    -- Returns/prints intro
    
  •  Help("dofile")
    -- Successful exact match in any topic - returning content
       dofile ([filename])
    
       Opens the named file and executes its contents as a Lua chunk. When
       called without arguments, dofile executes the contents of the standard
       input (stdin). Returns all values returned by the chunk. In case of
       errors, dofile propagates the error to its caller (that is, dofile does
       not run in protected mode)
    
  •  Help("file")
    -- Unsuccessful exact match in any topic - returning suggestions instead
    1       caux    luaL_dofile
    2       caux    luaL_fileresult
    3       caux    luaL_loadfile
    4       caux    luaL_loadfilex
    5       funcs   dofile
    6       funcs   file:close
    7       funcs   file:flush
    8       funcs   file:lines
    9       funcs   file:read
    10      funcs   file:seek
    11      funcs   file:setvbuf
    12      funcs   file:write
    13      funcs   loadfile
    
  •  Help("math","vars")
    -- Regexp-match among topics - unsuccessful match returning suggestions instead
    1       vars    math.huge
    2       vars    math.maxinteger
    3       vars    math.mininteger
    4       vars    math.pi
    
  •  Help("ma.*","v..s")
    -- Ditto above - explicit regexps
    
  •  Help("ma","va")
    -- Ditto above - implicit regexps
    
  •  Help("math.pi","vars")
    -- Explicit successful complete match - returning content
      math.pi
    
       The value of π.
    

Tables

help.Help Meta-table with constructor (class)

The class Help is used as disposable constructor with the purpose of returning/output relevant text content.

Methods

help:quasi (sub, cat) High-level function

Try different methods until something is output.

help:intro () Introductory help-text
help:topics (resub, recat) Search for regular expression matches of subjects and/or categories.
help:info (sub, cat) Print help for subject
help:url () Get URL for onlune Reference manual

The same source the module lua-help used when it composed the in-VM this searchable/printable topics text i.e.



Tables

help.Help
Meta-table with constructor (class)

The class Help is used as disposable constructor with the purpose of returning/output relevant text content. It's taking 0..2 arguments and depending on which invokes Help:quasi(sub, cat) or Help:intro ()

Fields:

  • __call is used as syntactic sugar for constructor

See also:

Methods

help:quasi (sub, cat)
High-level function

Try different methods until something is output. Most specific first.

Parameters:

  • sub string Subject literal or regexp [opt]
  • cat string Category literal or regexp [opt]

Returns:

    enum Fail or type of output ([0=fail], [1=doc], [2=topics])
help:intro ()
Introductory help-text Function takes no arguments just unconditionally prints it's text.

Returns:

    string URL to the Reference manual on line
help:topics (resub, recat)
Search for regular expression matches of subjects and/or categories.

Prints a list of none or topics depending of whats found

Parameters:

  • resub string Subject regexp [opt]
  • recat string Category regexp [opt]

Returns:

    integer Number of topics printed
help:info (sub, cat)
Print help for subject

Parameters:

Returns:

    integer number of characters output
help:url ()
Get URL for onlune Reference manual

The same source the module lua-help used when it composed the in-VM this searchable/printable topics text i.e. Use when/if something is missing.

Returns:

    string URL to the relevant versions Reference manual on line
generated by LDoc 1.5.0 Last updated 2024-08-18 19:08:20