Eiffel Code Comments
Comment Mark Up
The Eiffel compiler and EiffelStudio's code browsing tools support a special, light-weight mark up in comments and strings for referencing classes and features. EiffelStudio's code browsing tools use this mark up to better facilitate code navigation and browsing. In addition, marked up comments and strings will be examined and altered when performing a class or feature rename refactoring.
Syntax
The syntax for marking up classes and features is very compact, to ensure retained legibility. You'll see no need for XML or other types of verbose mark up found in other languages, which can impede the comment's very nature as a quick reference.
To mark up a class reference, surround the class name in an open ( {
) and matching closing ( }
) brace:
To mark up a feature reference, implemented in the same class or parent, surround the name with two single back quotes ( `...`
):
The earlier convention, which you will still find in much existing code, used a single back quote for opening and a matching normal quote for closing, as in
The new convention, with back quotes both for opening and for closing, is the recommended one.
In the case where a reference to a feature is not accessible to the containing class directly, use a combination of the class reference mark up and a feature name, sans quotation marks:
The rules that apply for comments, as described above, can also be utilized in any manifest or verbatim string:
Precursor Comments
Precursor comments declarations are a new mechanism added to EiffelStudio 6.2 to replicate a parent feature declaration's comments in the redefined/effective feature. The purpose of the mechanism is to reduce comment duplication, ease comment maintenance and facilitate augmentation.
For the purpose of demonstration, take the following deferred interface:
And effective implementation of it:
Comment Augmentation
The precursor comments declaration also supports augmentation. All a comment author has to do is to write additional comments before and/or after the precursor comment declaration. As a requirement, the precursor comment declaration must appear on a separate line for no other purpose except for clarity. Failure to do so will result in the rendering of the comments as they are declared in the feature, i.e., with
Using the code browsing facilities of EiffelStudio the reader will be presented with an expanded comment, for the effective version of feature
For clarity, it is a good idea to separate the augmented comments from the precursor comment declaration. Using the same example above but removing the one line spacing above and below the precursor comment declaration would result in the following, less readable comment:
However, that said, it is pure discretion to use additional spacing or not. Some situations do not call for, other do and some might (when the original comment changes.)
Multiple Redefinitions and Selection
With Eiffel supporting multiple inheritance, a scenario will arise where two inherited redefine features are joined in a descendant.
By default, the precursor comment declaration is replaced by the first located inherited feature comment, which may cause documentation irregularities. Because precursor comments are not signification to compilation they are not checked during compilation, such as is the way with the use of
To facilitate correct documentation, the precursor comment declaration can use an optional select clause, just like using
This will have exactly the same effect as using
Again, because precursor comments do not affect compilation, they are not checked at compile time. Specifying an incorrect class will yield a warning message in EiffelStudio's code browsing tools, to the effect:
Library Documentation Generation
Precursor comments are supported in all code browsing/documentation facilities, whether it be the integrated [/doc/eiffelstudio/Contract_Editor_tool Contract Viewer
], the Feature Relation Tool or the Eiffel documentation generation facilities. Using