diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-02-24 15:51:10 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-02-24 15:51:10 +0000 |
commit | f84684ee02a8990726fcb62a454b3788d5fe5f16 (patch) | |
tree | c1e6e31302f06932ff2596e0395406d14fbdcc32 /src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala | |
parent | f270f7ecfb30c331aa650d7b75fdbabc78be006b (diff) | |
download | scala-f84684ee02a8990726fcb62a454b3788d5fe5f16.tar.gz scala-f84684ee02a8990726fcb62a454b3788d5fe5f16.tar.bz2 scala-f84684ee02a8990726fcb62a454b3788d5fe5f16.zip |
[scaladoc] Preliminary support for links and li...
[scaladoc] Preliminary support for links and lists in wiki syntax,
as well as printing of lists. Fix to display of "inherits" classes.
Contributed by Pedro Furlanetto, no review. Member names in signature
are more contrasted and are aligned.
Diffstat (limited to 'src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala index ee2f491e9e..520bcb9a36 100644 --- a/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/compiler/scala/tools/nsc/doc/html/HtmlPage.scala @@ -132,15 +132,27 @@ abstract class HtmlPage { thisPage => case Paragraph(in) => <p>{ inlineToHtml(in) }</p> case Code(data) => <pre>{ Unparsed(data) }</pre> case UnorderedList(items) => - <ul>{items map { i => <li>{ blockToHtml(i) }</li>}}</ul> + <ul>{ listItemsToHtml(items) }</ul> case OrderedList(items) => - <ol>{items map { i => <li>{ blockToHtml(i) }</li>}}</ol> + <ol>{ listItemsToHtml(items) }</ol> case DefinitionList(items) => <dl>{items map { case (t, d) => <dt>{ inlineToHtml(t) }</dt><dd>{ blockToHtml(d) }</dd> } }</dl> case HorizontalRule() => <hr/> } + def listItemsToHtml(items: Seq[Block]) = + items.foldLeft(xml.NodeSeq.Empty){ (xmlList, item) => + item match { + case OrderedList(_) | UnorderedList(_) => // html requires sub ULs to be put into the last LI + xmlList.init ++ <li>{ xmlList.last.child ++ blockToHtml(item) }</li> + case Paragraph(inline) => + xmlList :+ <li>{ inlineToHtml(inline) }</li> // LIs are blocks, no need to use Ps + case block => + xmlList :+ <li>{ blockToHtml(block) }</li> + } + } + def inlineToHtml(inl: Inline): NodeSeq = inl match { //case URLLink(url, text) => <a href={url}>{if(text.isEmpty)url else inlineSeqsToXml(text)}</a> case Chain(items) => items flatMap (inlineToHtml(_)) @@ -149,7 +161,7 @@ abstract class HtmlPage { thisPage => case Underline(in) => <u>{ inlineToHtml(in) }</u> case Superscript(in) => <sup>{ inlineToHtml(in) }</sup> case Subscript(in) => <sub>{ inlineToHtml(in) }</sub> - case Link(raw) => Unparsed(raw)//error("link not supported") // TODO + case Link(raw,title) => <a href={ raw }>{ title.getOrElse(raw) }</a> // TODO link to target case Monospace(text) => <code>{ Unparsed(text) }</code> case Text(text) => Unparsed(text) } |