Skip to content

Commit

Permalink
Added generator code to make the function docs better for the mj func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
JamieMair committed Dec 6, 2023
1 parent 5cd10b9 commit 6202699
Show file tree
Hide file tree
Showing 3 changed files with 646 additions and 3 deletions.
7 changes: 6 additions & 1 deletion gen/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ function write_content_files(destination_dir, module_content)
fn_sig = def.args[1]
fn_name = string(fn_sig.args[1])
if haskey(function_mapping, fn_name)
documented_fn = Expr(:macrocall, :(Core.var"@doc"), LineNumberNode(1), function_mapping[fn_name].doc, def)
doc_description = function_mapping[fn_name].doc
arg_list = join(string.(fn_sig.args[2:end]), ", ")
new_docs = """\t$(fn_name)($(arg_list))
$(doc_description)"""
documented_fn = Expr(:macrocall, :(Core.var"@doc"), LineNumberNode(1), new_docs, def)
push!(function_block_args, documented_fn)
else
push!(function_block_args, def)
Expand Down
6 changes: 4 additions & 2 deletions gen/parsing/function_constraints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ end
function create_wrapped_docstring(fn_name, fn_body, argument_infos)
# original_fn = getproperty(LibMuJoCo, Symbol(fn_name))
original_documentation = string(eval(:(@doc LibMuJoCo.$(Symbol(fn_name)))))

io = IOBuffer()

write(io, "\"\"\"\n")
Expand All @@ -447,7 +447,9 @@ function create_wrapped_docstring(fn_name, fn_body, argument_infos)
write(io, join(map(x->x.identifier, argument_infos), ", "))
write(io, ")\n\n")

println(io, original_documentation)
for line in split(original_documentation, "\n")[5:end]
println(io, line)
end

write_argument_doc_description!(io, argument_infos)

Expand Down
Loading

0 comments on commit 6202699

Please sign in to comment.