Skip to content

Commit aca7558

Browse files
authored
Fix/get deps from target project (#35)
* fix get deps from target project * lazy_doc 0.6.1 * update CI to elixir 1.18 * fix tests elixir 1.18
1 parent e7d006a commit aca7558

7 files changed

Lines changed: 84 additions & 45 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
include:
1717
- pair:
18-
elixir: 1.17.2
18+
elixir: 1.18.3
1919
otp: 27.0.1
2020
lint: lint
2121

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.17.0-otp-27
1+
elixir 1.18.0-otp-27
22
erlang 27.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ provider which is a tuple of three elements `{GithubAi, :codestral, options}`.
1515
``` elixir
1616
def deps do
1717
[
18-
{:lazy_doc, "~> 0.6.0"}
18+
{:lazy_doc, "~> 0.6.1"}
1919
]
2020
end
2121
```
2222

2323
or install it as a single binary
2424

2525
``` bash
26-
mix escript.install hex lazy_doc 0.6.0
26+
mix escript.install hex lazy_doc 0.6.1
2727
```
2828

2929
## Configuration

lib/mix/tasks/lazy_doc.ex

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,21 @@ defmodule Mix.Tasks.LazyDoc do
4646
def write_to_file_formatted(file, compile_path, ast, comments) do
4747
dot_formatter = Application.get_env(:lazy_doc, :file_formatter, ".formatter.exs")
4848

49+
deps_paths =
50+
Path.wildcard("./deps/*/lib")
51+
|> Enum.map(fn path -> String.replace(path, "/lib", "") end)
52+
|> Enum.filter(fn path -> File.dir?(path) end)
53+
|> Enum.map(fn path -> String.split(path, "/") end)
54+
|> Enum.map(fn ["deps", dep] = list ->
55+
{String.to_atom(dep), Path.join(list) |> Path.absname()}
56+
end)
57+
|> Map.new()
58+
4959
{_func, formatter} =
50-
Mix.Tasks.Format.formatter_for_file(file, dot_formatter: dot_formatter)
60+
Mix.Tasks.Format.formatter_for_file(file,
61+
dot_formatter: dot_formatter,
62+
deps_paths: deps_paths
63+
)
5164

5265
line_length = Keyword.get(formatter, :line_length, 98)
5366
locals_without_parens = Keyword.get(formatter, :locals_without_parens, [])

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
defmodule LazyDoc.MixProject do
22
use Mix.Project
33

4-
@version "0.6.0"
4+
@version "0.6.1"
55

66
def project do
77
[
88
app: :lazy_doc,
99
version: @version,
1010
escript: escript(),
11-
elixir: "~> 1.17",
11+
elixir: "~> 1.18",
1212
elixirc_paths: elixirc_paths(Mix.env()),
1313
start_permanent: Mix.env() == :prod,
1414
deps: deps(),

mix.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
1818
"mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"},
1919
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
20-
"nimble_ownership": {:hex, :nimble_ownership, "0.3.2", "d4fa4056ade0ae33b5a9eb64554a1b3779689282e37513260125d2d6b32e4874", [:mix], [], "hexpm", "28b9a9f4094fda1aa8ca72f732ff3223eb54aa3eda4fed9022254de2c152b138"},
2120
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
2221
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
2322
"plug": {:hex, :plug, "1.17.0", "a0832e7af4ae0f4819e0c08dd2e7482364937aea6a8a997a679f2cbb7e026b2e", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f6692046652a69a00a5a21d0b7e11fcf401064839d59d6b8787f23af55b1e6bc"},
2423
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
25-
"req": {:hex, :req, "0.5.9", "09072dcd91a70c58734c4dd4fa878a9b6d36527291152885100ec33a5a07f1d6", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "2f027043003275918f5e79e6a4e57b10cb17161a1ab41c959aa40ecfb2142e5a"},
24+
"req": {:hex, :req, "0.5.10", "a3a063eab8b7510785a467f03d30a8d95f66f5c3d9495be3474b61459c54376c", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "8a604815743f8a2d3b5de0659fa3137fa4b1cffd636ecb69b30b2b9b2c2559be"},
2625
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
2726
}

test/lazy_doc/task_test.exs

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,54 @@ defmodule LazyDoc.TaskTest do
7171
expected_result =
7272
[
7373
{LazyDoc.Example,
74-
{%{
75-
"en" =>
76-
"Documentation for `LazyDoc`.\n\nThis module is an example of autogenerated docs by\nthe task provided.\n"
77-
},
78-
[
79-
{{:function, :func_without_doc, 0}, 31, ["func_without_doc()"],
80-
%{
81-
"en" =>
82-
"Returns a message indicating a greeting.\n\n## Parameters\n\n- None\n## Description\nExecutes a print statement to display \"Hello world\"."
83-
}, %{}},
84-
{{:function, :hello, 0}, 26, ["hello()"],
85-
%{
86-
"en" =>
87-
"Returns the atom :world.\n\n## Parameters\n\n- None\n## Description\nReturns a predefined atom value."
88-
}, %{}},
89-
{{:function, :my_func, 1}, 34, ["my_func(n)"],
90-
%{
91-
"en" =>
92-
"Returns a description based on the input value.\n\n## Parameters\n\n- n - The input number to be described.\n## Description\n Generates a string representation of the input number."
93-
}, %{}},
94-
{{:function, :my_func_2, 1}, 9, ["my_func_2(n)"],
95-
%{
96-
"en" =>
97-
"Returns the string representation of the input number.\n\n## Parameters\n\n- n - an integer value.\n\n## Description\n Returns a string indicating the value of n."
98-
}, %{}}
99-
]}}
74+
{
75+
%{
76+
"en" =>
77+
"Documentation for `LazyDoc`.\n\nThis module is an example of autogenerated docs by\nthe task provided.\n"
78+
},
79+
[
80+
{
81+
{:function, :func_without_doc, 0},
82+
31,
83+
["func_without_doc()"],
84+
%{
85+
"en" =>
86+
"Returns a message indicating a greeting.\n\n## Parameters\n\n- None\n## Description\nExecutes a print statement to display \"Hello world\"."
87+
},
88+
%{source_annos: [{32, 7}]}
89+
},
90+
{
91+
{:function, :hello, 0},
92+
26,
93+
["hello()"],
94+
%{
95+
"en" =>
96+
"Returns the atom :world.\n\n## Parameters\n\n- None\n## Description\nReturns a predefined atom value."
97+
},
98+
%{source_annos: [{27, 7}]}
99+
},
100+
{
101+
{:function, :my_func, 1},
102+
34,
103+
["my_func(n)"],
104+
%{
105+
"en" =>
106+
"Returns a description based on the input value.\n\n## Parameters\n\n- n - The input number to be described.\n## Description\n Generates a string representation of the input number."
107+
},
108+
%{source_annos: [{35, 7}]}
109+
},
110+
{
111+
{:function, :my_func_2, 1},
112+
9,
113+
["my_func_2(n)"],
114+
%{
115+
"en" =>
116+
"Returns the string representation of the input number.\n\n## Parameters\n\n- n - an integer value.\n\n## Description\n Returns a string indicating the value of n."
117+
},
118+
%{source_annos: [{14, 7}]}
119+
}
120+
]
121+
}}
100122
]
101123

102124
assert docs_per_module == expected_result
@@ -106,16 +128,21 @@ defmodule LazyDoc.TaskTest do
106128
expected_result =
107129
[
108130
{LazyDoc.ExampleModule,
109-
{:none,
110-
[
111-
{{:function, :bonjour, 0}, 26, ["bonjour()"], %{"en" => " It says Bonjour\n"}, %{}},
112-
{{:function, :fibs, 1}, 31, ["fibs(n)"], %{"en" => " Hello there\n"}, %{}},
113-
{{:function, :fibs, 2}, 38, ["fibs(n, list)"], :none, %{}},
114-
{{:function, :greet, 0}, 22, ["greet()"], :hidden, %{}},
115-
{{:function, :hello, 1}, 5, ["hello(param)"], :none, %{}},
116-
{{:function, :hello_there, 1}, 16, ["hello_there(i)"], :none, %{}},
117-
{{:function, :hihi, 0}, 10, ["hihi()"], :none, %{}}
118-
]}}
131+
{
132+
:none,
133+
[
134+
{{:function, :bonjour, 0}, 26, ["bonjour()"], %{"en" => " It says Bonjour\n"},
135+
%{source_annos: [{29, 7}]}},
136+
{{:function, :fibs, 1}, 31, ["fibs(n)"], %{"en" => " Hello there\n"},
137+
%{source_annos: [{34, 7}]}},
138+
{{:function, :fibs, 2}, 38, ["fibs(n, list)"], :none, %{source_annos: [{38, 7}]}},
139+
{{:function, :greet, 0}, 22, ["greet()"], :hidden, %{source_annos: [{23, 7}]}},
140+
{{:function, :hello, 1}, 5, ["hello(param)"], :none, %{source_annos: [{5, 7}]}},
141+
{{:function, :hello_there, 1}, 16, ["hello_there(i)"], :none,
142+
%{source_annos: [{16, 7}]}},
143+
{{:function, :hihi, 0}, 10, ["hihi()"], :none, %{source_annos: [{10, 7}]}}
144+
]
145+
}}
119146
]
120147

121148
assert docs_per_module == expected_result

0 commit comments

Comments
 (0)