Eiffel Contract-Viewer PreviousNext

gedoc can be used as an Eiffel contract-viewer. The contract-view of a class is a pretty-printed view of its class text where internal implementation details are hidden. It therefore does not produce valid Eiffel code, but rather an interface representation of the class, also known as short form. Only exported features, their pre- and postconditions, class invariants, and exported creation procedures are retained. Assertions containing calls to non-exported features are also omitted.

Contract-view of a single class

Here is how to generate the contract-view of a single class FOO:

	gedoc --format=contract_view --force --class=FOO project.ecf
where project.ecf is an ECF file describing an Eiffel project containing class FOO. The contract-view will be generated in file foo.ecv.

The command-line option --force tells gedoc to overwrite the file foo.ecv if it already exists. Without this option, files will not be overwritten and gedoc will emit an error message. Alternatively, the command-line option --interactive can be used to ask the user confirmation before overwriting files. If you want to generate the contract-view file in a directory different from the one containing the class text file, use the command-line option --output.

Contract-view of an Eiffel project

Here is how to generate the contract-view of all Eiffel classes in an Eiffel project:

	gedoc --format=contract_view --force project.ecf
where project.ecf is an ECF file describing the Eiffel project. You can also generate the contract-view of a subset of classes in this Eiffel project, using the command-line option --class with wildcards. For example, to generate the contract-view only for the classes in a given Eiffel library whose names start with DS_, type:
	gedoc --format=contract_view --force --class=DS_* project.ecf
To generate the contract-view of all classes in a given library, use the command-line option --library, possibly with wildcards:
	gedoc --format=contract_view --force --library=structure project.ecf

As described in the previous section, the command-line option --output can be used to generate the contract-view files in a directory different from the ones contaning the class text files. The command-line option --library-prefix can also be used to generate the contract-view files in a subdirectory of this output directory, named after the Eiffel library containing the corresponding classes (one subdirectory per library).

Flat-contract-view of a class or of an Eiffel project

The contract-view shows only features and invariants declared in the class itself, whereas the flat-contract-view also includes inherited features and invariants. To generate the flat-contract-view, also known as flat short form, of a class or of an Eiffel project, replace the command-line option --format=contract_view with --format=flat_contract_view in the examples of the previous sections.


Copyright (c) 2026, Eric Bezault
mailto:ericb@gobosoft.com
https://www.gobosoft.com
Last Updated: 31 August 2026
HomeTocPreviousNext