Skip to content

Commit

Permalink
Consistently refer to mermaid source as 'diagrams', fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Oct 13, 2024
1 parent 3f6b667 commit 6ea265b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions assets/packs/mermaid/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import "./main.css";

mermaid.initialize({ startOnLoad: false });

export function init(ctx, {graph, caption, download}) {
export function init(ctx, {diagram, caption, download}) {
ctx.importCSS("main.css")

function render() {
mermaid.render("graph1", graph).then(({ svg, bindFunctions }) => {
mermaid.render("diagram", diagram).then(({ svg, bindFunctions }) => {
let contents = document.createElement("div");
contents.id = "contents";
ctx.root.appendChild(contents);
Expand Down
8 changes: 4 additions & 4 deletions lib/kino/mermaid.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Kino.Mermaid do
@download_defaults [title: "Diagram", filename: "diagram.svg"]

@doc """
Creates a new kino displaying the given Mermaid graph.
Creates a new kino displaying the given Mermaid diagram.
## Options
Expand All @@ -44,7 +44,7 @@ defmodule Kino.Mermaid do
"""
@spec new(binary(), Keyword.t()) :: t()
def new(graph, options \\ []) do
def new(diagram, options \\ []) do
options = Keyword.validate!(options, caption: false, download: true)

download =
Expand All @@ -61,8 +61,8 @@ defmodule Kino.Mermaid do

caption = Keyword.fetch!(options, :caption)

Kino.JS.new(__MODULE__, %{graph: graph, caption: caption, download: download},
export: fn graph -> {"mermaid", graph} end
Kino.JS.new(__MODULE__, %{diagram: diagram, caption: caption, download: download},
export: fn diagram -> {"mermaid", diagram} end
)
end
end
6 changes: 3 additions & 3 deletions lib/kino/shorts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ defmodule Kino.Shorts do
def text(text), do: Kino.Text.new(text)

@doc ~S'''
Renders Mermaid graphs.
Renders Mermaid diagrams.
It is a wrapper around `Kino.Mermaid.new/1`.
Expand All @@ -178,8 +178,8 @@ defmodule Kino.Shorts do
C-->D;
""")
'''
@spec mermaid(String.t()) :: Kino.Mermaid.t()
def mermaid(mermaid), do: Kino.Mermaid.new(mermaid)
@spec mermaid(String.t(), Keyword.t()) :: Kino.Mermaid.t()
def mermaid(diagram, options \\ []), do: Kino.Mermaid.new(diagram, options)

@doc """
A placeholder for static outputs that can be dynamically updated.
Expand Down
2 changes: 1 addition & 1 deletion test/kino/process_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ defmodule Kino.ProcessTest do
send(Kino.JS.DataStore, {:connect, self(), %{origin: "client:#{inspect(self())}", ref: ref}})
assert_receive {:connect_reply, data, %{ref: ^ref}}

data
data.diagram
end

defp supervision_tree_with_ets_table do
Expand Down

0 comments on commit 6ea265b

Please sign in to comment.