diff options
Diffstat (limited to 'src/scaladoc')
5 files changed, 18 insertions, 40 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/Universe.scala b/src/scaladoc/scala/tools/nsc/doc/Universe.scala index 11520c810e..edf5112d7b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/Universe.scala +++ b/src/scaladoc/scala/tools/nsc/doc/Universe.scala @@ -5,6 +5,8 @@ package scala.tools.nsc.doc +import scala.tools.nsc.doc.html.page.diagram.DotRunner + /** * Class to hold common dependencies across Scaladoc classes. * @author Pedro Furlanetto @@ -13,4 +15,5 @@ package scala.tools.nsc.doc trait Universe { def settings: Settings def rootPackage: model.Package + def dotRunner: DotRunner } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala index a0dd154d2e..61ab18d42d 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala @@ -13,8 +13,6 @@ import io.{ Streamable, Directory } import scala.collection._ import page.diagram._ -import html.page.diagram.DiagramGenerator - /** A class that can generate Scaladoc sites to some fixed root folder. * @author David Bernard * @author Gilles Dubochet */ @@ -121,28 +119,27 @@ class HtmlFactory(val universe: doc.Universe, index: doc.Index) { finally out.close() } - DiagramGenerator.initialize(universe.settings) - libResources foreach (s => copyResource("lib/" + s)) new page.Index(universe, index) writeFor this new page.IndexScript(universe, index) writeFor this - - writeTemplates(_ writeFor this) - - for (letter <- index.firstLetterIndex) { - new html.page.ReferenceIndex(letter._1, index, universe) writeFor this + try { + writeTemplates(_ writeFor this) + for (letter <- index.firstLetterIndex) { + new html.page.ReferenceIndex(letter._1, index, universe) writeFor this + } + } finally { + DiagramStats.printStats(universe.settings) + universe.dotRunner.cleanup() } - - DiagramGenerator.cleanup() } def writeTemplates(writeForThis: HtmlPage => Unit) { val written = mutable.HashSet.empty[DocTemplateEntity] - val diagramGenerator: DiagramGenerator = new DotDiagramGenerator(universe.settings) def writeTemplate(tpl: DocTemplateEntity) { if (!(written contains tpl)) { + val diagramGenerator: DiagramGenerator = new DotDiagramGenerator(universe.settings, universe.dotRunner) writeForThis(new page.Template(universe, diagramGenerator, tpl)) written += tpl tpl.templates collect { case d: DocTemplateEntity => d } map writeTemplate diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala index 61c1819d11..cf65de4151 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala @@ -25,29 +25,3 @@ trait DiagramGenerator { */ def generate(d: Diagram, t: DocTemplateEntity, p: HtmlPage):NodeSeq } - -object DiagramGenerator { - - // TODO: This is tailored towards the dot generator, since it's the only generator. In the future it should be more - // general. - - private[this] var dotRunner: DotRunner = null - private[this] var settings: doc.Settings = null - - def initialize(s: doc.Settings) = - settings = s - - def getDotRunner() = { - if (dotRunner == null) - dotRunner = new DotRunner(settings) - dotRunner - } - - def cleanup() = { - DiagramStats.printStats(settings) - if (dotRunner != null) { - dotRunner.cleanup() - dotRunner = null - } - } -}
\ No newline at end of file diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 4ff436bdc6..b541cf721b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -15,7 +15,7 @@ import scala.collection.immutable._ import model._ import model.diagram._ -class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { +class DotDiagramGenerator(settings: doc.Settings, dotRunner: DotRunner) extends DiagramGenerator { // the page where the diagram will be embedded private var page: HtmlPage = null @@ -317,7 +317,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { * Calls dot with a given dot string and returns the SVG output. */ private def generateSVG(dotInput: String, template: DocTemplateEntity) = { - val dotOutput = DiagramGenerator.getDotRunner().feedToDot(dotInput, template) + val dotOutput = dotRunner.feedToDot(dotInput, template) var tSVG = -System.currentTimeMillis val result = if (dotOutput != null) { diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index 7289edc137..03d71f15a3 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -9,8 +9,11 @@ import base.comment._ import diagram._ import scala.collection._ +import scala.tools.nsc.doc.html.HtmlPage +import scala.tools.nsc.doc.html.page.diagram.{DotRunner} import scala.util.matching.Regex import scala.reflect.macros.internal.macroImpl +import scala.xml.NodeSeq import symtab.Flags import io._ @@ -47,6 +50,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { thisFactory.universe = thisUniverse val settings = thisFactory.settings val rootPackage = modelCreation.createRootPackage + lazy val dotRunner = new DotRunner(settings) } _modelFinished = true // complete the links between model entities, everthing that couldn't have been done before |