-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
211 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# The directory Mix will write compiled artifacts to. | ||
/_build/ | ||
|
||
# If you run "mix test --cover", coverage assets end up here. | ||
/cover/ | ||
|
||
# The directory Mix downloads your dependencies sources to. | ||
/deps/ | ||
|
||
# Where third-party dependencies like ExDoc output generated docs. | ||
/doc/ | ||
|
||
# Ignore .fetch files in case you like to edit your project deps locally. | ||
/.fetch | ||
|
||
# If the VM crashes, it generates a dump, let's ignore it too. | ||
erl_crash.dump | ||
|
||
# Also ignore archive artifacts (built via "mix archive.build"). | ||
*.ez | ||
|
||
# Ignore package tarball (built via "mix hex.build"). | ||
zig_doc-*.tar | ||
|
||
# Temporary files, for example, from tests. | ||
/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn foo(value: i32) i32 { | ||
return value + 1; | ||
} | ||
|
||
/// this is the function bar | ||
pub const bar = foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// this is the foo type. | ||
const foo = i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
defmodule Zig.SemaAPI do | ||
@type json :: nil | boolean | number | String.t | [json] | %{optional(String.t) => json} | ||
@callback run_sema(Path.t) :: {:ok, json} | {:error, String.t} | ||
@type json :: nil | boolean | number | String.t() | [json] | %{optional(String.t()) => json} | ||
@callback run_sema(Path.t()) :: {:ok, json} | {:error, String.t()} | ||
end | ||
|
||
Mox.defmock(Zig.SemaMock, for: Zig.SemaAPI) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule ZigDocTest.Documentation.ConstFunctionTest do | ||
use Zig.Doc.Case, async: true | ||
|
||
alias Zig.Doc.Sema | ||
|
||
test "documentation is generated for consts that are functions" do | ||
expect_sema({:ok, Sema.new(functions: [%{name: :bar, return: :i32, args: [:i32]}])}) | ||
|
||
assert %{docs: [function]} = get_module("test/_sources/const_function.zig") | ||
|
||
assert [{:p, [], [" this is the function bar"], %{}}] = function.doc | ||
|
||
# note that we lose the signature because we won't be digging too hard to find | ||
# the rest. | ||
|
||
assert "bar(i32) i32" = function.signature | ||
|
||
assert_code( | ||
""" | ||
bar(i32) :: i32 | ||
""", | ||
function.specs | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule ZigDocTest.Documentation.TypeBasicTest do | ||
use Zig.Doc.Case, async: true | ||
|
||
alias Zig.Doc.Sema | ||
|
||
test "type-level documentation is generated" do | ||
expect_sema({:ok, Sema.new(types: [%{name: :foo, def: :i32}])}) | ||
|
||
assert %{typespecs: [type]} = get_module("test/_sources/type_basic.zig") | ||
|
||
assert [{:p, [], [" this is the foo type."], %{}}] = type.doc | ||
assert "foo" = type.signature | ||
|
||
assert_code( | ||
""" | ||
foo :: i32 | ||
""", | ||
type.spec | ||
) | ||
end | ||
end |