On 2/5/17 4:33 AM, Gavin Baumanis wrote:
> But with all the auto-magic niceness that exists in Scala - I just
> thought I would check to see if there was a "not by hand" way of
> generating them?
>
> I was thinking along the lines of a case class and how it generates
> the getters and setters automatically for us - why can't we get he API
> documentation auto-generated, too?
Scaladoc does the best it can for this, by showing the names and types
of functions.
How good documentation this is depends on how specific the types you've
chosen are. String => String is not very explanatory, but [A](A,
List[A]): List[A] is quite a bit more specific.
One way to improve the Scaladoc of your API without adding Scaladoc
comments is to improve your types' specificity. This has the nice
side-effect of also constraining your implementations more, so fewer
tests are needed, not just fewer docs. By contrast, if you just use
String everywhere, you need more hand-written explanation of what each
String means, as well as tests to make sure you aren't mixing them up.
To the degree that we added information to your API that Scaladoc could
reliably emit as part of your docs, such information would also be part
of the type. So the type—which Scaladoc already emits for you—already
contains everything that Scaladoc could figure out, that is, assuming we
don't have the mind-reading system Naftoli mentions.
--
Stephen Compall