Comments and doc comments

Using comments and doc comments in Slice files.

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 comment
interface FooBar { // This is another comment
}

Slice also supports block comments (/* ... */), like C, including nested block comments.

The Slice compiler completely ignores comments that are not 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.

Slice doc comments support the following tags:

TagApplies toDescription
{@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.
slice
module Example
/// Represents a factory for widgets.
/// @see Widget
interface WidgetFactory {
/// Creates a new {@link Widget}.
/// @param name: The name of the new widget.
/// @param color: The color of the new widget.
/// @returns: A proxy to the new widget.
createWidget(name: string) -> Widget
/// Retrieves the last {@link Widget} created by this factory.
/// @returns proxy: A proxy to the last widget.
/// @returns timeStamp: The creation time stamp.
getLastWidget() -> (proxy: Widget, timeStamp: WellKnownTypes::TimeStamp)
}

Was this page helpful?

CookiesYour privacy
This website uses cookies to analyze traffic and improve your experience.
By clicking "Accept," you consent to the use of these cookies. You can learn more about our cookies policy in our Privacy Policy.