| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (Generator.scala)

This example Scala source code file (Generator.scala) is included in my "Source Code Warehouse" project. The intent of this project is to help you more easily find Scala source code examples by using tags.

All credit for the original source code belongs to; I'm just trying to make examples easier to find. (For my Scala work, see my Scala examples and tutorials.)

Scala tags/keywords

collection, compiler, generator, nsc, unit

The Generator.scala Scala example source code

package doclet

import scala.collection._

/** Custom Scaladoc generators must implement the `Generator` class. A custom generator can be selected in Scaladoc
  * using the `-doc-generator` command line option.
  * The `Generator` class does not provide data about the documented code. A number of data provider traits can be used
  * to configure what data is actually available to the generator:
  *  - A `Universer` provides a `Universe` data structure representing the interfaces and comments of the documented
  *    program.
  *  - An `Indexer` provides precalculated indexing information about a universe.
  * To implement this class only requires defining method `generateImpl`. */
abstract class Generator {

  /** A series of tests that must be true before generation can be done. This is used by data provider traits to
    * confirm that they have been correctly initialised before allowing generation to proceed. */
  protected val checks: mutable.Set[()=>Boolean] =

  /** Outputs documentation (as a side effect). */
  def generate(): Unit = {
    assert(checks forall { check => check() })

  /** Outputs documentation (as a side effect). This method is called only if all `checks` are true. */
  protected def generateImpl(): Unit


Other Scala source code examples

Here is a short list of links related to this Scala Generator.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.