Skip to content

Commit

Permalink
Merge pull request #95 from JamieMair/94-change-the-mujoco-function-d…
Browse files Browse the repository at this point in the history
…ocumentation-to-contain-the-function-signature

Added generator code to make the function docs better for the mj func…
  • Loading branch information
JamieMair authored Dec 6, 2023
2 parents 5cd10b9 + 6202699 commit 11061f8
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 11061f8

Please sign in to comment.