Skip to content

Commit

Permalink
Make HugoPass easier test & implement PathId substitutions
Browse files Browse the repository at this point in the history
Signed-off-by: reidspencer <reid.spencer@yoppworks.com>
  • Loading branch information
reid-spencer committed Oct 4, 2023
1 parent affa8e7 commit 5c5c98e
Show file tree
Hide file tree
Showing 12 changed files with 338 additions and 49 deletions.
132 changes: 132 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
######################## Hugo Configuration ####################

# Configure GeekDocs
baseUrl = "https://example.com/"
languageCode = "en-us"
title = "Unspecified Site Title"
name = "Unspecified Project Name"
description = "Unspecified Project Description"
tags = ["docs", "documentation", "responsive", "simple", "riddl"]
min_version = "0.83.0"
theme = [ "hugo-geekdoc" ]

# Author information from config
[author]
name = "Not Provided"
email = "somebody@somewere.tld"
homepage = "https://example.org/"

# Required to get well formatted code blocks
pygmentsUseClasses = true
pygmentsCodeFences = true
disablePathToLower = true
enableGitInfo = true
pygmentsStyle = "monokailight"

# Required if you want to render robots.txt template
enableRobotsTXT = true


# markup(down?) rendering configuration
[markup.goldmark.renderer]
# Needed for mermaid shortcode
unsafe = true
[markup.tableOfContents]
startLevel = 1
endLevel = 9
[markup.goldmark.extensions]
definitionList = true
footnote = true
linkify = true
strikethrough = true
table = true
taskList = true
typographer = true


[taxonomies]
tag = "tags"

[params]
# (Optional, default 6) Set how many table of contents levels to be showed on page.
# Use false to hide ToC, note that 0 will default to 6 (https://gohugo.io/functions/default/)
# You can also specify this parameter per page in front matter.
geekdocToC = false

# (Optional, default static/brand.svg) Set the path to a logo for the Geekdoc
# relative to your 'static/' folder.
geekdocLogo = "images/logo.png"

# (Optional, default false) Render menu from data file in 'data/menu/main.yaml'.
# See also https://geekdocs.de/usage/menus/#bundle-menu.
geekdocMenuBundle = false

# (Optional, default false) Collapse all menu entries, can not be overwritten
# per page if enabled. Can be enabled per page via `geekdocCollapseSection`.
geekdocCollapseAllSections = false

# (Optional, default true) Show page navigation links at the bottom of each
# docs page (bundle menu only).
geekdocNextPrev = true

# (Optional, default true) Show a breadcrumb navigation bar at the top of each docs page.
# You can also specify this parameter per page in front matter.
geekdocBreadcrumb = true

# (Optional, default none) Set source repository location. Used for 'Edit page' links.
# You can also specify this parameter per page in front matter.
geekdocRepo = ""

# (Optional, default none) Enable 'Edit page' links. Requires 'GeekdocRepo' param
# and path must point to 'content' directory of repo.
# You can also specify this parameter per page in front matter.
geekdocEditPath = "edit/main/src/main/riddl"

# (Optional, default true) Enables search function with flexsearch.
# Index is built on the fly and might slow down your website.
geekdocSearch = true

# (Optional, default false) Display search results with the parent folder as prefix. This
# option allows you to distinguish between files with the same name in different folders.
# NOTE: This parameter only applies when 'geekdocSearch = true'.
geekdocSearchShowParent = true

# (Optional, default none) Add a link to your Legal Notice page to the site footer.
# It can be either a remote url or a local file path relative to your content directory.
geekdocLegalNotice = "/legal"

# (Optional, default none) Add a link to your Privacy Policy page to the site footer.
# It can be either a remote url or a local file path relative to your content directory.
geekdocPrivacyPolicy = "/privacy"

# (Optional, default true) Add an anchor link to headlines.
geekdocAnchor = true

# (Optional, default true) Copy anchor url to clipboard on click.
geekdocAnchorCopy = true

# (Optional, default true) Enable or disable image lazy loading for images rendered
# by the 'img' shortcode.
geekdocImageLazyLoading = true

# (Optional, default false) Set HTMl <base> to .Site.BaseURL if enabled. It might be required
# if a subdirectory is used within Hugos BaseURL.
# See https://developer.mozilla.org/de/docs/Web/HTML/Element/base.
geekdocOverwriteHTMLBase = false

# (Optional, default false) Auto-decrease brightness of images and add a slightly grayscale to avoid
# bright spots while using the dark mode.
geekdocDarkModeDim = true

# (Optional, default true) Display a "Back to top" link in the site footer.
geekdocBackToTop = true

# (Optional, default false) Enable or disable adding tags for post pages automatically to the
# navigation sidebar.
geekdocTagsToMenu = true

# (Optional, default 'title') Configure how to sort file-tree menu entries. Possible options are 'title',
# 'linktitle', 'date', 'publishdate', 'expirydate' or 'lastmod'. Every option can be used with a reverse
# modifier as well e.g. 'title_reverse'.
geekdocFileTreeSortBy = "title"

31 changes: 31 additions & 0 deletions content/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: "Index"
weight: 10
draft: "false"
description: "The main index to the content"
geekdocAnchor: true
geekdocToC: 4

---

## *Landscape View*
{{< mermaid class="text-center">}}
flowchart TB
subgraph Root ["Root<br/><small>No brief description.<br/>(Arbitrary Technology)</small>"]
subgraph substitutions ["substitutions<br/><small>No brief description.<br/>(Arbitrary Technology)</small>"]
end
style substitutions font-size:1pc,fill:#2222AA,stroke:black,stroke-width:5,border:solid,color:white,margin-top:36px
end
style Root font-size:1pc,fill:#000088,stroke:black,stroke-width:6,border:solid,color:white,margin-top:36px
{{< /mermaid >}}

## *Domains*
* [substitutions](substitutions/)

## *Indices*
* [Glossary](glossary)
* [To Do List](todolist)
* [Statistics](statistics)

## *Textual Full Index*
{{< toc-tree >}}
13 changes: 13 additions & 0 deletions content/glossary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "Glossary Of Terms"
weight: 970
draft: "false"
description: "A generated glossary of terms"
geekdocAnchor: true
geekdocToC: 4

---
| Term | Type | Brief Description |
| :---: | :---: | :--- |
| [`referenced`](/substitutions/referenced) | [Context](https://riddl.tech/concepts/context/) | -- undefined -- |
| [`substitutions`](/substitutions) | [Domain](https://riddl.tech/concepts/domain/) | -- undefined -- |
15 changes: 15 additions & 0 deletions content/statistics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Model Statistics"
weight: 990
draft: "false"
description: "Statistical information about the RIDDL model documented"
geekdocAnchor: true
geekdocToC: 4

---
| Category | count | % of All | % documented | number empty | avg completeness | avg complexity | avg containment |
| :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| Context | 1 | 33.33333333333333 | 0.0 | 1 | 0.0 | 0.0 | 0.0 |
| Root | 1 | 33.33333333333333 | 0.0 | 0 | 0.0 | 0.0 | 0.0 |
| Domain | 1 | 33.33333333333333 | 0.4 | 0 | 18.181818181818183 | 6000.0 | 2.0 |
| All | 3 | 100.0 | 0.4 | 1 | 5.714285714285714 | 2000.0 | 0.6666666666666666 |
32 changes: 32 additions & 0 deletions content/substitutions/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "substitutions: Domain"
weight: 10
draft: "false"
description: "substitutions has no brief description."
geekdocAnchor: true
geekdocToC: 4
geekdocCollapseSection: true
geekdocFilePath: no-such-file
---
| Item | Value |
| :---: | :--- |
| _Briefly_ | Brief description missing. |
| _Authors_ | |
| _Definition Path_ | substitutions |
| _View Source Link_ | [string(1:1)]() |

## *Description*
This substitutions domain contains (context substitutions.referenced)[/substitutions/referenced]
which maps to https://www.merriam-webster.com/

## *Types*

## *Contexts*
* [referenced](referenced)

## *Used By None*

## *Uses Nothing*

## *Textual Domain Index*
{{< toc-tree >}}
37 changes: 37 additions & 0 deletions content/substitutions/referenced/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "referenced: Context"
weight: 10
draft: "false"
description: "referenced has no brief description."
geekdocAnchor: true
geekdocToC: 4
geekdocCollapseSection: true
geekdocFilePath: no-such-file
---
| Item | Value |
| :---: | :--- |
| _Briefly_ | Brief description missing. |
| _Authors_ | |
| _Definition Path_ | substitutions.referenced |
| _View Source Link_ | [string(2:3)]() |

## *Context Map*
{{< mermaid class="text-center">}}
C4Context
title C4 Containment Diagram for [Context 'referenced']
Enterprise_Boundary(Root,Root,"Context 'referenced' is not described.") {
System_Boundary(substitutions,substitutions,"Context 'referenced' is not described.") {
Boundary(Context 'referenced', Context 'referenced', "Context 'referenced' is not described.") {
}
}
}
{{< /mermaid >}}

## *Types*

## *Used By None*

## *Uses Nothing*

## *Textual Context Index*
{{< toc-tree >}}
14 changes: 14 additions & 0 deletions content/todolist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "To Do List"
weight: 980
draft: "false"
description: "A list of definitions needing more work"
geekdocAnchor: true
geekdocToC: 4

---

## *Definitions With Missing Content*

### _Unspecified Author_
* [Context 'referenced' In substitutions](/substitutions/referenced)
47 changes: 24 additions & 23 deletions hugo/src/main/scala/com/reactific/riddl/hugo/HugoPass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ case class HugoPass(input: PassInput, state: HugoTranslatorState) extends Pass(i
options.outputRoot.getFileName.toString.nonEmpty,
"Output path is empty"
)
options.inputFile match
case None =>
require(false, "inputFile option provides no path")
case Some(path: Path) =>
makeDirectoryStructure(path, state.logger, options, commonOptions)
if options.inputFile.nonEmpty then
makeDirectoryStructure(options.inputFile, state.logger, options, commonOptions)

val root = input.root
val root: RootContainer = input.root

val maybeAuthor = root.authors.headOption.orElse { root.domains.headOption.flatMap(_.authorDefs.headOption) }
private val maybeAuthor = root.authors.headOption.orElse { root.domains.headOption.flatMap(_.authorDefs.headOption) }
writeConfigToml(options, maybeAuthor)

val name: String = HugoPass.name
Expand Down Expand Up @@ -178,25 +175,29 @@ case class HugoPass(input: PassInput, state: HugoTranslatorState) extends Pass(i
}

private def loadStaticAssets(
inputPath: Path,
inputPath: Option[Path],
log: Logger,
options: HugoCommand.Options
): Unit = {
val inputRoot: Path = inputPath.toAbsolutePath
val sourceDir: Path = inputRoot.getParent.resolve("static")
inputPath match {
case Some(path) =>
val inputRoot: Path = path.toAbsolutePath
val sourceDir: Path = inputRoot.getParent.resolve("static")

val targetDir = options.staticRoot
if Files.exists(sourceDir) && Files.isDirectory(sourceDir) then {
val img = sourceDir
.resolve(options.siteLogoPath.getOrElse("images/logo.png"))
.toAbsolutePath
Files.createDirectories(img.getParent)
if !Files.exists(img) then {
copyResource(img, "hugo/static/images/RIDDL-Logo.ico")
}
// copy source to target using Files Class
val visitor = TreeCopyFileVisitor(log, sourceDir, targetDir)
Files.walkFileTree(sourceDir, visitor)
val targetDir = options.staticRoot
if Files.exists(sourceDir) && Files.isDirectory(sourceDir) then {
val img = sourceDir
.resolve(options.siteLogoPath.getOrElse("images/logo.png"))
.toAbsolutePath
Files.createDirectories(img.getParent)
if !Files.exists(img) then {
copyResource(img, "hugo/static/images/RIDDL-Logo.ico")
}
// copy source to target using Files Class
val visitor = TreeCopyFileVisitor(log, sourceDir, targetDir)
Files.walkFileTree(sourceDir, visitor)
}
case None => ()
}
}

Expand Down Expand Up @@ -234,7 +235,7 @@ case class HugoPass(input: PassInput, state: HugoTranslatorState) extends Pass(i
}

private def makeDirectoryStructure(
inputPath: Path,
inputPath: Option[Path],
log: Logger,
options: HugoCommand.Options,
commonOptions: CommonOptions
Expand Down
Loading

0 comments on commit 5c5c98e

Please sign in to comment.