Skip to content

Commit

Permalink
v1.0.4 Final commit
Browse files Browse the repository at this point in the history
Row and column headers for table rendering are available but I intend to improve the structure and logic in a future release.
  • Loading branch information
rchillyard committed Apr 10, 2019
1 parent 6de4192 commit 685536e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ If you need to set HTML attributes for a specific type, for example a row in the
Release Notes
=============

V1.0.3 -> V1.0.4
* Added the ability to add header row and header column for tables (NOTE: not finalized yet, but functional).

V1.0.2 -> V1.0.3
* Added no implicit warnings
* Created mechanism for rendering the result of parsing in a hierarchical structure.
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ organization := "com.phasmidsoftware"

name := "TableParser"

version := "1.0.4-SNAPSHOT"
version := "1.0.4"

scalaVersion := "2.12.6"

Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/com/phasmidsoftware/render/Renderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class ProductRenderer[T <: Product : ClassTag](val style: String, overr
protected def us[U: TreeWriter](t: T): Seq[U]
}

abstract class IndexedRenderer[T: Renderer](val style: String, override val baseAttrs: Map[String, String] = Map()) extends Renderer[Indexed[T]] {
abstract class IndexedRenderer[T: Renderer](val style: String, indexStyle: String, override val baseAttrs: Map[String, String] = Map()) extends Renderer[Indexed[T]] {
/**
* Render an instance of Indexed[T] as a U.
*
Expand All @@ -90,8 +90,7 @@ abstract class IndexedRenderer[T: Renderer](val style: String, override val base
* @return a new instance of U.
*/
override def render[U: TreeWriter](ti: Indexed[T], attrs: Map[String, String]): U = {
// TODO specify style as header, but not with HTML-specific "th".
val indexRenderer: Renderer[Int] = new TaggedRenderer[Int]("th") {}
val indexRenderer: Renderer[Int] = new TaggedRenderer[Int](indexStyle) {}
implicitly[TreeWriter[U]].node(style, Seq(indexRenderer.render(ti.i), implicitly[Renderer[T]].render(ti.t)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/phasmidsoftware/render/Renderers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ trait Renderers {
* @tparam P the type of the result.
* @return a new instance of U.
*/
def indexedRenderer[P: Renderer](style: String, attrs: Map[String, String] = Map()): Renderer[Indexed[P]] = new IndexedRenderer[P](style, attrs) {}
def indexedRenderer[P: Renderer](style: String, indexStyle: String, attrs: Map[String, String] = Map()): Renderer[Indexed[P]] = new IndexedRenderer[P](style, indexStyle, attrs) {}

/**
* Render an option of P as a U.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RendererSpec extends FlatSpec with Matchers {
object Complex2 extends Renderers {
implicit val valueRenderer: Renderer[Double] = renderer("td")
implicit val complexRenderer: Renderer[Complex] = renderer2("span")(Complex)
implicit val indexedRenderer: Renderer[Indexed[Complex]] = indexedRenderer[Complex]("tr", Map())
implicit val indexedRenderer: Renderer[Indexed[Complex]] = indexedRenderer[Complex]("tr", "th", Map())
// val rowsRenderer: Renderer[Seq[Indexed[Complex]]] = sequenceRenderer[Indexed[Complex]]("span")


Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/com/phasmidsoftware/table/TableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class TableSpec extends FlatSpec with Matchers {
implicit object HTMLTreeWriter extends HTMLTreeWriter

implicit val intPairRenderer: Renderer[IntPair] = renderer2("IntPair")(IntPair.apply)
implicit val r: Renderer[Indexed[IntPair]] = indexedRenderer("", Map())
implicit val r: Renderer[Indexed[IntPair]] = indexedRenderer("", "th", Map())

}

Expand Down

0 comments on commit 685536e

Please sign in to comment.