Skip to content

Commit

Permalink
I think I get introspectable method arguments...
Browse files Browse the repository at this point in the history
  • Loading branch information
keplersj committed Jun 9, 2016
1 parent c3111bc commit 6443496
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/compiler/crystal/tools/doc/method.cr
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,22 @@ class Crystal::Doc::Method
!@def.args.empty? || @def.block_arg || @def.yields
end

def args_to_json
@def.args.map_with_index do |arg, i|
{
name: arg.external_name,
type: arg.type?.to_s,
default: arg.default_value.to_s,
splat: @def.splat_index == i,
double_splat: @def.double_splat ? true : false,
}
end
end

def to_json(io)
{
name: name,
args: args_to_s,
args: args_to_json,
doc: doc,
abstract: abstract?,
yields: @def.yields,
Expand Down

0 comments on commit 6443496

Please sign in to comment.