@@ -133,15 +133,15 @@ function tryrst(md, remove_decl)
133
133
return Markdown. rst (md)
134
134
catch e
135
135
warn (" Error converting docstring:" )
136
- # display(md)
136
+ # display(md)
137
137
println (e)
138
138
return
139
139
end
140
140
end
141
141
142
142
torst (md,remove_decl) = isrst (md) ? flatten (md). content[1 ]. code : tryrst (md, remove_decl)
143
143
144
- function split_decl_rst (md, decl )
144
+ function split_decl_rst (md)
145
145
if isrst (md)
146
146
rst_text = flatten (md). content[1 ]. code
147
147
ls = split (rst_text, " \n " )
@@ -158,14 +158,17 @@ function split_decl_rst(md, decl)
158
158
end
159
159
return decl, join (ls[body_start: end ], " \n " )
160
160
end
161
- return decl, rst_text
162
161
else
163
162
if isa (md. content[1 ], Markdown. Code) && md. content[1 ]. language == " "
164
- decl = " .. function:: " * replace (shift! (md. content). code, " \n " ,
163
+ sigs = shift! (md. content)
164
+ decl = " .. function:: " * replace (sigs. code, " \n " ,
165
165
" \n " )
166
+ body = Markdown. rst (md)
167
+ unshift! (md. content, sigs)
168
+ return decl, body
166
169
end
167
- return decl, Markdown. rst (md)
168
170
end
171
+ return " " , " "
169
172
end
170
173
171
174
# Disable by default since it is hard to eliminate false positives
@@ -239,17 +242,19 @@ function translate(file)
239
242
end
240
243
end
241
244
doc = nothing
245
+ decl = nothing
246
+ body = nothing
242
247
for mdoc in getdoc (mod, funcname)
243
- trst = tryrst (mdoc, false )
244
- trst != = nothing || continue
245
- if contains ( replace (trst, r" [ \n ][ \n ]+ " , " " ) ,
246
- " " * replace (full, r" [\n ][\n ]+" , " " ))
248
+ mdecl, mbody = split_decl_rst (mdoc)
249
+ if contains ( replace (mdecl, r" [ \n ][ \n ]+ " , " " ),
250
+ replace (" .. function:: " * full ,
251
+ r" [\n ][\n ]+" , " " ))
247
252
if doc != nothing
248
253
error (" duplicate $full $l " )
249
254
end
250
255
doc = mdoc
251
- else
252
- # @show trst full
256
+ decl = mdecl
257
+ body = mbody
253
258
end
254
259
end
255
260
if doc == nothing || torst (doc, false ) == nothing
@@ -262,7 +267,6 @@ function translate(file)
262
267
delete! (all_docs, doc)
263
268
doccing = true
264
269
start_func_doc (full)
265
- decl, body = split_decl_rst (doc, l)
266
270
println (io, decl)
267
271
println (io)
268
272
println (io, " .. Docstring generated from Julia source\n " )
0 commit comments