1
1
defmodule ExDoc.Formatter.MARKDOWN do
2
2
@ moduledoc false
3
3
4
- @ assets_dir "MD/assets"
5
- alias __MODULE__ . { Assets , Templates }
4
+ alias __MODULE__ . { Templates }
6
5
alias ExDoc.Formatter.HTML
7
6
alias ExDoc.Utils
8
7
@@ -15,7 +14,7 @@ defmodule ExDoc.Formatter.MARKDOWN do
15
14
16
15
config = normalize_config ( config )
17
16
File . rm_rf! ( config . output )
18
- File . mkdir_p! ( Path . join ( config . output , "MD" ) )
17
+ File . mkdir_p! ( config . output )
19
18
20
19
project_nodes =
21
20
HTML . render_all ( project_nodes , filtered_modules , ".md" , config , highlight_tag: "samp" )
@@ -51,15 +50,15 @@ defmodule ExDoc.Formatter.MARKDOWN do
51
50
output =
52
51
config . output
53
52
|> Path . expand ( )
54
- |> Path . join ( "#{ config . project } " )
53
+ |> Path . join ( "markdown " )
55
54
56
55
% { config | output: output }
57
56
end
58
57
59
58
defp normalize_output ( output ) do
60
59
output
61
60
|> String . replace ( ~r/ \r \n |\r |\n / , "\n " )
62
- |> String . replace ( ~r/ \n {2 ,}/ , "\n " )
61
+ |> String . replace ( ~r/ \n {3 ,}/ , "\n \n " )
63
62
end
64
63
65
64
defp generate_nav ( config , nodes ) do
@@ -70,25 +69,19 @@ defmodule ExDoc.Formatter.MARKDOWN do
70
69
71
70
content = Templates . nav_template ( config , nodes )
72
71
|> normalize_output ( )
73
- File . write ( "#{ config . output } /MD/ index.md" , content )
72
+ File . write ( "#{ config . output } /index.md" , content )
74
73
end
75
74
76
75
defp generate_extras ( config ) do
77
76
for { _title , extras } <- config . extras do
78
- Enum . each ( extras , fn % { id: id , title: title , title_content: _title_content , source: content } ->
79
- output = "#{ config . output } /MD/#{ id } .md"
80
- content = """
81
- # #{ title }
82
-
83
- #{ content }
84
- """
85
- |> normalize_output ( )
77
+ Enum . each ( extras , fn % { id: id , source: content } ->
78
+ output = "#{ config . output } /#{ id } .md"
86
79
87
80
if File . regular? ( output ) do
88
81
Utils . warn ( "file #{ Path . relative_to_cwd ( output ) } already exists" , [ ] )
89
82
end
90
83
91
- File . write! ( output , content )
84
+ File . write! ( output , normalize_output ( content ) )
92
85
end )
93
86
end
94
87
end
@@ -129,7 +122,7 @@ defmodule ExDoc.Formatter.MARKDOWN do
129
122
defp generate_module_page ( module_node , config ) do
130
123
content = Templates . module_page ( config , module_node )
131
124
|> normalize_output ( )
132
- File . write ( "#{ config . output } /MD/ #{ module_node . id } .md" , content )
125
+ File . write ( "#{ config . output } /#{ module_node . id } .md" , content )
133
126
end
134
127
135
128
end
0 commit comments