Home Online Manual
Top
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 4.1.1.0 Dec_2017 "; // $Id: eecdbafd0811d291ba6adc1fc144d110da851fcd $
category="Miscellaneous";
// summary description of the library
info="
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

PROCEDURES:
  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
{ "EXAMPLE:"; echo = 2;
  mdouble(0);
  mdouble(-1);
}
////////////////////////////////////////////////////////////////////
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
{ "EXAMPLE:"; echo = 2;
  mtriple(0);
  mtriple(-1);
}
////////////////////////////////////////////////////////////////////
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:
@example
         this  --> that
@end example
        Use @format for preformatted text typesetting in normal font:
@format
         this --> that
@end format
        Use @texinfo for text in pure texinfo:
@texinfo
@expansion{}
@tex
$i_{1,1}$
@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
{ "EXAMPLE:"; echo = 2;
  msum();
  msum(4);
  msum(1,2,3,4);
}

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

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

Procedures:

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