From fc5adc6731e609b732867716e1482a924f217821 Mon Sep 17 00:00:00 2001 From: RobertDober Date: Tue, 30 Jun 2020 09:25:18 +0200 Subject: [PATCH 1/3] Preparing ex_doc to switch to EarmarkParser --- CHANGELOG.md | 2 ++ bin/ex_doc | 2 +- lib/ex_doc/markdown.ex | 4 ++-- lib/ex_doc/markdown/earmark.ex | 28 ++++++++++++++-------------- mix.exs | 2 +- mix.lock | 1 + test/ex_doc/autolink_test.exs | 8 ++++---- test/mix/tasks/docs_test.exs | 12 ++++++------ 8 files changed, 31 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9912e4dfc..072e938f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog + * [mix docs] Depend on earmark_parser `~> 1.4.0` + ## v0.22.1 (2020-05-19) * Bug fixes diff --git a/bin/ex_doc b/bin/ex_doc index 083f38021..ce30723d0 100755 --- a/bin/ex_doc +++ b/bin/ex_doc @@ -3,7 +3,7 @@ mix_env = System.get_env()["MIX_ENV"] || "dev" Code.prepend_path Path.expand("../_build/#{mix_env}/lib/nimble_parsec/ebin", __DIR__) Code.prepend_path Path.expand("../_build/#{mix_env}/lib/makeup/ebin", __DIR__) Code.prepend_path Path.expand("../_build/#{mix_env}/lib/makeup_elixir/ebin", __DIR__) -Code.prepend_path Path.expand("../_build/#{mix_env}/lib/earmark/ebin", __DIR__) +Code.prepend_path Path.expand("../_build/#{mix_env}/lib/earmark_parser/ebin", __DIR__) Code.prepend_path Path.expand("../_build/#{mix_env}/lib/ex_doc/ebin", __DIR__) if Code.ensure_loaded?(ExDoc.CLI) do diff --git a/lib/ex_doc/markdown.ex b/lib/ex_doc/markdown.ex index 57b6a9f57..341a17b28 100644 --- a/lib/ex_doc/markdown.ex +++ b/lib/ex_doc/markdown.ex @@ -8,9 +8,9 @@ defmodule ExDoc.Markdown do ExDoc supports the following Markdown parsers out of the box: - * [Earmark](http://github.com/pragdave/earmark) + * [EarmarkParser](http://github.com/robertdober/earmark_parser) - ExDoc uses Earmark by default. + ExDoc uses EarmarkParser by default. """ @doc """ diff --git a/lib/ex_doc/markdown/earmark.ex b/lib/ex_doc/markdown/earmark.ex index 1cf93ab61..af39a4084 100644 --- a/lib/ex_doc/markdown/earmark.ex +++ b/lib/ex_doc/markdown/earmark.ex @@ -1,14 +1,15 @@ defmodule ExDoc.Markdown.Earmark do @moduledoc """ - ExDoc extension for the Earmark MarkDown parser. + ExDoc extension for the EarmarkParseer MarkDown parser. """ @behaviour ExDoc.Markdown @doc """ - Check if the Earmark Markdown parser module is available. + Check if the EarmarkParser Markdown parser module is available. """ def available? do - match?({:ok, _}, Application.ensure_all_started(:earmark)) and Code.ensure_loaded?(Earmark) + match?({:ok, _}, Application.ensure_all_started(:earmark_parser)) and + Code.ensure_loaded?(EarmarkParser) end @doc """ @@ -27,17 +28,16 @@ defmodule ExDoc.Markdown.Earmark do """ @impl true def to_ast(text, opts) do - options = - struct(Earmark.Options, - gfm: Keyword.get(opts, :gfm, true), - line: Keyword.get(opts, :line, 1), - file: Keyword.get(opts, :file, "nofile"), - breaks: Keyword.get(opts, :breaks, false), - smartypants: Keyword.get(opts, :smartypants, false), - pure_links: true - ) - - case Earmark.as_ast(text, options) do + options = [ + gfm: Keyword.get(opts, :gfm, true), + line: Keyword.get(opts, :line, 1), + file: Keyword.get(opts, :file, "nofile"), + breaks: Keyword.get(opts, :breaks, false), + smartypants: Keyword.get(opts, :smartypants, false), + pure_links: true + ] + + case EarmarkParser.as_ast(text, options) do {:ok, ast, messages} -> print_messages(messages, options) fixup(ast) diff --git a/mix.exs b/mix.exs index cd7c87c9a..453b432ca 100644 --- a/mix.exs +++ b/mix.exs @@ -30,7 +30,7 @@ defmodule ExDoc.Mixfile do defp deps do [ - {:earmark, "~> 1.4.0"}, + {:earmark_parser, "~> 1.4.0"}, {:makeup_elixir, "~> 0.14"}, {:excoveralls, "~> 0.3", only: :test}, {:jason, "~> 1.2", only: :test} diff --git a/mix.lock b/mix.lock index ad1888b6d..2f298e7a1 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,7 @@ %{ "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, "earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.8", "1a823aec32df3f9423bdea0dc1fad2c1d4e24c054f60bfce97a49c9a36903794", [:mix], [], "hexpm", "0817aeeec25706700362b4578f58e42b573605a649d350d471364d1ee4e2295d"}, "excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "493daf5a2dd92d022a1c29e7edcc30f1bce1ffe10fb3690fac63889346d3af2f"}, "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "c2790c9f0f7205f4a362512192dee8179097394400e745e4d20bab7226a8eaad"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, diff --git a/test/ex_doc/autolink_test.exs b/test/ex_doc/autolink_test.exs index 03653d01a..4ac1ca8a2 100644 --- a/test/ex_doc/autolink_test.exs +++ b/test/ex_doc/autolink_test.exs @@ -93,8 +93,8 @@ defmodule ExDoc.AutolinkTest do end test "sibling function" do - assert autolink("Earmark.as_ast/2", siblings: [:earmark]) == - ~m"[`Earmark.as_ast/2`](Earmark.html#as_ast/2)" + assert autolink("EarmarkParser.as_ast/2", siblings: [:earmark_parser]) == + ~m"[`EarmarkParser.as_ast/2`](EarmarkParser.html#as_ast/2)" end test "auto-imported function" do @@ -194,8 +194,8 @@ defmodule ExDoc.AutolinkTest do end test "3rd party links" do - assert autolink("Earmark.as_ast/2") == - ~m"[`Earmark.as_ast/2`](https://hexdocs.pm/earmark/Earmark.html#as_ast/2)" + assert autolink("EarmarkParser.as_ast/2") == + ~m"[`EarmarkParser.as_ast/2`](https://hexdocs.pm/earmark_parser/EarmarkParser.html#as_ast/2)" assert_unchanged(":test_module.foo/0") end diff --git a/test/mix/tasks/docs_test.exs b/test/mix/tasks/docs_test.exs index 34c257364..6fe691d53 100644 --- a/test/mix/tasks/docs_test.exs +++ b/test/mix/tasks/docs_test.exs @@ -81,19 +81,19 @@ defmodule Mix.Tasks.DocsTest do {"ex_doc", "dev", [formatter: "epub", deps: deps, source_beam: _, app: _]} ] = run([], app: :ex_doc, docs: []) - assert List.keyfind(deps, Application.app_dir(:earmark), 0) == - {Application.app_dir(:earmark), - "https://hexdocs.pm/earmark/#{Application.spec(:earmark, :vsn)}/"} + assert List.keyfind(deps, Application.app_dir(:earmark_parser), 0) == + {Application.app_dir(:earmark_parser), + "https://hexdocs.pm/earmark_parser/#{Application.spec(:earmark_parser, :vsn)}/"} end test "allows custom dependency paths" do assert [ {"ex_doc", "dev", [formatter: "html", deps: deps, source_beam: _, app: _]}, {"ex_doc", "dev", [formatter: "epub", deps: deps, source_beam: _, app: _]} - ] = run([], app: :ex_doc, docs: [deps: [earmark: "foo"]]) + ] = run([], app: :ex_doc, docs: [deps: [earmark_parser: "foo"]]) - assert List.keyfind(deps, Application.app_dir(:earmark), 0) == - {Application.app_dir(:earmark), "foo"} + assert List.keyfind(deps, Application.app_dir(:earmark_parser), 0) == + {Application.app_dir(:earmark_parser), "foo"} end test "accepts lazy docs" do From 412125548faa0dd3b9920dc7bb3c9deda0b6f987 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Fri, 17 Jul 2020 09:59:01 +0200 Subject: [PATCH 2/3] Update lib/ex_doc/markdown/earmark.ex --- lib/ex_doc/markdown/earmark.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ex_doc/markdown/earmark.ex b/lib/ex_doc/markdown/earmark.ex index af39a4084..26d06ee93 100644 --- a/lib/ex_doc/markdown/earmark.ex +++ b/lib/ex_doc/markdown/earmark.ex @@ -1,6 +1,6 @@ defmodule ExDoc.Markdown.Earmark do @moduledoc """ - ExDoc extension for the EarmarkParseer MarkDown parser. + ExDoc extension for the EarmarkParser Markdown parser. """ @behaviour ExDoc.Markdown From dae6a64bdedb0876864b92272ce765a26c3b2a02 Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Fri, 17 Jul 2020 09:59:17 +0200 Subject: [PATCH 3/3] Update mix.lock --- mix.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/mix.lock b/mix.lock index 2f298e7a1..54de7807b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,5 @@ %{ "certifi": {:hex, :certifi, "2.5.1", "867ce347f7c7d78563450a18a6a28a8090331e77fa02380b4a21962a65d36ee5", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "805abd97539caf89ec6d4732c91e62ba9da0cda51ac462380bbd28ee697a8c42"}, - "earmark": {:hex, :earmark, "1.4.5", "62ffd3bd7722fb7a7b1ecd2419ea0b458c356e7168c1f5d65caf09b4fbdd13c8", [:mix], [], "hexpm", "b7d0e6263d83dc27141a523467799a685965bf8b13b6743413f19a7079843f4f"}, "earmark_parser": {:hex, :earmark_parser, "1.4.8", "1a823aec32df3f9423bdea0dc1fad2c1d4e24c054f60bfce97a49c9a36903794", [:mix], [], "hexpm", "0817aeeec25706700362b4578f58e42b573605a649d350d471364d1ee4e2295d"}, "excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "493daf5a2dd92d022a1c29e7edcc30f1bce1ffe10fb3690fac63889346d3af2f"}, "hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "c2790c9f0f7205f4a362512192dee8179097394400e745e4d20bab7226a8eaad"},