Permalink
Browse files

Update to latest Elixir

  • Loading branch information...
1 parent 402cb1a commit 829b73aac97058ff2c70807240f34125a41f44a5 Rafael Mendonça França committed Mar 25, 2012
View
@@ -1,8 +1,8 @@
defmodule ExDoc do
require Erlang.file, as: F
- def generate_docs(path, formatter // ExDoc::HTMLFormatter) do
- docs = ExDoc::Retriever.get_docs find_files(path)
+ def generate_docs(path, formatter // ExDoc.HTMLFormatter) do
+ docs = ExDoc.Retriever.get_docs find_files(path)
copy_index_files
copy_css_files
copy_image_files
@@ -20,11 +20,11 @@ defmodule ExDoc do
end
defp normalize_path('/' ++ path) do
- List.reverse(path) ++ '*'
+ List.reverse(path) ++ '**/*.beam'
end
defp normalize_path(path) do
- List.reverse(path) ++ '/*'
+ List.reverse(path) ++ '/**/*.beam'
end
defp copy_index_files do
@@ -1,4 +1,4 @@
-defmodule ExDoc::HTMLFormatter do
+defmodule ExDoc.HTMLFormatter do
def format_docs({name,{ moduledoc, docs }}) do
docs = generate_html_for_docs(docs)
moduledoc = generate_html_for_moduledoc(moduledoc)
@@ -37,7 +37,7 @@ defmodule ExDoc::HTMLFormatter do
Enum.map docs, extract_docs(&1)
end
- defp extract_docs({ { name, arity }, _line, type, false }) do
+ defp extract_docs({ { _name, _arity }, _line, type, false }) do
{ type, "" }
end
View
@@ -1,4 +1,4 @@
-defmodule ExDoc::Retriever do
+defmodule ExDoc.Retriever do
def get_docs(files) do
Enum.map files, get_docs_from_file(&1)
end
@@ -7,7 +7,7 @@ defmodule ExDoc::Retriever do
defp get_docs_from_file(file) do
module_name = get_module_name(file)
- module = :"#{module_name}"
+ module = :"__MAIN__.#{module_name}"
moduledoc = module.__info__(:moduledoc)
docs = module.__info__(:docs)
View
@@ -49,5 +49,5 @@ static ErlNifFunc nif_funcs[] =
{"to_html", 1, to_markdown_nif}
};
-ERL_NIF_INIT(::Markdown,nif_funcs,NULL,NULL,NULL,NULL);
+ERL_NIF_INIT(__MAIN__.Markdown,nif_funcs,NULL,NULL,NULL,NULL);
@@ -1,29 +1,29 @@
Code.require_file "../../test_helper", __FILE__
-defmodule ExDoc::HTMLFormatterTest do
- use ExUnit::Case, sync: true
+defmodule ExDoc.HTMLFormatterTest do
+ use ExUnit.Case, sync: true
test "format_docs generate only the module name when there's no more info" do
output_dir = File.expand_path("../../../output", __FILE__)
try do
:file.make_dir(output_dir)
- ExDoc::HTMLFormatter.format_docs({"::XPTOModule", {{1, nil}, []}})
- path = File.expand_path(output_dir <> "/::XPTOModule.html", __FILE__)
+ ExDoc.HTMLFormatter.format_docs({"XPTOModule", {{1, nil}, []}})
+ path = File.expand_path(output_dir <> "/XPTOModule.html", __FILE__)
expected = """
<!DOCTYPE html>
<html>
<head>
- <title>::XPTOModule</title>
+ <title>XPTOModule</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div class="banner">
<span>Elixir v0.9</span>
- <h1>::XPTOModule</h1>
+ <h1>XPTOModule</h1>
</div>
<div id="bodyContent">
<div id="content">
@@ -49,15 +49,15 @@ defmodule ExDoc::HTMLFormatterTest do
<!DOCTYPE html>
<html>
<head>
- <title>::CompiledWithDocs</title>
+ <title>CompiledWithDocs</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div class="banner">
<span>Elixir v0.9</span>
- <h1>::CompiledWithDocs</h1>
+ <h1>CompiledWithDocs</h1>
</div>
<div id="bodyContent">
<div id="content">
@@ -104,10 +104,10 @@ defmodule ExDoc::HTMLFormatterTest do
:file.make_dir(output_dir)
- file = File.expand_path("../../tmp/::CompiledWithDocs.beam", __FILE__)
- [docs] = ExDoc::Retriever.get_docs([file])
- ExDoc::HTMLFormatter.format_docs(docs)
- path = output_dir <> "/::CompiledWithDocs.html"
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithDocs.beam", __FILE__)
+ [docs] = ExDoc.Retriever.get_docs([file])
+ ExDoc.HTMLFormatter.format_docs(docs)
+ path = output_dir <> "/CompiledWithDocs.html"
{ :ok, generated } = :file.read_file(path)
assert_equal expected, generated
after:
@@ -1,35 +1,35 @@
Code.require_file "../../test_helper", __FILE__
-defmodule ExDoc::RetrieverTest do
- use ExUnit::Case
+defmodule ExDoc.RetrieverTest do
+ use ExUnit.Case
- require ExDoc::Retriever, as: R
+ require ExDoc.Retriever, as: R
test "get_docs returns the module name" do
- file = File.expand_path("../../tmp/::CompiledWithDocs.beam", __FILE__)
- assert_match [{ "::CompiledWithDocs", _ }], R.get_docs([file])
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithDocs.beam", __FILE__)
+ assert_match [{ "CompiledWithDocs", _ }], R.get_docs([file])
end
test "get_docs returns the moduledoc info" do
- file = File.expand_path("../../tmp/::CompiledWithDocs.beam", __FILE__)
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithDocs.beam", __FILE__)
[{ _, {moduledoc, _} }] = R.get_docs([file])
assert_match { 1, "moduledoc\n\n\#\# Example\n CompiledWithDocs.example\n" }, moduledoc
end
test "get_docs returns nil if there's no moduledoc info" do
- file = File.expand_path("../../tmp/::CompiledWithoutDocs.beam", __FILE__)
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithoutDocs.beam", __FILE__)
[{ _, {moduledoc, _} }] = R.get_docs([file])
assert_match { _, nil }, moduledoc
end
test "get_docs returns the doc info for each module function" do
- file = File.expand_path("../../tmp/::CompiledWithDocs.beam", __FILE__)
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithDocs.beam", __FILE__)
[{ _, {_, doc} }] = R.get_docs([file])
assert_match [{ {:example, 0}, 10, :def, "Some example"}, { {:"example_1", 0}, 13, :defmacro, "Another example"}], doc
end
test "get_docs returns an empty list if there's no docs info" do
- file = File.expand_path("../../tmp/::CompiledWithoutDocs.beam", __FILE__)
+ file = File.expand_path("../../tmp/__MAIN__/CompiledWithoutDocs.beam", __FILE__)
[{ _, {_, doc} }] = R.get_docs([file])
assert_empty doc
end
View
@@ -1,14 +1,14 @@
Code.require_file "../test_helper", __FILE__
defmodule ExDocTest do
- use ExUnit::Case, sync: true
+ use ExUnit.Case, sync: true
test "generate_docs generates the html file with the documentation" do
output_dir = File.expand_path("../../output", __FILE__)
try do
ExDoc.generate_docs File.expand_path("../tmp", __FILE__)
- path = output_dir <> "/::CompiledWithDocs.html"
+ path = output_dir <> "/CompiledWithDocs.html"
assert :filelib.is_file(path)
after:
:os.cmd('rm -rf #{output_dir}')
@@ -20,7 +20,7 @@ defmodule ExDocTest do
try do
ExDoc.generate_docs "test/tmp"
- path = output_dir <> "/::CompiledWithDocs.html"
+ path = output_dir <> "/CompiledWithDocs.html"
assert :filelib.is_file(path)
after:
:os.cmd('rm -rf #{output_dir}')
@@ -60,25 +60,25 @@ defmodule ExDocTest do
<ul>
<li class='level_0 closed'>
<div class='content'>
- <a href='../::CompiledWithDocs.html' target='docwin'>::CompiledWithDocs</a>
+ <a href='../CompiledWithDocs.html' target='docwin'>CompiledWithDocs</a>
<div class='icon'></div>
</div>
</li>
<li class='level_1 closed'>
<div class='content'>
- <a href='../::CompiledWithDocs.html#example/0' target='docwin'>example/0</a>
+ <a href='../CompiledWithDocs.html#example/0' target='docwin'>example/0</a>
<div class='icon'></div>
</div>
</li>
<li class='level_1 closed'>
<div class='content'>
- <a href='../::CompiledWithDocs.html#example_1/0' target='docwin'>example_1/0</a>
+ <a href='../CompiledWithDocs.html#example_1/0' target='docwin'>example_1/0</a>
<div class='icon'></div>
</div>
</li>
<li class='level_0 closed'>
<div class='content'>
- <a href='../::CompiledWithoutDocs.html' target='docwin'>::CompiledWithoutDocs</a>
+ <a href='../CompiledWithoutDocs.html' target='docwin'>CompiledWithoutDocs</a>
<div class='icon'></div>
</div>
</li>
View
@@ -1,7 +1,7 @@
Code.require_file "../test_helper", __FILE__
defmodule MarkdownTest do
- use ExUnit::Case
+ use ExUnit.Case
test "to_html generate the HTML from the markdown" do
assert_equal "<h1>Test</h1>\n", Markdown.to_html("# Test")

0 comments on commit 829b73a

Please sign in to comment.