3 min read
Comments and doc comments
Using comments and doc comments in Slice files.
Comments
You can and should add comments to your Slice files to make your Slice definitions easier to understand.
A Slice comment starts with two slashes (//) and continues until the end of the line, just like in C# and Rust:
slice
// This is a commentinterface FooBar { // This is another comment}Slice also supports block comments (/* ... */), like C. Block comments cannot be nested.
The Slice compiler completely ignores comments that are not doc comments.
Doc comments
Slice comments that start with a triple slash (///) are doc comments. The Slice code generators use these special comments as input for the doc comments they generate in the mapped languages.
Slice doc comments can be attached to all Slice elements except parameters and modules.
Doc comment tags
Slice doc comments support the following tags:
| Tag | Applies to | Description |
|---|---|---|
{@link identifier} | All | Provide a link to the Slice type, operation or field identifier. |
@param name: ... | Operations | Describe the operation parameter name. |
@returns name: ... | Operations | Describe the return parameter name. |
@see identifier | All | Suggest to see Slice type, operation or field identifier. |
Example
slice
module Example
/// Represents a factory for widgets./// @see Widgetinterface WidgetFactory { /// Creates a new {@link Widget}. /// @param name: The name of the new widget. /// @returns: The new widget. createWidget(name: string) -> Widget
/// Retrieves the last {@link Widget} created by this factory. /// @returns widget: A copy of the last widget. /// @returns timeStamp: The creation time stamp. getLastWidget() -> (widget: Proxy, timeStamp: WellKnownTypes::TimeStamp)}