Skip to content

Commit

Permalink
Remove unused --source-root option
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Oct 20, 2021
1 parent 94cf404 commit 1792d12
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 44 deletions.
1 change: 0 additions & 1 deletion lib/ex_doc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ defmodule ExDoc do
output: normalize_output(output),
homepage_url: options[:homepage_url],
proglang: normalize_proglang(proglang),
source_root: options[:source_root] || File.cwd!(),
source_url_pattern: source_url_pattern,
nest_modules_by_prefix: normalize_nest_modules_by_prefix(nest_modules_by_prefix),
groups_for_modules: normalize_groups_for_modules(groups_for_modules)
Expand Down
2 changes: 0 additions & 2 deletions lib/ex_doc/cli.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ defmodule ExDoc.CLI do
l: :logo,
m: :main,
o: :output,
r: :source_root,
u: :source_url,
v: :version
],
Expand Down Expand Up @@ -159,7 +158,6 @@ defmodule ExDoc.CLI do
-m, --main The entry-point page in docs, default: "api-reference"
--package Hex package name
--source-ref Branch/commit/tag used for source link inference, default: "master"
-r, --source-root Path to the source code root, used for generating links, default: "."
-u, --source-url URL to the source code
-o, --output Path to output docs, default: "doc"
-v, --version Print ExDoc version
Expand Down
2 changes: 0 additions & 2 deletions lib/ex_doc/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ defmodule ExDoc.Config do
retriever: ExDoc.Retriever,
source_beam: nil,
source_ref: @default_source_ref,
source_root: nil,
source_url: nil,
source_url_pattern: nil,
title: nil,
Expand Down Expand Up @@ -73,7 +72,6 @@ defmodule ExDoc.Config do
retriever: atom(),
source_beam: nil | String.t(),
source_ref: nil | String.t(),
source_root: nil | String.t(),
source_url: nil | String.t(),
source_url_pattern: nil | String.t(),
title: nil | String.t(),
Expand Down
12 changes: 4 additions & 8 deletions lib/ex_doc/retriever.ex
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,9 @@ defmodule ExDoc.Retriever do
Regex.replace(~r/%{line}/, source_url, to_string(line))
end

defp source_path(module, config) do
source = String.Chars.to_string(module.module_info(:compile)[:source])

if root = config.source_root do
Path.relative_to(source, root)
else
source
end
defp source_path(module, _config) do
module.module_info(:compile)[:source]
|> String.Chars.to_string()
|> Path.relative_to(File.cwd!())
end
end
2 changes: 0 additions & 2 deletions test/ex_doc/cli_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ defmodule ExDoc.CLITest do
--config not_aliased.exs
--output html
--formatter html
--source-root ./
--source-url http://example.com/username/project
--source-ref abcdefg
--main Main
Expand All @@ -71,7 +70,6 @@ defmodule ExDoc.CLITest do
output: "html",
source_beam: "#{@ebin}",
source_ref: "abcdefg",
source_root: "./",
source_url: "http://example.com/username/project"
]
after
Expand Down
1 change: 0 additions & 1 deletion test/ex_doc/formatter/epub/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ defmodule ExDoc.Formatter.EPUB.TemplatesTest do
default = %ExDoc.Config{
project: "Elixir",
version: "1.0.1",
source_root: File.cwd!(),
source_url_pattern: "#{source_url()}/blob/master/%{path}#L%{line}",
homepage_url: homepage_url(),
source_url: source_url(),
Expand Down
1 change: 0 additions & 1 deletion test/ex_doc/formatter/epub_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ defmodule ExDoc.Formatter.EPUBTest do
version: "1.0.1",
formatter: "epub",
output: output_dir(),
source_root: beam_dir(),
source_beam: beam_dir(),
extras: ["test/fixtures/README.md"],
skip_undefined_reference_warnings_on: ["Warnings"]
Expand Down
2 changes: 0 additions & 2 deletions test/ex_doc/formatter/html/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
default = %ExDoc.Config{
project: "Elixir",
version: "1.0.1",
source_root: File.cwd!(),
source_url_pattern: "#{source_url()}/blob/master/%{path}#L%{line}",
homepage_url: homepage_url(),
source_url: source_url(),
Expand Down Expand Up @@ -179,7 +178,6 @@ defmodule ExDoc.Formatter.HTML.TemplatesTest do
config = %ExDoc.Config{
project: "Elixir",
version: "1.0.1",
source_root: File.cwd!(),
main: "hello"
}

Expand Down
4 changes: 1 addition & 3 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ defmodule ExDoc.Formatter.HTMLTest do
formatter: "html",
assets: "test/tmp/html_assets",
output: output_dir(),
source_root: beam_dir(),
source_beam: beam_dir(),
logo: "test/fixtures/elixir.png",
extras: [
Expand Down Expand Up @@ -372,7 +371,7 @@ defmodule ExDoc.Formatter.HTMLTest do
end

test "without any other content" do
generate_docs(doc_config(source_root: "unknown", source_beam: "unknown"))
generate_docs(doc_config(source_beam: "unknown"))

content = read_wildcard!("#{output_dir()}/dist/sidebar_items-*.js")
assert content =~ ~s("modules":[])
Expand All @@ -387,7 +386,6 @@ defmodule ExDoc.Formatter.HTMLTest do
test "containing settext headers while discarding links on header" do
generate_docs(
doc_config(
source_root: "unknown",
source_beam: "unknown",
extras: ["test/fixtures/ExtraPageWithSettextHeader.md"]
)
Expand Down
17 changes: 0 additions & 17 deletions test/ex_doc/retriever_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,6 @@ defmodule ExDoc.RetrieverTest do
Retriever.docs_from_modules([NotAvailable], %ExDoc.Config{})
end
end

test "source_url is relative to source_root", c do
tmp_dir = Path.expand(c.tmp_dir)

elixirc(c, "foo.ex", ~S"""
defmodule Foo do
end
""")

config = %ExDoc.Config{source_url_pattern: "%{path}:%{line}", source_root: nil}
[mod] = Retriever.docs_from_modules([Foo], config)
assert mod.source_url == "#{tmp_dir}/foo.ex:1"

config = %ExDoc.Config{source_url_pattern: "%{path}:%{line}", source_root: tmp_dir}
[mod] = Retriever.docs_from_modules([Foo], config)
assert mod.source_url == "foo.ex:1"
end
end

test "docs_from_dir/2: filter_prefix", c do
Expand Down
5 changes: 0 additions & 5 deletions test/ex_doc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ defmodule ExDocTest do
apps: [:test_app],
formatter: IdentityFormatter,
retriever: IdentityRetriever,
source_root: "root_dir",
source_beam: "beam_dir",
output: &1
]
Expand All @@ -49,7 +48,6 @@ defmodule ExDocTest do
markdown_processor: Sample,
output: "test/tmp/ex_doc",
retriever: IdentityRetriever,
source_root: "root_dir",
source_beam: "beam_dir"
]

Expand All @@ -69,7 +67,6 @@ defmodule ExDocTest do
markdown_processor: {Sample, [foo: :bar]},
output: "test/tmp/ex_doc",
retriever: IdentityRetriever,
source_root: "root_dir",
source_beam: "beam_dir"
]

Expand All @@ -84,7 +81,6 @@ defmodule ExDocTest do
apps: [:test_app],
formatter: IdentityFormatter,
retriever: IdentityRetriever,
source_root: "root_dir",
source_beam: "beam_dir"
]

Expand All @@ -100,7 +96,6 @@ defmodule ExDocTest do
apps: [:test_app],
formatter: "pdf",
retriever: IdentityRetriever,
source_root: "root_dir",
source_beam: "beam_dir"
]

Expand Down

0 comments on commit 1792d12

Please sign in to comment.