Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
Write some simple doctests, and eliminate the generated default test

There really isn't much to test here, as any tests beyond "Wow it works"
are just testing the underlying Djot transformer
  • Loading branch information
paradox460 committed Nov 9, 2023
1 parent 5dc9426 commit 45ba0b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
24 changes: 22 additions & 2 deletions lib/djot.ex
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
defmodule Djot do
@moduledoc """
Transform a Djot string input to HTML output.
Transform a Djot string input to HTML output.
No sanitization is performed, the document comes directly from the Djot transformer.
No sanitization is performed, the document comes directly from the Djot transformer.
"""

alias Djot.Native

@doc ~S"""
Converts a Djot document into HTML
Returns a tuple
## Examples
iex> Djot.to_html("Hello World!")
{:ok, "<p>Hello World!</p>\n"}
"""
@spec to_html(String.t()) :: {:ok, String.t()} | {:error, :djot_transform}
def to_html(dj) do
Native.to_html(dj)
end

@doc ~S"""
Converts a Djot document into HTML
Returns the document or throws an error
## Examples
iex> Djot.to_html!("Hello World!")
"<p>Hello World!</p>\n"
"""
@spec to_html!(String.t()) :: String.t()
def to_html!(dj) do
case Native.to_html(dj) do
Expand Down
1 change: 0 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ defmodule Djot.MixProject do
defp deps do
[
{:rustler, "~> 0.30.0"},

{:ex_doc, "~> 0.30.9", only: :dev, runtime: false}
]
end
Expand Down
4 changes: 0 additions & 4 deletions test/djot_test.exs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
defmodule DjotTest do
use ExUnit.Case
doctest Djot

test "greets the world" do
assert Djot.hello() == :world
end
end

0 comments on commit 45ba0b6

Please sign in to comment.