© Toby Weston 2018

Toby Weston, Scala for Java Developers, https://doi.org/10.1007/978-1-4842-3108-1_5

5. ScalaDoc

Toby Weston

(1)London, UK

Scala has ported the idea of JavaDoc and creatively called it ScalaDoc . Adding ScalaDoc to your Scala source works similarly to adding JavaDoc, and is done with markup in comments (see Figure 5-1). For example, the following fragment in source code

  /** Returns `true` if this value is equal to x, `false` otherwise. **/
  def ==(x: Byte): Boolean

…can be turned into the following fragment in HTML :

A456960_1_En_5_Fig1_HTML.jpg
Figure 5-1 Embedded ScalaDoc markup gets rendered in HTML

To see the documentation for the Scala Library API, head over to the Scala website.1 You’ll notice it is broadly similar to JavaDoc. You can see the classes along the left; they’re not grouped by package like in JavaDoc but they’re clickable to get more information.

A456960_1_En_5_Fig2_HTML.jpg
Figure 5-2 The basic ScalaDoc for Char

A neat feature of ScalaDoc is that you can also filter the content. For example, you can show only methods inherited from Any.

If you’re interested in the hierarchy of a class, you can look at its super-types and subtypes. You may even see a navigable diagram of the type hierarchy, although not every class has this. The type hierarchy diagram for Source in Figure 5-3 shows it is a subtype of Iterable and Closable, and you can navigate up through the hierarchy by clicking on the diagram.

A456960_1_En_5_Fig3_HTML.jpg
Figure 5-3 ScalaDoc showing the type hierarchy diagram
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.4.174