From 4190d1a587b3c055105fa991667ecb2b6808e0ce Mon Sep 17 00:00:00 2001 From: Nick Stanchenko Date: Wed, 10 Jul 2024 19:59:10 +0100 Subject: [PATCH] Make ImagePath visible in minimal example (close #18) --- docs/GettingStarted.md | 26 ++++++++++++++++++++++++-- docs/Guide.md | 29 +++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index b45596a..257b3e1 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -26,14 +26,28 @@ $ sbt demo You can depend on the library by adding these lines to your `build.sbt`: +```mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +``` + + + + ```scala -// JVM libraryDependencies += "io.github.stanch" %% "reftree" % "@VERSION@" +``` -// Scala.js + + + +```scala libraryDependencies += "io.github.stanch" %%% "reftree" % "@VERSION@" ``` + + + ## Minimal example ```scala mdoc:invisible @@ -44,7 +58,13 @@ val ImagePath = "site-gen/target/mdoc/images" import reftree.render.{Renderer, RenderingOptions} import reftree.diagram.Diagram import java.nio.file.Paths +``` + +```scala +val ImagePath = "images" +``` +```scala mdoc:silent val renderer = Renderer( renderingOptions = RenderingOptions(density = 100), directory = Paths.get(ImagePath, "overview") @@ -56,6 +76,8 @@ case class Person(firstName: String, age: Int) Diagram.sourceCodeCaption(Person("Bob", 42)).render("example") ``` +This generates `images/overview/example.png` with the following image: + ![bob](images/overview/example.png) For more details, please refer to the [guide](Guide.md). diff --git a/docs/Guide.md b/docs/Guide.md index 202d8af..540138a 100644 --- a/docs/Guide.md +++ b/docs/Guide.md @@ -53,17 +53,29 @@ implicit def treeInstance: ToRefTree[Tree] = ToRefTree[Tree] { tree => To render diagrams and animations, you will need a `Renderer`. -**For JVM:** +```mdx-code-block +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +``` ```scala mdoc:invisible val ImagePath = "site-gen/target/mdoc/images" ``` + + + ```scala mdoc:silent import reftree.render._ import reftree.diagram._ import java.nio.file.Paths +``` +```scala +val ImagePath = "images" +``` + +```scala mdoc:silent val renderer = Renderer( renderingOptions = RenderingOptions(density = 75), directory = Paths.get(ImagePath, "guide") @@ -74,7 +86,8 @@ You can also pass a `format` parameter as a String to the `Renderer` constructor to specify the format you require. The default is `png`. You can specify any file type supported by `dot -T`. -**For Scala.js:** + + ```scala import reftree.render._ @@ -85,9 +98,13 @@ val renderer = Renderer( ) ``` + + + There are two ways to use renderers: -**JVM** + + ```scala mdoc:silent import scala.collection.immutable.Queue @@ -100,7 +117,8 @@ import renderer._ Diagram(Queue(1)).render("queue") ``` -**Scala.js** + + ```scala import org.scalajs.dom @@ -113,6 +131,9 @@ import renderer._ Diagram(List(1)).render(dom.document.getElementById("diagram")) ``` + + + You can set various options, for example: ```scala mdoc:silent