(!*******************************************************
* Mosel Example Programs
* ======================
*
* file mddoc.mos
* ``````````````
* Example for the use of the Mosel language
* (Use of annotations for documentation)
*
* (c) 2015 Fair Isaac Corporation
* author: Y. Colombani, rev. Nov. 2018
*******************************************************!)
model mddoc
version 0.0.3
!The following optional header is required only when building the PDF
(!@doc.
@xmlheader
@xmlroot manual
!)
(!@doc.
@title An example of model documentation
@date November 2018
@chapter Annotations for documentation
@section Running moseldoc
@p [XML]
The moseldoc program takes as input a bim file produced from
a Mosel model compiled with the -D compiler option.
Generation of the documentation for this model is therefore obtained by
executing the following commands:
@p [SRC]
>mosel comp -D mddoc
>moseldoc mddoc
@p
The result of this process is an XML file ("mddoc_doc.xml")
and a directory containing an HTML version of the documentation
("mddoc_html"). The program will produce only the XML file
(from a bim file) if option -xml is used and only the HTML data
(from an XML file) if -html
is selected. The option -f will be required to force the
replacement of existing files.
@p
As a Mosel program available in source form, moseldoc
can be adapted to fit specific user requirements. To re-generate the
moseldoc executable use this compilation command (requires a C compiler):
@p [SRC]
>mosel comp -s moseldoc.mos -o deploy.exe:moseldoc,css-z=moseldoc.css
@p
Note for Xpress Workbench users:
To enable the -D compiler option in Workbench open the Run
menu and select the entry Compiler Options, enable the
Generate Doc Annotations option, then confirm with Save.
Click on the Compile button in the Workbench toolbar to generate
a BIM file that contains the documentation annotations.
@section Automatic addition of annotations
@p
The documentation generation relies on annotations that are recorded
into the bim
file. Some of these annotations are automatically produced by the Mosel
compiler when it is run with the option -D (it is also possible
to overwrite annotations set by the compiler).
These are the automatically generated annotations:
- @doc.name
- model/package name
- @doc.version
- model/package version
- @doc.date
- generation date
- @doc.syntax
- subroutine prototype
- @doc.type
- entity type
- @doc.recfldtype
- record field type
- @doc.default
- parameter default value
- @doc.const
- constant value
@p
The special annotation @doc.autogen can be used to disable
locally this automatic generation procedure (when it is set to 'false', the
generation is disabled).
@p
Thanks to the automatic generation feature it is possible to produce a documentation for model source files that do not contain any annotations.
@section Document structure
@p
The document is organised in chapters (@doc.chapter title),
sections (@doc.section title) and subsections (@doc.subsection title).
In each of these components, paragraphs are added using the marker @doc.p.
By default, the paragraph content is expected to be valid XML but plain
text can also be used by starting the paragraph with the [TXT] marker
(in this case special characters like '<' are not interpreted) and to insert
code examples you need to start with the marker [SRC] (special
characters are not interpreted and spacing is preserved).
@p
Documentation contents (entities, function definitions and paragraphs) are
automatically associated with the current subsection, section or chapter
(depending on the last definition). It is also possible to specify
a different location using the @doc.relocate annotation that
must designate a target location in the document that has been defined
with @doc.location.
!)
(!@doc.
@chapter The example
@p
This entire document is generated from the source file
mddoc.mos. Please look at the model source to see which annotations
were defined to produce the output under this chapter.
!)
!@doc.section Parameters
parameters
!@doc.descr short parameter description
!@doc.value v1 possible value
!@doc.value v2 another possible value
!@doc.info some more explanation (longer text)
P1="some text"
end-parameters
!@doc.section Constants and variables
!@doc.location vardefs
public declarations
(!@doc.
@descr short description of the constant set
@info additional information
!)
S=1..10
!@doc.descr an error code constant
MYERR=11
(!@doc.
@descr a record type
@recflddescr fld1 field description
@recflddescr fld2 another field description
@recfldval fld2 val1 meaning of a specific value
@recfldval fld2 v2 another value for this field with a subroutine reference aproc
@info further information
!)
rectype=public record
fld1:integer
fld2:string
end-record
(!@doc.
@descr a record variable
@recflddescr fldA field description
@recflddescr fldB another field description
@setby aproc
@info @doc.value may also be used with a variable
@info several @doc.info tags can be used for a given entity
@info entities can be referenced: rectype !) recvar:public record fldA:integer fldB:string end-record end-declarations (!@doc. @section Subroutines @p [TXT] The list of subroutines below is automatically generated from the declarations appearing within the scope of this section !) (!@doc. @descr some short description @param i first parameter @param r second parameter @param flags some flags. Possible values: @paramval flags 1 first option @paramval flags 2 second option @err 33 error condition that can be set @err MYERR reference to an error code constant @return the truth @example Some descriptive text for the example @example [SRC] the example code is here @info useful information for myfunct
!)
public function myfunct(i:integer,r:real,flags:integer):boolean
returned:=i>r
end-function
!@doc.group myfunct
!@doc.info myotherfunc is an alternative to myfunct
!@doc.info Up to 3 different subroutine names can be grouped
public function myotherfunc(i:integer):boolean
returned:=true
end-function
!The following procedure will not be included into the doc
!@doc.autogen=false
public procedure hiddenproc
a:=1
end-procedure
! re-enable automatic generation
!@doc.autogen
(!@doc.
@descr Yet another routine
@param s the only parameter
@info should modify recvar
@related recvar
!)
public procedure aproc(s:string)
writeln(s)
end-procedure
!@doc.relocate vardefs
public declarations
advar:string !@doc.descr an additional variable
end-declarations
end-model