Search code examples
javascriptgoogle-closure-compilergoogle-closure-library

What does @code mean in Google Closure?


An example is here:

* An implementation of {@code goog.events.Listenable} with full W3C
* EventTarget-like support (capture/bubble mechanism,

https://developer.pubref.org/static/apidoc/global/closure/goog/events/EventTarget.html

I can guess what it means but where can I find its exact definition? I checked all the Google Closure Annotation docs but couldn't find. Thanks :)


Solution

  • Updated

    Per my new understanding; Since JSDocs supports markdown. {@code FooBar} is therefore deprecated in favor of back-ticks `FooBar`.

    Old

    You can see the output of the docs you've asked about on the Closure API's documentation page for goog.events.EventTarget.

    When the JSDocs are rendered the @code tag will cause the code with in brackets to be rendered with as a <code></code> element.

    Source: js-dossier

    There's also the much better documentation from the JavaDocs... docs:

    {@code text}

    • Equivalent to {@literal}.

    • Displays text in code font without interpreting the text as HTML markup or nested javadoc tags. This enables you to use regular angle brackets (< and >) instead of the HTML entities (< and >) in doc comments, such as in parameter types (), inequalities (3 < 4), or arrows (<-). For example, the doc comment text:

      {@code A<B>C}
      

      displays in the generated HTML page unchanged, as:

      A<B>C
      

      The noteworthy point is that the is not interpreted as bold and is in code font. If you want the same functionality without the code font, use {@literal}.

    Source: docs.oracle.com