Skip to content

Commit 682cf4d

Browse files
committed
Refactor markdown output paths in tests to align with updated directory structure
1 parent 46a4bdd commit 682cf4d

File tree

2 files changed

+53
-57
lines changed

2 files changed

+53
-57
lines changed

lib/ex_doc/formatter/markdown.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ defmodule ExDoc.Formatter.Markdown do
3939
end
4040

4141
defp normalize_config(config) do
42-
output =
43-
config.output
44-
|> Path.expand()
45-
|> Path.join("markdown")
46-
42+
output = Path.expand(config.output)
4743
%{config | output: output}
4844
end
4945

test/ex_doc/formatter/markdown_test.exs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,34 @@ defmodule ExDoc.Formatter.MarkdownTest do
2424

2525
test "generates Markdown files in the default directory", %{tmp_dir: tmp_dir} = context do
2626
generate_docs(doc_config(context))
27-
assert File.regular?(tmp_dir <> "/markdown/index.md")
28-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithDocs.md")
27+
assert File.regular?(tmp_dir <> "/index.md")
28+
assert File.regular?(tmp_dir <> "/CompiledWithDocs.md")
2929
end
3030

3131
test "generates headers for module pages", %{tmp_dir: tmp_dir} = context do
3232
generate_docs(doc_config(context, main: "RandomError"))
3333

34-
content = File.read!(tmp_dir <> "/markdown/RandomError.md")
34+
content = File.read!(tmp_dir <> "/RandomError.md")
3535
assert content =~ ~r{^# RandomError}m
3636
assert content =~ ~r{\(Elixir v1\.0\.1\)}
3737
end
3838

3939
test "generates all listing files", %{tmp_dir: tmp_dir} = context do
4040
generate_docs(doc_config(context))
4141

42-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithDocs.md")
43-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithDocs.Nested.md")
44-
assert File.regular?(tmp_dir <> "/markdown/CustomBehaviourOne.md")
45-
assert File.regular?(tmp_dir <> "/markdown/CustomBehaviourTwo.md")
46-
assert File.regular?(tmp_dir <> "/markdown/RandomError.md")
47-
assert File.regular?(tmp_dir <> "/markdown/CustomProtocol.md")
48-
assert File.regular?(tmp_dir <> "/markdown/Mix.Tasks.TaskWithDocs.md")
42+
assert File.regular?(tmp_dir <> "/CompiledWithDocs.md")
43+
assert File.regular?(tmp_dir <> "/CompiledWithDocs.Nested.md")
44+
assert File.regular?(tmp_dir <> "/CustomBehaviourOne.md")
45+
assert File.regular?(tmp_dir <> "/CustomBehaviourTwo.md")
46+
assert File.regular?(tmp_dir <> "/RandomError.md")
47+
assert File.regular?(tmp_dir <> "/CustomProtocol.md")
48+
assert File.regular?(tmp_dir <> "/Mix.Tasks.TaskWithDocs.md")
4949
end
5050

5151
test "generates the index file", %{tmp_dir: tmp_dir} = context do
5252
generate_docs(doc_config(context))
5353

54-
content = File.read!(tmp_dir <> "/markdown/index.md")
54+
content = File.read!(tmp_dir <> "/index.md")
5555
assert content =~ ~r{^# Elixir v1\.0\.1 - Documentation - Table of Contents$}m
5656
assert content =~ ~r{## Modules}
5757
assert content =~ ~r{- \[CompiledWithDocs\]\(CompiledWithDocs\.md\)}
@@ -61,7 +61,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
6161
test "generates module with proper structure", %{tmp_dir: tmp_dir} = context do
6262
generate_docs(doc_config(context))
6363

64-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
64+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
6565

6666
# Header
6767
assert content =~ ~r{^# CompiledWithDocs \(Elixir v1\.0\.1\)}m
@@ -81,7 +81,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
8181
test "generates functions correctly", %{tmp_dir: tmp_dir} = context do
8282
generate_docs(doc_config(context))
8383

84-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
84+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
8585

8686
# Function in ToC
8787
assert content =~ ~r{####.*\[`example\(foo, bar}
@@ -116,14 +116,14 @@ defmodule ExDoc.Formatter.MarkdownTest do
116116

117117
generate_docs(config)
118118

119-
refute File.exists?(tmp_dir <> "/markdown/elixir.md")
119+
refute File.exists?(tmp_dir <> "/elixir.md")
120120
end
121121
end
122122

123123
test "generates LLM index file", %{tmp_dir: tmp_dir} = context do
124124
generate_docs(doc_config(context))
125125

126-
content = File.read!(tmp_dir <> "/markdown/llms.txt")
126+
content = File.read!(tmp_dir <> "/llms.txt")
127127

128128
assert content =~ ~r{# Elixir 1\.0\.1}
129129
assert content =~ ~r{Elixir documentation index for Large Language Models}
@@ -134,7 +134,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
134134
describe "markdown output validation" do
135135
test "generates proper markdown syntax", %{tmp_dir: tmp_dir} = context do
136136
generate_docs(doc_config(context))
137-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
137+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
138138

139139
assert content =~ ~r/^# CompiledWithDocs/m
140140
assert content =~ ~r/^## Table of Contents/m
@@ -147,7 +147,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
147147

148148
test "handles complex documentation elements", %{tmp_dir: tmp_dir} = context do
149149
generate_docs(doc_config(context))
150-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
150+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
151151

152152
assert content =~ ~r/#### `example\(foo, bar.*\)`/
153153
assert content =~ ~r/> This function is deprecated\./
@@ -156,7 +156,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
156156

157157
test "generates valid navigation structure", %{tmp_dir: tmp_dir} = context do
158158
generate_docs(doc_config(context))
159-
content = File.read!(tmp_dir <> "/markdown/index.md")
159+
content = File.read!(tmp_dir <> "/index.md")
160160

161161
assert content =~ ~r/^# Elixir v1\.0\.1 - Documentation - Table of Contents$/m
162162
assert content =~ ~r/- \[CompiledWithDocs\]\(CompiledWithDocs\.md\)/
@@ -168,7 +168,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
168168

169169
test "generates proper markdown escaping", %{tmp_dir: tmp_dir} = context do
170170
generate_docs(doc_config(context))
171-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
171+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
172172

173173
assert content =~ ~r/&lt;|&gt;|&amp;/ || !String.contains?(content, "<script>")
174174
assert content =~ ~r/#### `[^`]+`/
@@ -181,30 +181,30 @@ defmodule ExDoc.Formatter.MarkdownTest do
181181
config = doc_config(context, output: custom_output)
182182
generate_docs(config)
183183

184-
assert File.regular?(custom_output <> "/markdown/index.md")
185-
assert File.regular?(custom_output <> "/markdown/CompiledWithDocs.md")
186-
refute File.exists?(tmp_dir <> "/markdown/index.md")
184+
assert File.regular?(custom_output <> "/index.md")
185+
assert File.regular?(custom_output <> "/CompiledWithDocs.md")
186+
refute File.exists?(tmp_dir <> "/index.md")
187187
end
188188

189189
test "handles custom project name and version", %{tmp_dir: tmp_dir} = context do
190190
config = doc_config(context, project: "MyProject", version: "2.0.0")
191191
generate_docs(config)
192192

193-
content = File.read!(tmp_dir <> "/markdown/index.md")
193+
content = File.read!(tmp_dir <> "/index.md")
194194
assert content =~ ~r/# MyProject v2\.0\.0 - Documentation/
195195

196-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
196+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
197197
assert content =~ ~r/\(MyProject v2\.0\.0\)/
198-
llm_content = File.read!(tmp_dir <> "/markdown/llms.txt")
198+
llm_content = File.read!(tmp_dir <> "/llms.txt")
199199
assert llm_content =~ ~r/# MyProject 2\.0\.0/
200200
end
201201

202202
test "processes source_url configuration", %{tmp_dir: tmp_dir} = context do
203203
config = doc_config(context, source_url: "https://github.com/example/project")
204204
generate_docs(config)
205205

206-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithDocs.md")
207-
assert File.regular?(tmp_dir <> "/markdown/index.md")
206+
assert File.regular?(tmp_dir <> "/CompiledWithDocs.md")
207+
assert File.regular?(tmp_dir <> "/index.md")
208208
end
209209
end
210210

@@ -213,10 +213,10 @@ defmodule ExDoc.Formatter.MarkdownTest do
213213
config = doc_config(context, extras: ["test/fixtures/README.md"])
214214
generate_docs(config)
215215

216-
assert File.regular?(tmp_dir <> "/markdown/index.md")
217-
nav_content = File.read!(tmp_dir <> "/markdown/index.md")
216+
assert File.regular?(tmp_dir <> "/index.md")
217+
nav_content = File.read!(tmp_dir <> "/index.md")
218218
assert nav_content =~ ~r/## Modules/
219-
assert File.regular?(tmp_dir <> "/markdown/llms.txt")
219+
assert File.regular?(tmp_dir <> "/llms.txt")
220220
end
221221

222222
test "handles multiple extras with custom names", %{tmp_dir: tmp_dir} = context do
@@ -230,15 +230,15 @@ defmodule ExDoc.Formatter.MarkdownTest do
230230

231231
generate_docs(config)
232232

233-
assert File.regular?(tmp_dir <> "/markdown/index.md")
234-
assert File.regular?(tmp_dir <> "/markdown/llms.txt")
233+
assert File.regular?(tmp_dir <> "/index.md")
234+
assert File.regular?(tmp_dir <> "/llms.txt")
235235
end
236236

237237
test "processes plain text files as extras", %{tmp_dir: tmp_dir} = context do
238238
config = doc_config(context, extras: ["test/fixtures/PlainText.txt"])
239239
generate_docs(config)
240240

241-
assert File.regular?(tmp_dir <> "/markdown/index.md")
241+
assert File.regular?(tmp_dir <> "/index.md")
242242
end
243243

244244
test "handles extras with custom titles", %{tmp_dir: tmp_dir} = context do
@@ -251,8 +251,8 @@ defmodule ExDoc.Formatter.MarkdownTest do
251251

252252
generate_docs(config)
253253

254-
assert File.regular?(tmp_dir <> "/markdown/index.md")
255-
assert File.regular?(tmp_dir <> "/markdown/llms.txt")
254+
assert File.regular?(tmp_dir <> "/index.md")
255+
assert File.regular?(tmp_dir <> "/llms.txt")
256256
end
257257

258258
test "ignores external url extras", %{tmp_dir: tmp_dir} = context do
@@ -266,45 +266,45 @@ defmodule ExDoc.Formatter.MarkdownTest do
266266

267267
generate_docs(config)
268268

269-
refute File.exists?(tmp_dir <> "/markdown/elixir.md")
270-
assert File.regular?(tmp_dir <> "/markdown/index.md")
269+
refute File.exists?(tmp_dir <> "/elixir.md")
270+
assert File.regular?(tmp_dir <> "/index.md")
271271
end
272272
end
273273

274274
describe "error scenarios" do
275275
test "handles modules with no documentation gracefully", %{tmp_dir: tmp_dir} = context do
276276
generate_docs(doc_config(context))
277277

278-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithoutDocs.md")
278+
assert File.regular?(tmp_dir <> "/CompiledWithoutDocs.md")
279279

280-
content = File.read!(tmp_dir <> "/markdown/CompiledWithoutDocs.md")
280+
content = File.read!(tmp_dir <> "/CompiledWithoutDocs.md")
281281
assert content =~ ~r/^# CompiledWithoutDocs/
282282
end
283283

284284
test "handles missing source beam directory", %{tmp_dir: tmp_dir} = context do
285285
config = doc_config(context, source_beam: "nonexistent/path")
286286

287287
generate_docs(config)
288-
assert File.regular?(tmp_dir <> "/markdown/index.md")
288+
assert File.regular?(tmp_dir <> "/index.md")
289289
end
290290

291291
test "handles empty extras list", %{tmp_dir: tmp_dir} = context do
292292
config = doc_config(context, extras: [])
293293
generate_docs(config)
294294

295-
nav_content = File.read!(tmp_dir <> "/markdown/index.md")
295+
nav_content = File.read!(tmp_dir <> "/index.md")
296296
refute nav_content =~ ~r/## Guides/
297297

298-
llm_content = File.read!(tmp_dir <> "/markdown/llms.txt")
298+
llm_content = File.read!(tmp_dir <> "/llms.txt")
299299
refute llm_content =~ ~r/## Guides/
300300
end
301301

302302
test "handles special characters in module names", %{tmp_dir: tmp_dir} = context do
303303
generate_docs(doc_config(context))
304304

305-
assert File.regular?(tmp_dir <> "/markdown/CompiledWithDocs.Nested.md")
305+
assert File.regular?(tmp_dir <> "/CompiledWithDocs.Nested.md")
306306

307-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.Nested.md")
307+
content = File.read!(tmp_dir <> "/CompiledWithDocs.Nested.md")
308308
assert content =~ ~r/^# CompiledWithDocs\.Nested/
309309
end
310310
end
@@ -314,7 +314,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
314314
config = doc_config(context, extras: ["test/fixtures/README.md"])
315315
generate_docs(config)
316316

317-
content = File.read!(tmp_dir <> "/markdown/llms.txt")
317+
content = File.read!(tmp_dir <> "/llms.txt")
318318

319319
assert content =~ ~r/# Elixir 1\.0\.1/
320320
assert content =~ ~r/documentation index for Large Language Models/
@@ -331,15 +331,15 @@ defmodule ExDoc.Formatter.MarkdownTest do
331331
config = doc_config(context, source_beam: "test/fixtures/beam_no_tasks")
332332
generate_docs(config)
333333

334-
content = File.read!(tmp_dir <> "/markdown/llms.txt")
334+
content = File.read!(tmp_dir <> "/llms.txt")
335335

336336
assert content =~ ~r/## Modules/
337337
end
338338

339339
test "truncates long descriptions in llm index", %{tmp_dir: tmp_dir} = context do
340340
generate_docs(doc_config(context))
341341

342-
content = File.read!(tmp_dir <> "/markdown/llms.txt")
342+
content = File.read!(tmp_dir <> "/llms.txt")
343343

344344
lines = String.split(content, "\n")
345345
module_lines = Enum.filter(lines, &String.starts_with?(&1, "- **"))
@@ -354,14 +354,14 @@ defmodule ExDoc.Formatter.MarkdownTest do
354354
test "generates proper internal links", %{tmp_dir: tmp_dir} = context do
355355
generate_docs(doc_config(context))
356356

357-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
357+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
358358

359359
assert content =~ ~r/\[`[^`]+`\]\(#[^)]+\)/
360360
end
361361

362362
test "handles function anchors correctly", %{tmp_dir: tmp_dir} = context do
363363
generate_docs(doc_config(context))
364-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
364+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
365365

366366
assert content =~ ~r/<a id="[^"]+"><\/a>/
367367

@@ -379,7 +379,7 @@ defmodule ExDoc.Formatter.MarkdownTest do
379379
describe "output normalization" do
380380
test "normalizes line endings consistently", %{tmp_dir: tmp_dir} = context do
381381
generate_docs(doc_config(context))
382-
content = File.read!(tmp_dir <> "/markdown/CompiledWithDocs.md")
382+
content = File.read!(tmp_dir <> "/CompiledWithDocs.md")
383383

384384
refute String.contains?(content, "\r\n")
385385
refute String.contains?(content, "\r")
@@ -391,8 +391,8 @@ defmodule ExDoc.Formatter.MarkdownTest do
391391
generate_docs(doc_config(context))
392392

393393
files = [
394-
tmp_dir <> "/markdown/index.md",
395-
tmp_dir <> "/markdown/CompiledWithDocs.md"
394+
tmp_dir <> "/index.md",
395+
tmp_dir <> "/CompiledWithDocs.md"
396396
]
397397

398398
for file <- files do

0 commit comments

Comments
 (0)