Skip to content

Commit

Permalink
Initial functionality #1
Browse files Browse the repository at this point in the history
* Finish build settings
* Add in ScalaFmt
* Make 2 themes we plan to support
* Integrate theme selection into HugoPass
  • Loading branch information
reidspencer committed Mar 29, 2024
1 parent 88a3db0 commit d2e1c38
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 11 deletions.
8 changes: 7 additions & 1 deletion hugo/src/main/scala/com/ossuminc/riddl/hugo/HugoPass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.ossuminc.riddl.passes.symbols.Symbols.ParentStack
import com.ossuminc.riddl.passes.validate.ValidationPass
import com.ossuminc.riddl.stats.StatsPass
import com.ossuminc.riddl.utils.{PathUtils, Tar, Timer, TreeCopyFileVisitor, Zip}
import com.ossuminc.riddl.hugo.themes.*

import java.io.File
import java.net.URL
Expand Down Expand Up @@ -88,7 +89,12 @@ case class HugoPass(
next.resolve(par)
}
val path = parDir.resolve(fileName)
val mdw = MarkdownWriter(path, commonOptions, symbolsOutput, refMap, usage, this)
val mdw: MarkdownWriter = options.hugoThemeName match {
case Some(GeekDocTheme.name) | None => GeekDocTheme(path, commonOptions, symbolsOutput, refMap, usage, this)
case Some(DotdockTheme.name) => DotdockTheme(path, commonOptions, symbolsOutput, refMap, usage, this)
case Some(s) => messages.addError((0, 0), s"Hugo theme named '$s' is not supported, using GeekDoc ")
GeekDocTheme(path, commonOptions, symbolsOutput, refMap, usage, this)
}
addFile(mdw)
mdw
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.ossuminc.riddl.utils.TextFileWriter
import java.nio.file.Path
import scala.annotation.unused

case class MarkdownWriter(
abstract class MarkdownWriter(
filePath: Path,
commonOptions: CommonOptions,
symbolsOutput: SymbolsOutput,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.ossuminc.riddl.hugo.themes

import com.ossuminc.riddl.hugo.{MarkdownWriter, PassUtilities}
import com.ossuminc.riddl.language.CommonOptions
import com.ossuminc.riddl.passes.resolve.{ReferenceMap, Usages}
import com.ossuminc.riddl.passes.symbols.SymbolsOutput

import java.nio.file.Path

object DotdockTheme {
val name = "DotDock"
}

/** Theme extensions to the Markdown writer for the Dotdock Hugo theme
*
* @param filePath
* Path to the file being written
* @param commonOptions
* The common options to consider when writing
* @param symbolsOutput
* The symbol table
* @param refMap
* The reference map for looking up references
* @param usage
* The usage statistics
* @param passUtilities
* The PassUtilities from running the various passes
*/
case class DotdockTheme(
filePath: Path,
commonOptions: CommonOptions,
symbolsOutput: SymbolsOutput,
refMap: ReferenceMap,
usage: Usages,
passUtilities: PassUtilities
) extends MarkdownWriter(filePath, commonOptions, symbolsOutput, refMap, usage, passUtilities) {
final val name: String = DotdockTheme.name
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
package com.ossuminc.riddl.hugo.themes

import com.ossuminc.riddl.hugo.MarkdownWriter
import com.ossuminc.riddl.hugo.{MarkdownWriter, PassUtilities}
import com.ossuminc.riddl.language.CommonOptions
import com.ossuminc.riddl.passes.resolve.{ReferenceMap, Usages}
import com.ossuminc.riddl.passes.symbols.SymbolsOutput

case class GeekDocTheme(mdw: MarkdownWriter) extends ThemeWriter(mdw) {
def name: String = "GeekDoc"
import java.nio.file.Path

object GeekDocTheme {
val name: String = "GeekDoc"
}

/** Theme extension to the MardownWriter for the Hugo GeekDoc theme */
case class GeekDocTheme(
filePath: Path,
commonOptions: CommonOptions,
symbolsOutput: SymbolsOutput,
refMap: ReferenceMap,
usage: Usages,
passUtilities: PassUtilities
) extends MarkdownWriter(filePath, commonOptions, symbolsOutput, refMap, usage, passUtilities) with ThemeWriter {

def themeName: String = GeekDocTheme.name
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.ossuminc.riddl.hugo.themes

import com.ossuminc.riddl.hugo.MarkdownWriter

trait ThemeWriter(mdw: MarkdownWriter) {
def name: String
trait ThemeWriter { this: MarkdownWriter =>

def themeName: String
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ossuminc.riddl.hugo

import com.ossuminc.riddl.hugo.themes.GeekDocTheme
import com.ossuminc.riddl.language.{CommonOptions, Messages}
import com.ossuminc.riddl.language.Messages.Messages
import com.ossuminc.riddl.language.AST.Root
Expand Down Expand Up @@ -49,7 +50,7 @@ abstract class HugoTestBase extends ValidatingTest {
def outputs: PassesOutput = passesResult.outputs
def options: HugoCommand.Options = HugoCommand.Options()
protected val messages: Messages.Accumulator = Messages.Accumulator(commonOptions)
MarkdownWriter(filePath, commonOptions, symbols, refMap, usages, pu)
GeekDocTheme(filePath, commonOptions, symbols, refMap, usages, pu)
}

def makeMDWFor(input: String): (PassesResult, Root, MarkdownWriter) = {
Expand Down
2 changes: 1 addition & 1 deletion project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ object Deps {
)

val pureconfig: Seq[ModuleID] =
Seq[ModuleID]("com.github.pureconfig" %% "pureconfig-core" % V.pureconfig)
Seq[ModuleID ]("com.github.pureconfig" %% "pureconfig-core" % V.pureconfig)
}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

addSbtPlugin("com.ossuminc" % "sbt-ossuminc" % "0.8.3")
addSbtPlugin("com.ossuminc" % "sbt-ossuminc" % "0.9.5")

// This enables sbt-bloop to create bloop config files for Metals editors
// Uncomment locally if you use metals, otherwise don't slow down other
Expand Down

0 comments on commit d2e1c38

Please sign in to comment.