Need some good examples on how to write a Doclet (scaladoc)

227 views
Skip to first unread message

Reik Schatz

unread,
Sep 18, 2014, 5:55:55 AM9/18/14
to scala...@googlegroups.com
I want to write a Doclet that generates custom html/json for classes in a specific package only. Haven't found many examples or tutorials. Is there a way to unit test the Doclet, i.e. how do I create a doc.Universe for the sources I want to test?

Thx

Vlad Ureche

unread,
Sep 18, 2014, 12:02:28 PM9/18/14
to Reik Schatz, scala-user
2014-09-18 11:55 GMT+02:00 Reik Schatz <reik....@gmail.com>:

I want to write a Doclet that generates custom html/json for classes in a specific package only.

Cool! Looking forward to seeing it!
 
Haven't found many examples or tutorials.

If the only thing you want to do is skip some packages, maybe you can use the -skip-packages flag:

$ scaladoc -help
Usage: scaladoc <options> <source files>
where possible scaladoc options include:
  ...
  -skip-packages <<package1>:...:<packageN>>  A colon-delimited list of fully qualified package names that will be skipped from scaladoc.

Alternatively, if you want to do this in the doclet, you can override the standard Doclet, HTMLFactory and the Template generator.
For more general tweaks to the page format, have a look at extradoc, which is a good place to start: https://github.com/szeiger/extradoc
 
Is there a way to unit test the Doclet, i.e. how do I create a doc.Universe for the sources I want to test?

Well, that's a pretty difficult problem. You can:
(1) test the entire stack (model generator + generated html/json) -- see HtmlFactoryTest or
(2) generate your own model conforming to the interfaces defined here and you can use the model factory for inspiration)

HTH,
Vlad
Reply all
Reply to author
Forward
0 new messages