Skip to content

Commit

Permalink
markdown test
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Feb 17, 2025
1 parent 4b4bdf7 commit 202fd6f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/BackendMarkdown/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ testDescr PosTest {..} =
step "Parsing & Scoping"
PipelineResult {..} <- snd <$> testRunIO entryPoint upToScopingEntry
let m = _pipelineResult ^. Scoper.resultModule
let opts =
opts =
ProcessJuvixBlocksArgs
{ _processJuvixBlocksArgsConcreteOpts = Concrete.defaultOptions,
_processJuvixBlocksArgsUrlPrefix = _UrlPrefix,
Expand Down
7 changes: 7 additions & 0 deletions tests/positive/Markdown/Lib.juvix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```juvix
module Lib;
axiom L : Type;
type Nat := zero | suc Nat;
```
1 change: 1 addition & 0 deletions tests/positive/Markdown/Package.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import PackageDescription.V2 open;
package : Package :=
defaultPackage@{
name := "markdown";
dependencies := [];
};
14 changes: 5 additions & 9 deletions tests/positive/Markdown/Test.juvix.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ module Test;
Certain blocks can be hidden from the output by adding the `hide` attribute, as shown below.

```juvix hide
import Stdlib.Prelude open;
import Lib open;
```

```juvix
fib : Nat → Nat → Nat → Nat
| zero x1 _ := x1
| (suc n) x1 x2 := fib n x2 (x1 + x2);
fibonacci (n : Nat) : Nat := fib n 0 1;
axiom X : L;
```

The `extract-module-statements` attribute can be used to display only the statements contained in a module in the output.
Expand All @@ -43,7 +39,7 @@ end;
Commands like `typecheck` and `compile` can be used with Juvix Markdown files.

```juvix
main : IO := readLn (printNatLn << fibonacci << stringToNat);
main : Nat := zero;
```

Other code blocks are not touched, e.g:
Expand Down Expand Up @@ -90,7 +86,7 @@ We also use other markup for documentation such as:

```juvix
module move-to-left;
import Stdlib.Data.Nat open;
import Lib open;

add (n : Nat) : Nat -> Nat
| zero := n
Expand All @@ -102,7 +98,7 @@ We also use other markup for documentation such as:

```juvix
module example-add;
import Stdlib.Data.Nat open;
import Lib open;
add : Nat -> Nat -> Nat
| n zero := n
| n (suc m) := suc (add n m);
Expand Down
5 changes: 5 additions & 0 deletions tests/positive/Markdown/markdown/Dir.Nested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Nested

<pre class="highlight"><code class="juvix"><pre class="src-content"><span class="ju-keyword">module</span> <span id="Dir.Nested"><span class="annot"><a href="Dir.Nested.html#Dir.Nested" class="ju-code-link ju-module"><span class="annot"><a href="Dir.Nested.html#Dir.Nested" class="ju-code-link ju-module"><span class="ju-module"><span class="ju-module">Dir.Nested</span></span></a></span></a></span></span><span class="ju-delimiter">;</span><br/></pre></code></pre>

<pre class="highlight"><code class="juvix"><pre class="src-content"><span class="ju-keyword">axiom</span> <span id="Hi"><span class="annot"><a href="Dir.Nested.html#Hi" class="ju-code-link ju-axiom"><span class="annot"><a href="Dir.Nested.html#Hi" class="ju-code-link ju-axiom"><span class="ju-axiom">Hi</span></a></span></a></span></span> <span class="ju-keyword">:</span> <span class="ju-keyword">Type</span><span class="ju-delimiter">;</span></pre></code></pre>
8 changes: 4 additions & 4 deletions tests/positive/Markdown/markdown/Test.md

Large diffs are not rendered by default.

49 changes: 38 additions & 11 deletions tests/smoke/Commands/markdown.smoke.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
working-directory: ./../../positive/Markdown
working-directory: ./../../positive

tests:
- name: markdown-help-theme
Expand All @@ -19,9 +19,8 @@ tests:
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp Test.juvix.md $temp
cp -r Markdown/* $temp
cd $temp
juvix init
juvix --log-level error markdown Test.juvix.md --stdout
stdout:
contains:
Expand All @@ -35,9 +34,8 @@ tests:
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp Test.juvix.md $temp
cp -r Markdown/* $temp
cd $temp
juvix init
juvix --log-level error markdown Test.juvix.md --output-dir=OUT
[ -d OUT ]
[ -f OUT/Test.md ]
Expand All @@ -51,9 +49,8 @@ tests:
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp Test.juvix.md $temp
cp -r Markdown/* $temp
cd $temp
juvix init
juvix --log-level error markdown Test.juvix.md --prefix-id="XYZ"
cat markdown/Test.md
stdout:
Expand All @@ -68,9 +65,8 @@ tests:
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp Test.juvix.md $temp
cp -r Markdown/* $temp
cd $temp
touch juvix.yaml
juvix --log-level error markdown Test.juvix.md --no-path --stdout
stdout:
matches: |
Expand All @@ -84,11 +80,42 @@ tests:
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp Test.juvix.md $temp
cp -r Markdown/* $temp
cd $temp
touch juvix.yaml
juvix --log-level error markdown Test.juvix.md --no-path --prefix-url Y --prefix-id X --stdout
stdout:
matches: |
.*href="Y#XTest:[0-9]+".*
exit-status: 0

- name: markdown-folder-structure
command:
shell:
- bash
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp -r Markdown/* $temp
cd $temp
juvix markdown --folder-structure --log-level error
cd markdown
[ -f Test.md ]
[ -f Dir/Nested.md ]
stdout: ''
exit-status: 0

- name: markdown-flat-structure
command:
shell:
- bash
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
cp -r Markdown/* $temp
cd $temp
juvix markdown --folder-structure --log-level error
cd markdown
[ -f Test.md ]
[ -f Dir.Nested.md ]
stdout: ''
exit-status: 0

0 comments on commit 202fd6f

Please sign in to comment.