[Comments] [§]

[Comments] [§]

There are three types of comments. Normal comments are ignored, while [Doc Comments] and [Top-Level Doc Comments] are used by the compiler to generate the package documentation.

  comments.zig

Shell


There are no multiline comments. Zig has the property that each line of code can be tokenized independently.

[Doc Comments] [§]

  A doc comment is one that begins with exactly three slashes (i.e.
  /// but not ////);
  multiple doc comments in a row are merged together to form a multiline
  doc comment.  The doc comment documents whatever immediately follows it.
  

  doc_comments.zig

  Doc comments are only allowed in certain places; it is a compile error to
  have a doc comment in an unexpected place, such as in the middle of an expression,
  or just before a non-doc comment.
  

  invalid_doc-comment.zig

Shell


  unattached_doc-comment.zig

Shell


  Doc comments can be interleaved with normal comments, which are ignored.

[Top-Level Doc Comments] [§]

  A top-level doc comment is one that begins with two slashes and an exclamation
  point: //!; it documents the type which owns the containing
  [Namespace].
  

  

  It is a compile error if a top-level doc comment is not placed at the start
  of a namespace, before any expressions.
  

  tldoc_comments.zig