Skip to content

Commit

Permalink
Refine text tags (#232)
Browse files Browse the repository at this point in the history
* Refine tags to a more specific type

There is a regression introduced during the Scala 3 upgrade where the
`scalatags.Text.all.doctype` case class no longer worked with the
pre-existing tags since its second argument accepts a
`scalatags.text.Frag` but the tags themselves refined to
`<tag-name>.Self` (the <tag-name> is a placeholder for the tag's name).
As it turns out, this self type was not being refined by the tags
themselves because for some reason, the Scala 3 compiler resolves this
type to be `scalatags.generic.TypedTag` i.e. it resolves to the more
generic type as opposed to the more specific type of
`scalatags.Text.TypedTag`. Fortunately in Scala 2, this works out fine
as the type does get refined and therefore the tags can be used inside
a `scalatags.text.Frag`.

This commit essentially adds type annotations to all the tags under the
text package so that the more specific `ConcreteHtmlTag[String]` is used
instead of the more generic `TypedTag`.

* Add doctype compilation test and fix extraneous warnings.
  • Loading branch information
seoethereal authored Dec 17, 2021
1 parent 2d4454c commit 47f8f7f
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 189 deletions.
150 changes: 75 additions & 75 deletions scalatags/src/scalatags/text/SvgTags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,80 @@ package scalatags
package text
trait SvgTags extends generic.SvgTags[Builder, String, String]
with TagFactory{
lazy val altGlyph = tag("altGlyph")
lazy val altGlyphDef = tag("altGlyphDef")
lazy val altGlyphItem = tag("altGlyphItem")
lazy val animate = tag("animate")
lazy val animateMotion = tag("animateMotion")
lazy val animateTransform = tag("animateTransform")
lazy val circle = tag("circle")
lazy val clipPath = tag("clipPath")
lazy val `color-profile` = tag("color-profile")
lazy val cursor = tag("cursor")
lazy val defs = tag("defs")
lazy val desc = tag("desc")
lazy val ellipse = tag("ellipse")
lazy val feBlend = tag("feBlend")
lazy val feColorMatrix = tag("feColorMatrix")
lazy val feComponentTransfer = tag("feComponentTransfer")
lazy val feComposite = tag("feComposite")
lazy val feConvolveMatrix = tag("feConvolveMatrix")
lazy val feDiffuseLighting = tag("feDiffuseLighting")
lazy val feDisplacementMap = tag("feDisplacementMap")
lazy val feDistantLighting = tag("feDistantLighting")
lazy val feFlood = tag("feFlood")
lazy val feFuncA = tag("feFuncA")
lazy val feFuncB = tag("feFuncB")
lazy val feFuncG = tag("feFuncG")
lazy val feFuncR = tag("feFuncR")
lazy val feGaussianBlur = tag("feGaussianBlur")
lazy val feImage = tag("feImage")
lazy val feMerge = tag("feMerge")
lazy val feMergeNode = tag("feMergeNode")
lazy val feMorphology = tag("feMorphology")
lazy val feOffset = tag("feOffset")
lazy val fePointLight = tag("fePointLight")
lazy val feSpecularLighting = tag("feSpecularLighting")
lazy val feSpotlight = tag("feSpotlight")
lazy val feTile = tag("feTile")
lazy val feTurbulance = tag("feTurbulance")
lazy val filter = tag("filter")
lazy val font = tag("font")
lazy val `font-face` = tag("font-face")
lazy val `font-face-format` = tag("font-face-format")
lazy val `font-face-name` = tag("font-face-name")
lazy val `font-face-src` = tag("font-face-src")
lazy val `font-face-uri` = tag("font-face-uri")
lazy val foreignObject = tag("foreignObject")
lazy val g = tag("g")
lazy val glyph = tag("glyph")
lazy val glyphRef = tag("glyphRef")
lazy val hkern = tag("hkern")
lazy val image = tag("image")
lazy val line = tag("line")
lazy val linearGradient = tag("linearGradient")
lazy val marker = tag("marker")
lazy val mask = tag("mask")
lazy val metadata = tag("metadata")
lazy val `missing-glyph` = tag("missing-glyph")
lazy val mpath = tag("mpath")
lazy val path = tag("path")
lazy val pattern = tag("pattern")
lazy val polygon = tag("polygon")
lazy val polyline = tag("polyline")
lazy val radialGradient = tag("radialGradient")
lazy val rect = tag("rect")
lazy val set = tag("set")
lazy val stop = tag("stop")
lazy val svg = tag("svg")
lazy val switch = tag("switch")
lazy val symbol = tag("symbol")
lazy val text = tag("text")
lazy val textPath = tag("textPath")
lazy val tref = tag("tref")
lazy val tspan = tag("tspan")
lazy val use = tag("use")
lazy val view = tag("view")
lazy val vkern = tag("vkern")
lazy val altGlyph: ConcreteHtmlTag[String] = tag("altGlyph")
lazy val altGlyphDef: ConcreteHtmlTag[String] = tag("altGlyphDef")
lazy val altGlyphItem: ConcreteHtmlTag[String] = tag("altGlyphItem")
lazy val animate: ConcreteHtmlTag[String] = tag("animate")
lazy val animateMotion: ConcreteHtmlTag[String] = tag("animateMotion")
lazy val animateTransform: ConcreteHtmlTag[String] = tag("animateTransform")
lazy val circle: ConcreteHtmlTag[String] = tag("circle")
lazy val clipPath: ConcreteHtmlTag[String] = tag("clipPath")
lazy val `color-profile`: ConcreteHtmlTag[String] = tag("color-profile")
lazy val cursor: ConcreteHtmlTag[String] = tag("cursor")
lazy val defs: ConcreteHtmlTag[String] = tag("defs")
lazy val desc: ConcreteHtmlTag[String] = tag("desc")
lazy val ellipse: ConcreteHtmlTag[String] = tag("ellipse")
lazy val feBlend: ConcreteHtmlTag[String] = tag("feBlend")
lazy val feColorMatrix: ConcreteHtmlTag[String] = tag("feColorMatrix")
lazy val feComponentTransfer: ConcreteHtmlTag[String] = tag("feComponentTransfer")
lazy val feComposite: ConcreteHtmlTag[String] = tag("feComposite")
lazy val feConvolveMatrix: ConcreteHtmlTag[String] = tag("feConvolveMatrix")
lazy val feDiffuseLighting: ConcreteHtmlTag[String] = tag("feDiffuseLighting")
lazy val feDisplacementMap: ConcreteHtmlTag[String] = tag("feDisplacementMap")
lazy val feDistantLighting: ConcreteHtmlTag[String] = tag("feDistantLighting")
lazy val feFlood: ConcreteHtmlTag[String] = tag("feFlood")
lazy val feFuncA: ConcreteHtmlTag[String] = tag("feFuncA")
lazy val feFuncB: ConcreteHtmlTag[String] = tag("feFuncB")
lazy val feFuncG: ConcreteHtmlTag[String] = tag("feFuncG")
lazy val feFuncR: ConcreteHtmlTag[String] = tag("feFuncR")
lazy val feGaussianBlur: ConcreteHtmlTag[String] = tag("feGaussianBlur")
lazy val feImage: ConcreteHtmlTag[String] = tag("feImage")
lazy val feMerge: ConcreteHtmlTag[String] = tag("feMerge")
lazy val feMergeNode: ConcreteHtmlTag[String] = tag("feMergeNode")
lazy val feMorphology: ConcreteHtmlTag[String] = tag("feMorphology")
lazy val feOffset: ConcreteHtmlTag[String] = tag("feOffset")
lazy val fePointLight: ConcreteHtmlTag[String] = tag("fePointLight")
lazy val feSpecularLighting: ConcreteHtmlTag[String] = tag("feSpecularLighting")
lazy val feSpotlight: ConcreteHtmlTag[String] = tag("feSpotlight")
lazy val feTile: ConcreteHtmlTag[String] = tag("feTile")
lazy val feTurbulance: ConcreteHtmlTag[String] = tag("feTurbulance")
lazy val filter: ConcreteHtmlTag[String] = tag("filter")
lazy val font: ConcreteHtmlTag[String] = tag("font")
lazy val `font-face`: ConcreteHtmlTag[String] = tag("font-face")
lazy val `font-face-format`: ConcreteHtmlTag[String] = tag("font-face-format")
lazy val `font-face-name`: ConcreteHtmlTag[String] = tag("font-face-name")
lazy val `font-face-src`: ConcreteHtmlTag[String] = tag("font-face-src")
lazy val `font-face-uri`: ConcreteHtmlTag[String] = tag("font-face-uri")
lazy val foreignObject: ConcreteHtmlTag[String] = tag("foreignObject")
lazy val g: ConcreteHtmlTag[String] = tag("g")
lazy val glyph: ConcreteHtmlTag[String] = tag("glyph")
lazy val glyphRef: ConcreteHtmlTag[String] = tag("glyphRef")
lazy val hkern: ConcreteHtmlTag[String] = tag("hkern")
lazy val image: ConcreteHtmlTag[String] = tag("image")
lazy val line: ConcreteHtmlTag[String] = tag("line")
lazy val linearGradient: ConcreteHtmlTag[String] = tag("linearGradient")
lazy val marker: ConcreteHtmlTag[String] = tag("marker")
lazy val mask: ConcreteHtmlTag[String] = tag("mask")
lazy val metadata: ConcreteHtmlTag[String] = tag("metadata")
lazy val `missing-glyph`: ConcreteHtmlTag[String] = tag("missing-glyph")
lazy val mpath: ConcreteHtmlTag[String] = tag("mpath")
lazy val path: ConcreteHtmlTag[String] = tag("path")
lazy val pattern: ConcreteHtmlTag[String] = tag("pattern")
lazy val polygon: ConcreteHtmlTag[String] = tag("polygon")
lazy val polyline: ConcreteHtmlTag[String] = tag("polyline")
lazy val radialGradient: ConcreteHtmlTag[String] = tag("radialGradient")
lazy val rect: ConcreteHtmlTag[String] = tag("rect")
lazy val set: ConcreteHtmlTag[String] = tag("set")
lazy val stop: ConcreteHtmlTag[String] = tag("stop")
lazy val svg: ConcreteHtmlTag[String] = tag("svg")
lazy val switch: ConcreteHtmlTag[String] = tag("switch")
lazy val symbol: ConcreteHtmlTag[String] = tag("symbol")
lazy val text: ConcreteHtmlTag[String] = tag("text")
lazy val textPath: ConcreteHtmlTag[String] = tag("textPath")
lazy val tref: ConcreteHtmlTag[String] = tag("tref")
lazy val tspan: ConcreteHtmlTag[String] = tag("tspan")
lazy val use: ConcreteHtmlTag[String] = tag("use")
lazy val view: ConcreteHtmlTag[String] = tag("view")
lazy val vkern: ConcreteHtmlTag[String] = tag("vkern")
}

156 changes: 78 additions & 78 deletions scalatags/src/scalatags/text/Tags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,91 @@ package scalatags
package text
trait Tags extends generic.Tags[Builder, String, String] with TagFactory{
// Root Element
lazy val html = tag("html")
lazy val html: ConcreteHtmlTag[String] = tag("html")
// Document Metadata
lazy val head = tag("head")
lazy val base = tag("base", void = true)
lazy val link = tag("link", void = true)
lazy val meta = tag("meta", void = true)
lazy val head: ConcreteHtmlTag[String] = tag("head")
lazy val base: ConcreteHtmlTag[String] = tag("base", void = true)
lazy val link: ConcreteHtmlTag[String] = tag("link", void = true)
lazy val meta: ConcreteHtmlTag[String] = tag("meta", void = true)
// Scripting
lazy val script = tag("script")
lazy val script: ConcreteHtmlTag[String] = tag("script")
// Sections
lazy val body = tag("body")
lazy val h1 = tag("h1")
lazy val h2 = tag("h2")
lazy val h3 = tag("h3")
lazy val h4 = tag("h4")
lazy val h5 = tag("h5")
lazy val h6 = tag("h6")
lazy val header = tag("header")
lazy val footer = tag("footer")
lazy val body: ConcreteHtmlTag[String] = tag("body")
lazy val h1: ConcreteHtmlTag[String] = tag("h1")
lazy val h2: ConcreteHtmlTag[String] = tag("h2")
lazy val h3: ConcreteHtmlTag[String] = tag("h3")
lazy val h4: ConcreteHtmlTag[String] = tag("h4")
lazy val h5: ConcreteHtmlTag[String] = tag("h5")
lazy val h6: ConcreteHtmlTag[String] = tag("h6")
lazy val header: ConcreteHtmlTag[String] = tag("header")
lazy val footer: ConcreteHtmlTag[String] = tag("footer")
// Grouping content
lazy val p = tag("p")
lazy val hr = tag("hr", void = true)
lazy val pre = tag("pre")
lazy val blockquote = tag("blockquote")
lazy val ol = tag("ol")
lazy val ul = tag("ul")
lazy val li = tag("li")
lazy val dl = tag("dl")
lazy val dt = tag("dt")
lazy val dd = tag("dd")
lazy val figure = tag("figure")
lazy val figcaption = tag("figcaption")
lazy val div = tag("div")
lazy val p: ConcreteHtmlTag[String] = tag("p")
lazy val hr: ConcreteHtmlTag[String] = tag("hr", void = true)
lazy val pre: ConcreteHtmlTag[String] = tag("pre")
lazy val blockquote: ConcreteHtmlTag[String] = tag("blockquote")
lazy val ol: ConcreteHtmlTag[String] = tag("ol")
lazy val ul: ConcreteHtmlTag[String] = tag("ul")
lazy val li: ConcreteHtmlTag[String] = tag("li")
lazy val dl: ConcreteHtmlTag[String] = tag("dl")
lazy val dt: ConcreteHtmlTag[String] = tag("dt")
lazy val dd: ConcreteHtmlTag[String] = tag("dd")
lazy val figure: ConcreteHtmlTag[String] = tag("figure")
lazy val figcaption: ConcreteHtmlTag[String] = tag("figcaption")
lazy val div: ConcreteHtmlTag[String] = tag("div")
// Text-level semantics
lazy val a = tag("a")
lazy val em = tag("em")
lazy val strong = tag("strong")
lazy val small = tag("small")
lazy val s = tag("s")
lazy val cite = tag("cite")
lazy val code = tag("code")
lazy val sub = tag("sub")
lazy val sup = tag("sup")
lazy val i = tag("i")
lazy val b = tag("b")
lazy val u = tag("u")
lazy val span = tag("span")
lazy val br = tag("br", void = true)
lazy val wbr = tag("wbr", void = true)
lazy val a: ConcreteHtmlTag[String] = tag("a")
lazy val em: ConcreteHtmlTag[String] = tag("em")
lazy val strong: ConcreteHtmlTag[String] = tag("strong")
lazy val small: ConcreteHtmlTag[String] = tag("small")
lazy val s: ConcreteHtmlTag[String] = tag("s")
lazy val cite: ConcreteHtmlTag[String] = tag("cite")
lazy val code: ConcreteHtmlTag[String] = tag("code")
lazy val sub: ConcreteHtmlTag[String] = tag("sub")
lazy val sup: ConcreteHtmlTag[String] = tag("sup")
lazy val i: ConcreteHtmlTag[String] = tag("i")
lazy val b: ConcreteHtmlTag[String] = tag("b")
lazy val u: ConcreteHtmlTag[String] = tag("u")
lazy val span: ConcreteHtmlTag[String] = tag("span")
lazy val br: ConcreteHtmlTag[String] = tag("br", void = true)
lazy val wbr: ConcreteHtmlTag[String] = tag("wbr", void = true)
// Edits
lazy val ins = tag("ins")
lazy val del = tag("del")
lazy val ins: ConcreteHtmlTag[String] = tag("ins")
lazy val del: ConcreteHtmlTag[String] = tag("del")
// Embedded content
lazy val img = tag("img", void = true)
lazy val iframe = tag("iframe")
lazy val embed = tag("embed", void = true)
lazy val `object` = tag("object")
lazy val param = tag("param", void = true)
lazy val video = tag("video")
lazy val audio = tag("audio")
lazy val source = tag("source", void = true)
lazy val track = tag("track", void = true)
lazy val canvas = tag("canvas")
lazy val map = tag("map")
lazy val area = tag("area", void = true)
lazy val img: ConcreteHtmlTag[String] = tag("img", void = true)
lazy val iframe: ConcreteHtmlTag[String] = tag("iframe")
lazy val embed: ConcreteHtmlTag[String] = tag("embed", void = true)
lazy val `object`: ConcreteHtmlTag[String] = tag("object")
lazy val param: ConcreteHtmlTag[String] = tag("param", void = true)
lazy val video: ConcreteHtmlTag[String] = tag("video")
lazy val audio: ConcreteHtmlTag[String] = tag("audio")
lazy val source: ConcreteHtmlTag[String] = tag("source", void = true)
lazy val track: ConcreteHtmlTag[String] = tag("track", void = true)
lazy val canvas: ConcreteHtmlTag[String] = tag("canvas")
lazy val map: ConcreteHtmlTag[String] = tag("map")
lazy val area: ConcreteHtmlTag[String] = tag("area", void = true)
// Tabular data
lazy val table = tag("table")
lazy val caption = tag("caption")
lazy val colgroup = tag("colgroup")
lazy val col = tag("col", void = true)
lazy val tbody = tag("tbody")
lazy val thead = tag("thead")
lazy val tfoot = tag("tfoot")
lazy val tr = tag("tr")
lazy val td = tag("td")
lazy val th = tag("th")
lazy val table: ConcreteHtmlTag[String] = tag("table")
lazy val caption: ConcreteHtmlTag[String] = tag("caption")
lazy val colgroup: ConcreteHtmlTag[String] = tag("colgroup")
lazy val col: ConcreteHtmlTag[String] = tag("col", void = true)
lazy val tbody: ConcreteHtmlTag[String] = tag("tbody")
lazy val thead: ConcreteHtmlTag[String] = tag("thead")
lazy val tfoot: ConcreteHtmlTag[String] = tag("tfoot")
lazy val tr: ConcreteHtmlTag[String] = tag("tr")
lazy val td: ConcreteHtmlTag[String] = tag("td")
lazy val th: ConcreteHtmlTag[String] = tag("th")
// Forms
lazy val form = tag("form")
lazy val fieldset = tag("fieldset")
lazy val legend = tag("legend")
lazy val label = tag("label")
lazy val input = tag("input", void = true)
lazy val button = tag("button")
lazy val select = tag("select")
lazy val datalist = tag("datalist")
lazy val optgroup = tag("optgroup")
lazy val option = tag("option")
lazy val textarea = tag("textarea")
lazy val form: ConcreteHtmlTag[String] = tag("form")
lazy val fieldset: ConcreteHtmlTag[String] = tag("fieldset")
lazy val legend: ConcreteHtmlTag[String] = tag("legend")
lazy val label: ConcreteHtmlTag[String] = tag("label")
lazy val input: ConcreteHtmlTag[String] = tag("input", void = true)
lazy val button: ConcreteHtmlTag[String] = tag("button")
lazy val select: ConcreteHtmlTag[String] = tag("select")
lazy val datalist: ConcreteHtmlTag[String] = tag("datalist")
lazy val optgroup: ConcreteHtmlTag[String] = tag("optgroup")
lazy val option: ConcreteHtmlTag[String] = tag("option")
lazy val textarea: ConcreteHtmlTag[String] = tag("textarea")
}
64 changes: 32 additions & 32 deletions scalatags/src/scalatags/text/Tags2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@ package scalatags
package text
trait Tags2 extends generic.Tags2[Builder, String, String] with TagFactory{
// Document Metadata
lazy val title = tag("title")
lazy val style = tag("style")
lazy val title: ConcreteHtmlTag[String] = tag("title")
lazy val style: ConcreteHtmlTag[String] = tag("style")
// Scripting
lazy val noscript = tag("noscript")
lazy val noscript: ConcreteHtmlTag[String] = tag("noscript")
// Sections
lazy val section = tag("section")
lazy val nav = tag("nav")
lazy val article = tag("article")
lazy val aside = tag("aside")
lazy val address = tag("address")
lazy val main = tag("main")
lazy val section: ConcreteHtmlTag[String] = tag("section")
lazy val nav: ConcreteHtmlTag[String] = tag("nav")
lazy val article: ConcreteHtmlTag[String] = tag("article")
lazy val aside: ConcreteHtmlTag[String] = tag("aside")
lazy val address: ConcreteHtmlTag[String] = tag("address")
lazy val main: ConcreteHtmlTag[String] = tag("main")
// Text level semantics
lazy val q = tag("q")
lazy val dfn = tag("dfn")
lazy val abbr = tag("abbr")
lazy val data = tag("data")
lazy val time = tag("time")
lazy val `var` = tag("var")
lazy val samp = tag("samp")
lazy val kbd = tag("kbd")
lazy val math = tag("math")
lazy val mark = tag("mark")
lazy val ruby = tag("ruby")
lazy val rt = tag("rt")
lazy val rp = tag("rp")
lazy val bdi = tag("bdi")
lazy val bdo = tag("bdo")
lazy val q: ConcreteHtmlTag[String] = tag("q")
lazy val dfn: ConcreteHtmlTag[String] = tag("dfn")
lazy val abbr: ConcreteHtmlTag[String] = tag("abbr")
lazy val data: ConcreteHtmlTag[String] = tag("data")
lazy val time: ConcreteHtmlTag[String] = tag("time")
lazy val `var`: ConcreteHtmlTag[String] = tag("var")
lazy val samp: ConcreteHtmlTag[String] = tag("samp")
lazy val kbd: ConcreteHtmlTag[String] = tag("kbd")
lazy val math: ConcreteHtmlTag[String] = tag("math")
lazy val mark: ConcreteHtmlTag[String] = tag("mark")
lazy val ruby: ConcreteHtmlTag[String] = tag("ruby")
lazy val rt: ConcreteHtmlTag[String] = tag("rt")
lazy val rp: ConcreteHtmlTag[String] = tag("rp")
lazy val bdi: ConcreteHtmlTag[String] = tag("bdi")
lazy val bdo: ConcreteHtmlTag[String] = tag("bdo")
// Forms
lazy val keygen = tag("keygen", void = true)
lazy val output = tag("output")
lazy val progress = tag("progress")
lazy val meter = tag("meter")
lazy val keygen: ConcreteHtmlTag[String] = tag("keygen", void = true)
lazy val output: ConcreteHtmlTag[String] = tag("output")
lazy val progress: ConcreteHtmlTag[String] = tag("progress")
lazy val meter: ConcreteHtmlTag[String] = tag("meter")
// Interactive elements
lazy val details = tag("details")
lazy val summary = tag("summary")
lazy val command = tag("command", void = true)
lazy val menu = tag("menu")
lazy val details: ConcreteHtmlTag[String] = tag("details")
lazy val summary: ConcreteHtmlTag[String] = tag("summary")
lazy val command: ConcreteHtmlTag[String] = tag("command", void = true)
lazy val menu: ConcreteHtmlTag[String] = tag("menu")
}
Loading

0 comments on commit 47f8f7f

Please sign in to comment.