diff options
Diffstat (limited to 'src/scaladoc/scala/tools/nsc/doc/doclet/Generator.scala')
-rw-r--r-- | src/scaladoc/scala/tools/nsc/doc/doclet/Generator.scala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/doclet/Generator.scala b/src/scaladoc/scala/tools/nsc/doc/doclet/Generator.scala new file mode 100644 index 0000000000..42b56aa927 --- /dev/null +++ b/src/scaladoc/scala/tools/nsc/doc/doclet/Generator.scala @@ -0,0 +1,30 @@ +package scala.tools.nsc.doc +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] = + mutable.Set.empty[()=>Boolean] + + /** Outputs documentation (as a side effect). */ + def generate(): Unit = { + assert(checks forall { check => check() }) + generateImpl() + } + + /** Outputs documentation (as a side effect). This method is called only if all `checks` are true. */ + protected def generateImpl(): Unit + +} |