Skip to content

Commit

Permalink
Updated code to support Scala 2.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
petrhosek authored and ignatov committed Aug 15, 2011
1 parent 429bcb4 commit 790940c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package api {
import model.Model
import model.Model.factory._
import model.mapper.Comment
import lib.DependencyFactory.model
import lib.util.NameUtils._
import lib.util.PathUtils._
import lib.DependencyFactory.model
Expand Down
31 changes: 26 additions & 5 deletions src/main/scala/scala/tools/colladoc/lib/DependencyFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
package scala.tools.colladoc {
package lib {

import net.liftweb._
import http._
import net.liftweb.http._
import model.mapper.{CommentToString, Comment}
import model.{SearchIndex, Model}
import net.liftweb.util.Props

import tools.nsc.doc.Universe
import tools.nsc.doc.doclet.{Indexer, Universer, Generator}
import tools.nsc.doc.html.Doclet
import tools.nsc.doc.model.IndexModelFactory

/**
* Factory providing various dependencies.
* @author Petr Hosek
*/
object DependencyFactory extends Factory {
implicit object doclet extends FactoryMaker(getDoclet _)
implicit object model extends FactoryMaker(getModel _)
implicit object index extends FactoryMaker(getIndex _)
implicit object path extends FactoryMaker(getPath _)
Expand All @@ -48,17 +53,33 @@ object DependencyFactory extends Factory {
private def getProps =
Props.props

private lazy val getDoclet = {
val doclet = new Doclet

doclet match {
case universer: Universer =>
universer setUniverse getModel
doclet match {
case indexer: Indexer => indexer setIndex IndexModelFactory.makeIndex(getModel)
case _ => ()
}
case _ => ()
}

doclet
}

// Note: Lazy eval is necessary here to give us an opportunity to do DI of
// dependencies required by the model and the index.
private lazy val getModel = {
private lazy val getModel: Universe = {
// Make sure that we index the model when it is created.
getIndex

Model.model
Model.model.get // TODO: use safe solution
}

private lazy val getIndex =
new SearchIndex(Model.model.rootPackage, getComment)
new SearchIndex(Model.model.get.rootPackage, getComment) // TODO: use safe solution
}
}

Expand Down
9 changes: 2 additions & 7 deletions src/main/scala/scala/tools/colladoc/model/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import net.liftweb.common.Logger
import net.liftweb.http.S

import tools.nsc.Global
import tools.nsc.doc.{SourcelessComments, Settings}
import tools.nsc.doc.Settings
import tools.nsc.io.Directory

import java.io.File
Expand Down Expand Up @@ -82,18 +82,13 @@ object Model extends Logger {
phasesSet += pickler
phasesSet += refchecks
}
override def onlyPresentation = true
lazy val addSourceless = {
val sourceless = new SourcelessComments { val global = compiler }
docComments ++= sourceless.comments
}
override def forScaladoc = true
}

/** Model factory used to construct the model. */
class Factory extends ModelFactory(compiler, settings) with DynamicModelFactory with DynamicCommentFactory with TreeFactory {
def construct(files: List[String]) = {
(new compiler.Run()) compile files
compiler.addSourceless

makeModel
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ trait DynamicModelFactory extends ModelFactory { thisFactory: ModelFactory with
def isAbstractType = mbr.isAbstractType
def isTemplate = mbr.isTemplate
def universe = mbr.universe
def annotations = mbr.annotations
override def equals(other: Any) = other match {
case that: MemberEntityProxy => mbr.equals(that.mbr)
case _ => mbr.equals(other)
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/scala/tools/colladoc/page/History.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
package scala.tools.colladoc {
package page {

import lib.util.Helpers._
import lib.util.NameUtils._
import model.Model
import model.Model.factory._
import model.mapper.Comment
import lib.DependencyFactory.model
import lib.util.Helpers._
import lib.util.NameUtils._

import net.liftweb.util.Helpers._

Expand Down Expand Up @@ -211,4 +211,4 @@ class History(rootPack: Package) extends Template(rootPack) {
}

}
}
}
8 changes: 5 additions & 3 deletions src/main/scala/scala/tools/colladoc/page/Index.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,25 @@ import net.liftweb.http.js.jquery.JqJE._
import net.liftweb.http.js.JE._
import net.liftweb.widgets.gravatar.Gravatar

import tools.nsc.doc.Universe
import tools.nsc.doc.{Universe, Index => DocIndex}
import tools.nsc.doc.html.page.{Index => PageIndex}
import xml.Text
import lib.js.JqUI._

/**
* Page containing index of all symbols and user panel.
* @author Petr Hosek
*/
class Index(universe: Universe) extends tools.nsc.doc.html.page.Index(universe) {
class Index(universe: Universe, index: DocIndex) extends PageIndex(universe, index) {

override def browser = super.browser \+
override def scriptElement = super.scriptElement \+
<div id="user">
{ if (User.loggedIn_?)
loggedIn
else
loggedOut
}
{ super.scriptElement }
</div>

override def title = {
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/scala/tools/colladoc/page/Search.scala
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ class Search(rootPack: Package) extends scala.tools.colladoc.page.Template(rootP
def constructorParam0(vl: ValueParam): NodeSeq =
// notice the }{ in the next lines, they are necessary to avoid a undesired withspace in output
<span name={ vl.name }>{ Text(vl.name + ": ") }{ typeToHtml(vl.resultType, hasLinks) }{
if(!vl.defaultValue.isEmpty) {
defaultValueToHtml(vl.defaultValue.get);
}
else NodeSeq.Empty
if(!vl.defaultValue.isEmpty)
treeToHtml(vl.defaultValue.get)
else
NodeSeq.Empty
}</span>
def constructorParams0(vlss: List[ValueParam]): NodeSeq = vlss match {
case Nil => NodeSeq.Empty
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/scala/tools/colladoc/snippet/IndexOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ import xml._

import tools.nsc.doc.model._
import tools.nsc.doc.Universe
import tools.nsc.doc.doclet.{Indexer, Universer}

/**
* Index snippet.
* @author Petr Hosek
*/
class IndexOps(universe: Universe) {
def this() = this(model.vend)
class IndexOps(universer: Universer, indexer: Indexer) {
def this() = this(doclet.vend, doclet.vend)

lazy val index = new Index(universe)
lazy val index = new Index(universer.universe, indexer.index)

/** Return index title. */
def title(xhtml: NodeSeq): NodeSeq =
Expand Down

0 comments on commit 790940c

Please sign in to comment.