Home Online Manual
Back: Procedures in a library
Forward: mdouble
FastBack: Procedures
FastForward: Formal Checker
Up: Libraries
Top: Singular Manual
Contents: Table of Contents
Index: Index
About: About this document

3.8.7 template_lib

First, we show the source-code of a template library:

version="version template.lib Dec_2017 "; // $Id: eecdbafd0811d291ba6adc1fc144d110da851fcd $
// summary description of the library
LIBRARY:   template.lib  A Template for a Singular Library
AUTHOR:    Olaf Bachmann, email: obachman@mathematik.uni-kl.de

SEE ALSO:  standard_lib, Libraries,
           Typesetting of help and info strings

KEYWORDS: library, template.lib; template.lib; library, info string

  mdouble(int)           return double of int argument
  mtriple(int)          return three times int argument
  msum([int,..,int])     sum of int arguments
proc mdouble(int i)
"USAGE:    mdouble(i); i int
RETURN:   int: i+i
NOTE:     Help string is in pure ASCII.
          This line starts on a new line since previous line is short.
          No new line here.
SEE ALSO: msum, mtriple, Typesetting of help and info strings
KEYWORDS: procedure, ASCII help
EXAMPLE:  example mdouble; shows an example"
  return (i + i);
{ "EXAMPLE:"; echo = 2;
proc mtriple(int i)
"@c we do texinfo here
@table @asis
@item @strong{Usage:}
@code{mtriple(i)}; @code{i} int

@item @strong{Return:}
int: @math{i+i+i}
@item @strong{Note:}
Help is in pure Texinfo.
@*This help string is written in texinfo, which enables you to use,
among others, the @@math command for mathematical typesetting
(for instance, to print @math{\alpha, \beta}).
@*Texinfo also gives more control over the layout, but is, admittingly,
more cumbersome to write.
@end table
@c use @c ref contstuct for references
@cindex procedure, texinfo help
@c ref
@strong{See also:}
@ref{mdouble}, @ref{msum}, @ref{Typesetting of help and info strings}
@c ref
  return (i + i + i);
{ "EXAMPLE:"; echo = 2;
proc msum(list #)
"USAGE:  msum([i_1,..,i_n]); @code{i_1,..,i_n} def
RETURN:  Sum of int arguments
NOTE:    This help string is written in a mixture of ASCII and texinfo.
         @* Use @ref for references (e.g.,  @pxref{mtriple}).
         @* Use @code for typewriter font (e.g., @code{i_1}).
         @* Use @math for simple math mode typesetting (e.g., @math{i_1}).
         @* Warning: Parenthesis like } are not allowed inside @math and @code.
         @* Use @example for indented, preformatted text typesetting in
         typewriter font:
         this  --> that
@end example
        Use @format for preformatted text typesetting in normal font:
         this --> that
@end format
        Use @texinfo for text in pure texinfo:
@end tex

@end texinfo
        Note that
        automatic linebreaking         is still in affect (like in this line).
SEE ALSO: mdouble, mtriple, Typesetting of help and info strings
KEYWORDS: procedure, ASCII/Texinfo help
EXAMPLE: example msum; shows an example"
  if (size(#) == 0) { return (0);}
  if (size(#) == 1) { return (#[1]);}
  int i;
  def s = #[1];
  for (i=2; i<=size(#); i++)
    s = s + #[i];
  return (s);
{ "EXAMPLE:"; echo = 2;

Second, we show how the library appears in the documentation after typesetting (with one subsection for each procedure):

A Template for a Singular Library
Olaf Bachmann, email: obachman@mathematik.uni-kl.de

Procedures: mdouble  return double of int argument mtriple  return three times int argument msum  sum of int arguments
See also: Libraries; Typesetting of help and info strings; standard_lib.