Getting Help (GNU Octave (version 6.2.0))

Next: Command Line Editing, Previous: Quitting Octave, Up: Getting Started [Contents][Index]

### 2.3 Commands for Getting Help

The entire text of this manual is available from the Octave prompt via the command `doc`. In addition, the documentation for individual user-written functions and variables is also available via the `help` command. This section describes the commands used for reading the manual and the documentation strings for user-supplied functions and variables. See Function Files, for more information about how to document the functions you write.

: help name
: help --list
: help .
: help

  Display the help text for name.

  For example, the command `help help` prints a short message describing the `help` command.

  Given the single argument `--list`, list all operators, keywords, built-in functions, and loadable functions available in the current session of Octave.

  Given the single argument `.`, list all operators available in the current session of Octave.

  If invoked without any arguments, `help` displays instructions on how to access help from the command line.

  The help command can provide information about most operators, but name must be enclosed by single or double quotes to prevent the Octave interpreter from acting on name. For example, `help "+"` displays help on the addition operator.

  See also: doc, lookfor, which, info.

: doc function_name
: doc

  Display documentation for the function function_name directly from an online version of the printed manual, using the GNU Info browser.

  If invoked without an argument, the manual is shown from the beginning.

  For example, the command `doc rand` starts the GNU Info browser at the `rand` node in the online version of the manual.

  Once the GNU Info browser is running, help for using it is available using the command `C-h`.

  See also: help.

: lookfor str
: lookfor -all str
: [fcn, help1str] = lookfor (str)
: [fcn, help1str] = lookfor ("-all", str)

  Search for the string str in the documentation of all functions in the current function search path.

  By default, `lookfor` looks for str in just the first sentence of the help string for each function found. The entire help text of each function can be searched by using the `"-all"` argument. All searches are case insensitive.

  When called with no output arguments, `lookfor` prints the list of matching functions to the terminal. Otherwise, the output argument fcns contains the function names and help1str contains the first sentence from the help string of each function.

  Programming Note: The ability of `lookfor` to correctly identify the first sentence of the help text is dependent on the format of the function’s help. All Octave core functions are correctly formatted, but the same can not be guaranteed for external packages and user-supplied functions. Therefore, the use of the `"-all"` argument may be necessary to find related functions that are not a part of Octave.

  The speed of lookup is greatly enhanced by having a cached documentation file. See `doc_cache_create` for more information.

  See also: help, doc, which, path, doc_cache_create.

To see what is new in the current release of Octave, use the `news` function.

: news
: news package

  Display the current NEWS file for Octave or an installed package.

  When called without an argument, display the NEWS file for Octave.

  When given a package name package, display the current NEWS file for that package.

  See also: ver, pkg.

: info ()

  Display contact information for the GNU Octave community.

: warranty ()

  Describe the conditions for copying and distributing Octave.

The following functions can be used to change which programs are used for displaying the documentation, and where the documentation can be found.

: val = info_file ()
: old_val = info_file (new_val)
: info_file (new_val, "local")

  Query or set the internal variable that specifies the name of the Octave info file.

  The default value is `octave-home/share/info/octave.info`, in which octave-home is the root directory of the Octave installation. The default value may be overridden by the environment variable `OCTAVE_INFO_FILE`, or the command line argument `--info-file FNAME`.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

  See also: info_program, doc, help, makeinfo_program.

: val = info_program ()
: old_val = info_program (new_val)
: info_program (new_val, "local")

  Query or set the internal variable that specifies the name of the info program to run.

  The default value is "`info`". The default value may be overridden by the environment variable `OCTAVE_INFO_PROGRAM`, or the command line argument `--info-program NAME`.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

  See also: info_file, doc, help, makeinfo_program.

: val = makeinfo_program ()
: old_val = makeinfo_program (new_val)
: makeinfo_program (new_val, "local")

  Query or set the internal variable that specifies the name of the program that Octave runs to format help text containing Texinfo markup commands.

  The default value is `makeinfo`.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

  See also: texi_macros_file, info_file, info_program, doc, help.

: val = texi_macros_file ()
: old_val = texi_macros_file (new_val)
: texi_macros_file (new_val, "local")

  Query or set the internal variable that specifies the name of the file containing Texinfo macros that are prepended to documentation strings before they are passed to makeinfo.

  The default value is `octave-home/share/octave/version/etc/macros.texi`, in which octave-home is the root directory of the Octave installation, and version is the Octave version number. The default value may be overridden by the environment variable `OCTAVE_TEXI_MACROS_FILE`, or the command line argument `--texi-macros-file FNAME`.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

  See also: makeinfo_program.

: val = doc_cache_file ()
: old_val = doc_cache_file (new_val)
: doc_cache_file (new_val, "local")

  Query or set the internal variable that specifies the name of the Octave documentation cache file.

  A cache file significantly improves the performance of the `lookfor` command. The default value is `octave-home/share/octave/version/etc/doc-cache`, in which octave-home is the root directory of the Octave installation, and version is the Octave version number. The default value may be overridden by the environment variable `OCTAVE_DOC_CACHE_FILE`, or the command line argument `--doc-cache-file FNAME`.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

  See also: doc_cache_create, lookfor, info_program, doc, help, makeinfo_program.

  See also: lookfor.

: val = built_in_docstrings_file ()
: old_val = built_in_docstrings_file (new_val)
: built_in_docstrings_file (new_val, "local")

  Query or set the internal variable that specifies the name of the file containing docstrings for built-in Octave functions.

  The default value is `octave-home/share/octave/version/etc/built-in-docstrings`, in which octave-home is the root directory of the Octave installation, and version is the Octave version number. The default value may be overridden by the environment variable `OCTAVE_BUILT_IN_DOCSTRINGS_FILE`, or the command line argument `--built-in-docstrings-file FNAME`.

  Note: This variable is only used when Octave is initializing itself. Modifying it during a running session of Octave will have no effect.

: val = suppress_verbose_help_message ()
: old_val = suppress_verbose_help_message (new_val)
: suppress_verbose_help_message (new_val, "local")

  Query or set the internal variable that controls whether Octave will add additional help information to the end of the output from the `help` command and usage messages for built-in commands.

  When called from inside a function with the `"local"` option, the variable is changed locally for the function and any subroutines it calls. The original variable value is restored when exiting the function.

The following functions are principally used internally by Octave for generating the documentation. They are documented here for completeness and because they may occasionally be useful for users.

: doc_cache_create (out_file, directory)
: doc_cache_create (out_file)
: doc_cache_create ()

  Generate documentation cache for all functions in directory.

  A documentation cache is generated for all functions in directory which may be a single string or a cell array of strings. The cache is used to speed up the function `lookfor`.

  The cache is saved in the file out_file which defaults to the value `doc-cache` if not given.

  If no directory is given (or it is the empty matrix), a cache for built-in functions, operators, and keywords is generated.

  See also: doc_cache_file, lookfor, path.

: [text, format] = get_help_text (name)

  Return the raw help text of function name.

  The raw help text is returned in text and the format in format. The format is a string which is one of `"texinfo"`, `"html"`, or `"plain text"`.

  See also: get_help_text_from_file.

: [text, format] = get_help_text_from_file (fname)

  Return the raw help text from the file fname.

  The raw help text is returned in text and the format in format. The format is a string which is one of `"texinfo"`, `"html"`, or `"plain text"`.

  See also: get_help_text.

: text = get_first_help_sentence (name)
: text = get_first_help_sentence (name, max_len)
: [text, status] = get_first_help_sentence (…)

  Return the first sentence of a function’s help text.

  The first sentence is defined as the text after the function declaration until either the first period (".") or the first appearance of two consecutive newlines ("\n\n"). The text is truncated to a maximum length of max_len, which defaults to 80. If the text must be truncated the last three characters of the text are replaced with `"..."` to indicate that more text was available.

  The optional output argument status returns the status reported by `makeinfo`. If only one output argument is requested, and status is nonzero, a warning is displayed.

  As an example, the first sentence of this help text is

      get_first_help_sentence ("get_first_help_sentence")
      -| ans = Return the first sentence of a function's help text.

Next: Command Line Editing, Previous: Quitting Octave, Up: Getting Started [Contents][Index]