diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-01-08 23:20:04 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-02-17 08:25:29 +0100 |
commit | 7b07a78cc0831a08f2d39a259dec2454c7d4cc1e (patch) | |
tree | b90dd022688b5fec4a0a39fce2e4db9fb1aed5a7 /test/scaladoc/scalacheck/HtmlFactoryTest.scala | |
parent | c524f18ee4959f6fe8297971fc882e63468c4317 (diff) | |
download | scala-7b07a78cc0831a08f2d39a259dec2454c7d4cc1e.tar.gz scala-7b07a78cc0831a08f2d39a259dec2454c7d4cc1e.tar.bz2 scala-7b07a78cc0831a08f2d39a259dec2454c7d4cc1e.zip |
Scaladoc: Add new search, featuring entity and member search
This commit adds a revamped search function for the scaladoc tool. It
also contains a number of small fixes for HTML-layout and JavaScript
issues.
The search is implemented by enhancing the scheduler and using
JavaScript promises. List of changes/additions:
* Revamped search functionality
- Search members as well as entities
- Preserve keyboard navigation
- Scroll to selected entity if outside of viewport
- Non-blocking, cancelable
* Display of library name (top left)
* Refactored scheduler
* Cleanup of HTML layout
- Remove left pane
- Better mobile layout, no need for dynamic offsets
- Remove unused element classes
- Remove iframe structure
- Better layout for kinds
Diffstat (limited to 'test/scaladoc/scalacheck/HtmlFactoryTest.scala')
-rw-r--r-- | test/scaladoc/scalacheck/HtmlFactoryTest.scala | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/test/scaladoc/scalacheck/HtmlFactoryTest.scala b/test/scaladoc/scalacheck/HtmlFactoryTest.scala index f0f106b293..daa7de8545 100644 --- a/test/scaladoc/scalacheck/HtmlFactoryTest.scala +++ b/test/scaladoc/scalacheck/HtmlFactoryTest.scala @@ -26,6 +26,8 @@ object Test extends Properties("HtmlFactory") { final val RESOURCES = "test/scaladoc/resources/" + + import scala.tools.nsc.ScalaDocReporter import scala.tools.nsc.doc.{DocFactory, Settings} import scala.tools.nsc.doc.model.IndexModelFactory import scala.tools.nsc.doc.html.HtmlFactory @@ -59,7 +61,7 @@ object Test extends Properties("HtmlFactory") { createFactory.makeUniverse(Left(List(RESOURCES+basename))) match { case Some(universe) => { val index = IndexModelFactory.makeIndex(universe) - (new HtmlFactory(universe, index)).writeTemplates((page) => { + (new HtmlFactory(universe, index, new ScalaDocReporter(universe.settings))).writeTemplates((page) => { result += (page.absoluteLinkTo(page.path) -> page.body) }) } @@ -75,7 +77,8 @@ object Test extends Properties("HtmlFactory") { val index = IndexModelFactory.makeIndex(universe) val pages = index.firstLetterIndex.map({ case (key, value) => { - val page = new ReferenceIndex(key, index, universe) + val reporter = new ScalaDocReporter(universe.settings) + val page = new ReferenceIndex(key, index, universe, reporter) page.absoluteLinkTo(page.path) -> page.body } }) @@ -723,9 +726,9 @@ object Test extends Properties("HtmlFactory") { } case _ => false } - property("package") = files.get("com/example/p1/package.html") != None + property("package") = files.get("com/example/p1/index.html") != None - property("package object") = files("com/example/p1/package.html") match { + property("package object") = files("com/example/p1/index.html") match { case node: scala.xml.Node => node.toString contains "com.example.p1#packageObjectMethod" case _ => false @@ -743,13 +746,13 @@ object Test extends Properties("HtmlFactory") { property("SI-8514: No inconsistencies") = checkText("SI-8514.scala")( - (Some("a/package"), + (Some("a/index"), """class A extends AnyRef Some doc here Some doc here Annotations @DeveloperApi() """, true), - (Some("a/package"), + (Some("a/index"), """class B extends AnyRef Annotations @DeveloperApi() """, true) @@ -794,28 +797,28 @@ object Test extends Properties("HtmlFactory") { case _ => false } - property("SI-8144: Members' permalink - package") = check("some/package.html") { node => - ("type link" |: node.assertTypeLink("../index.html#some.package")) && - ("member: some.pack" |: node.assertValuesLink("some.pack", "../index.html#some.package@pack")) + property("SI-8144: Members' permalink - package") = check("some/index.html") { node => + ("type link" |: node.assertTypeLink("../some/index.html")) && + ("member: some.pack" |: node.assertValuesLink("some.pack", "../some/index.html#pack")) } - property("SI-8144: Members' permalink - inner package") = check("some/pack/package.html") { node => - ("type link" |: node.assertTypeLink("../../index.html#some.pack.package")) && - ("member: SomeType (object)" |: node.assertValuesLink("some.pack.SomeType", "../../index.html#some.pack.package@SomeType")) && - ("member: SomeType (class)" |: node.assertMemberLink("types")("some.pack.SomeType", "../../index.html#some.pack.package@SomeTypeextendsAnyRef")) + property("SI-8144: Members' permalink - inner package") = check("some/pack/index.html") { node => + ("type link" |: node.assertTypeLink("../../some/pack/index.html")) && + ("member: SomeType (object)" |: node.assertValuesLink("some.pack.SomeType", "../../some/pack/index.html#SomeType")) && + ("member: SomeType (class)" |: node.assertMemberLink("types")("some.pack.SomeType", "../../some/pack/index.html#SomeTypeextendsAnyRef")) } property("SI-8144: Members' permalink - companion object") = check("some/pack/SomeType$.html") { node => - ("type link" |: node.assertTypeLink("../../index.html#some.pack.SomeType$")) && - ("member: someVal" |: node.assertMemberLink("allMembers")("some.pack.SomeType#someVal", "../../index.html#some.pack.SomeType$@someVal:String")) + ("type link" |: node.assertTypeLink("../../some/pack/SomeType$.html")) && + ("member: someVal" |: node.assertMemberLink("allMembers")("some.pack.SomeType#someVal", "../../some/pack/SomeType$.html#someVal:String")) } property("SI-8144: Members' permalink - class") = check("some/pack/SomeType.html") { node => - ("type link" |: node.assertTypeLink("../../index.html#some.pack.SomeType")) && - ("constructor " |: node.assertMemberLink("constructors")("some.pack.SomeType#<init>", "../../index.html#some.pack.SomeType@<init>(arg:String):some.pack.SomeType")) && - ( "member: type TypeAlias" |: node.assertMemberLink("types")("some.pack.SomeType.TypeAlias", "../../index.html#some.pack.SomeType@TypeAlias=String")) && - ( "member: def >#<():Int " |: node.assertValuesLink("some.pack.SomeType#>#<", "../../index.html#some.pack.SomeType@>#<():Int")) && - ( "member: def >@<():TypeAlias " |: node.assertValuesLink("some.pack.SomeType#>@<", "../../index.html#some.pack.SomeType@>@<():SomeType.this.TypeAlias")) + ("type link" |: node.assertTypeLink("../../some/pack/SomeType.html")) && + ("constructor " |: node.assertMemberLink("constructors")("some.pack.SomeType#<init>", "../../some/pack/SomeType.html#<init>(arg:String):some.pack.SomeType")) && + ( "member: type TypeAlias" |: node.assertMemberLink("types")("some.pack.SomeType.TypeAlias", "../../some/pack/SomeType.html#TypeAlias=String")) && + ( "member: def >#<():Int " |: node.assertValuesLink("some.pack.SomeType#>#<", "../../some/pack/SomeType.html#>#<():Int")) && + ( "member: def >@<():TypeAlias " |: node.assertValuesLink("some.pack.SomeType#>@<", "../../some/pack/SomeType.html#>@<():SomeType.this.TypeAlias")) } } |