All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.scrooge.backend.ConstsTemplate.scala Maven / Gradle / Ivy

The newest version!
package com.twitter.scrooge.backend

import com.twitter.scrooge.mustache.Dictionary.{codify, v}
import com.twitter.scrooge.mustache.Dictionary
import com.twitter.scrooge.ast.{Identifier, ConstDefinition}

trait ConstsTemplate { self: TemplateGenerator =>
  def constDict(
    namespace: Identifier,
    consts: Seq[ConstDefinition]
  ): Dictionary = Dictionary(
    "package" -> genID(namespace),
    "constants" -> v(consts map {
      c =>
        Dictionary(
          "name" -> genID(c.sid),
          "fieldType" -> genType(c.fieldType),
          "value" -> genConstant(c.value, false, Some(c.fieldType)),
          "docstring" -> codify(c.docstring.getOrElse(""))
        )
    })
  )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy