forked from loafle/openapi-generator-original
autodoc retrieves descriptions for delegated methods
This commit is contained in:
@@ -161,15 +161,15 @@ sub _printmethod {
|
||||
my $delegate_to = '';
|
||||
my $via = '';
|
||||
my $on = '';
|
||||
my $doc = '';
|
||||
my $original_pkg = $method->original_package_name;
|
||||
if ($method->can('associated_attribute')) {
|
||||
$delegate_to = $method->delegate_to_method;
|
||||
my $aa = $method->associated_attribute;
|
||||
$on = $aa->{isa};
|
||||
$via = $aa->{name};
|
||||
$original_pkg = "(flattened into $original_pkg from ???)"; # TODO - need to get hold of the role pkg, not the pkg it's flattened onto
|
||||
use Data::Dumper;
|
||||
#print Dumper($aa);
|
||||
$original_pkg = $on;
|
||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||
}
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
@@ -245,6 +245,8 @@ $methodname
|
||||
$on
|
||||
Via: @*()
|
||||
$via
|
||||
Doc: @*
|
||||
$doc
|
||||
Same as: $self->@*->@*()
|
||||
$via, $delegate_to
|
||||
|
||||
@@ -300,7 +302,8 @@ sub _printattr {
|
||||
my $from = $attr->associated_class->name || '';
|
||||
my $reqd = $attr->is_required ? 'yes' : 'no';
|
||||
my $lazy = $attr->is_lazy ? 'yes' : 'no';
|
||||
my $doc = $attr->has_documentation ? 'yes' : 'no';
|
||||
my $has_doc = $attr->has_documentation ? 'yes' : 'no';
|
||||
my $doc = $attr->documentation || '';
|
||||
my $handles = join ', ', sort @{$attr->handles || []};
|
||||
$handles ||= '';
|
||||
|
||||
@@ -326,7 +329,7 @@ Name is isa reqd lazy doc handles
|
||||
.
|
||||
format ATTR =
|
||||
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
$attrname, $is, $tc, $reqd, $lazy, $doc, $handles
|
||||
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
|
||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||
$handles
|
||||
.
|
||||
|
||||
@@ -42,7 +42,7 @@ sub BUILD {
|
||||
# collect the methods callable on each API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my $methods = Class::Inspector->methods($api_class, 'expanded');
|
||||
my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead
|
||||
my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods;
|
||||
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods;
|
||||
}
|
||||
@@ -66,6 +66,7 @@ sub BUILD {
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
documentation => $api_class->class_documentation->{description}, # not populated yet
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -73,7 +74,6 @@ sub BUILD {
|
||||
sub _build_af {
|
||||
my $self = shift;
|
||||
my %args;
|
||||
$args{auth_setup_handler_object} = $self if $self->can('auth_setup_handler');
|
||||
$args{base_url} = $self->base_url if $self->base_url;
|
||||
return WWW::{{moduleName}}::ApiFactory->new(%args);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ sub BUILD {
|
||||
# collect the methods callable on each API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my $methods = Class::Inspector->methods($api_class, 'expanded');
|
||||
my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead
|
||||
my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods;
|
||||
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods;
|
||||
}
|
||||
@@ -66,6 +66,7 @@ sub BUILD {
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
documentation => $api_class->class_documentation->{description}, # not populated yet
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -73,7 +74,6 @@ sub BUILD {
|
||||
sub _build_af {
|
||||
my $self = shift;
|
||||
my %args;
|
||||
$args{auth_setup_handler_object} = $self if $self->can('auth_setup_handler');
|
||||
$args{base_url} = $self->base_url if $self->base_url;
|
||||
return WWW::SwaggerClient::ApiFactory->new(%args);
|
||||
}
|
||||
|
||||
@@ -161,15 +161,15 @@ sub _printmethod {
|
||||
my $delegate_to = '';
|
||||
my $via = '';
|
||||
my $on = '';
|
||||
my $doc = '';
|
||||
my $original_pkg = $method->original_package_name;
|
||||
if ($method->can('associated_attribute')) {
|
||||
$delegate_to = $method->delegate_to_method;
|
||||
my $aa = $method->associated_attribute;
|
||||
$on = $aa->{isa};
|
||||
$via = $aa->{name};
|
||||
$original_pkg = "(flattened into $original_pkg from ???)"; # TODO - need to get hold of the role pkg, not the pkg it's flattened onto
|
||||
use Data::Dumper;
|
||||
#print Dumper($aa);
|
||||
$original_pkg = $on;
|
||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||
}
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
@@ -245,6 +245,8 @@ $methodname
|
||||
$on
|
||||
Via: @*()
|
||||
$via
|
||||
Doc: @*
|
||||
$doc
|
||||
Same as: $self->@*->@*()
|
||||
$via, $delegate_to
|
||||
|
||||
@@ -300,7 +302,8 @@ sub _printattr {
|
||||
my $from = $attr->associated_class->name || '';
|
||||
my $reqd = $attr->is_required ? 'yes' : 'no';
|
||||
my $lazy = $attr->is_lazy ? 'yes' : 'no';
|
||||
my $doc = $attr->has_documentation ? 'yes' : 'no';
|
||||
my $has_doc = $attr->has_documentation ? 'yes' : 'no';
|
||||
my $doc = $attr->documentation || '';
|
||||
my $handles = join ', ', sort @{$attr->handles || []};
|
||||
$handles ||= '';
|
||||
|
||||
@@ -326,7 +329,7 @@ Name is isa reqd lazy doc handles
|
||||
.
|
||||
format ATTR =
|
||||
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
$attrname, $is, $tc, $reqd, $lazy, $doc, $handles
|
||||
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
|
||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||
$handles
|
||||
.
|
||||
|
||||
Reference in New Issue
Block a user