| 1 | =begin comment | ||
| 2 | |||
| 3 | QueryBuilderApi | ||
| 4 | |||
| 5 | Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/. | ||
| 6 | |||
| 7 | OpenAPI spec version: 1.1.8 | ||
| 8 | Contact: support@activedbsoft.com | ||
| 9 | Generated by: https://github.com/swagger-api/swagger-codegen.git | ||
| 10 | |||
| 11 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 12 | you may not use this file except in compliance with the License. | ||
| 13 | You may obtain a copy of the License at | ||
| 14 | |||
| 15 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 16 | |||
| 17 | Unless required by applicable law or agreed to in writing, software | ||
| 18 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 19 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 20 | See the License for the specific language governing permissions and | ||
| 21 | limitations under the License. | ||
| 22 | |||
| 23 | =end comment | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | # | ||
| 28 | # NOTE: This class is auto generated by the swagger code generator program. | ||
| 29 | # Do not edit the class manually. | ||
| 30 | # Ref: https://github.com/swagger-api/swagger-codegen | ||
| 31 | # | ||
| 32 | package SQL::QueryBuilder::WebApi::Role::AutoDoc; | ||
| 33 | use List::MoreUtils qw(uniq); | ||
| 34 | |||
| 35 | use Moose::Role; | ||
| 36 | |||
| 37 | sub autodoc { | ||
| 38 | my ($self, $how) = @_; | ||
| 39 | |||
| 40 | die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/; | ||
| 41 | |||
| 42 | $self->_printisa($how); | ||
| 43 | $self->_printmethods($how); | ||
| 44 | $self->_printattrs($how); | ||
| 45 | print "\n"; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub _printisa { | ||
| 49 | my ($self, $how) = @_; | ||
| 50 | my $meta = $self->meta; | ||
| 51 | |||
| 52 | my $myclass = ref $self; | ||
| 53 | |||
| 54 | my $super = join ', ', $meta->superclasses; | ||
| 55 | my @roles = $meta->calculate_all_roles; | ||
| 56 | #shift(@roles) if @roles > 1; # if > 1, the first is a composite, the rest are the roles | ||
| 57 | |||
| 58 | my $isa = join ', ', grep {$_ ne $myclass} $meta->linearized_isa; | ||
| 59 | my $sub = join ', ', $meta->subclasses; | ||
| 60 | my $dsub = join ', ', $meta->direct_subclasses; | ||
| 61 | |||
| 62 | my $app_name = $self->version_info->{app_name}; | ||
| 63 | my $app_version = $self->version_info->{app_version}; | ||
| 64 | my $generated_date = $self->version_info->{generated_date}; | ||
| 65 | my $generator_class = $self->version_info->{generator_class}; | ||
| 66 | |||
| 67 | $~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT'; | ||
| 68 | write; | ||
| 69 | |||
| 70 | my ($rolepkg, $role_reqs); | ||
| 71 | |||
| 72 | foreach my $role (@roles) { | ||
| 73 | $rolepkg = $role->{package} || next; # some are anonymous, or something | ||
| 74 | next if $rolepkg eq 'SQL::QueryBuilder::WebApi::Role::AutoDoc'; | ||
| 75 | $role_reqs = join ', ', keys %{$role->{required_methods}}; | ||
| 76 | $role_reqs ||= ''; | ||
| 77 | $~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES'; | ||
| 78 | write; | ||
| 79 | } | ||
| 80 | |||
| 81 | if ($how eq 'pod') { | ||
| 82 | $~ = 'ROLES_POD_CLOSE'; | ||
| 83 | write; | ||
| 84 | } | ||
| 85 | |||
| 86 | # ----- format specs ----- | ||
| 87 | format INHERIT = | ||
| 88 | |||
| 89 | @* - | ||
| 90 | $myclass | ||
| 91 | ISA: @* | ||
| 92 | $isa | ||
| 93 | Direct subclasses: @* | ||
| 94 | $dsub | ||
| 95 | All subclasses: @* | ||
| 96 | $sub | ||
| 97 | |||
| 98 | Target API: @* @* | ||
| 99 | $app_name, $app_version | ||
| 100 | Generated on: @* | ||
| 101 | $generated_date | ||
| 102 | Generator class: @* | ||
| 103 | $generator_class | ||
| 104 | |||
| 105 | . | ||
| 106 | format ROLES = | ||
| 107 | Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ | ||
| 108 | $rolepkg | ||
| 109 | requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~ | ||
| 110 | $role_reqs | ||
| 111 | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~ | ||
| 112 | $role_reqs | ||
| 113 | . | ||
| 114 | |||
| 115 | format INHERIT_POD = | ||
| 116 | =head1 NAME | ||
| 117 | |||
| 118 | @* | ||
| 119 | $myclass | ||
| 120 | |||
| 121 | =head1 VERSION | ||
| 122 | |||
| 123 | =head2 @* version: @* | ||
| 124 | $app_name, $app_version | ||
| 125 | |||
| 126 | Automatically generated by the Perl Swagger Codegen project: | ||
| 127 | |||
| 128 | =over 4 | ||
| 129 | |||
| 130 | =item Build date: @* | ||
| 131 | $generated_date | ||
| 132 | |||
| 133 | =item Build package: @* | ||
| 134 | $generator_class | ||
| 135 | |||
| 136 | =item Codegen version: | ||
| 137 | |||
| 138 | |||
| 139 | =back | ||
| 140 | |||
| 141 | =head1 INHERITANCE | ||
| 142 | |||
| 143 | =head2 Base class(es) | ||
| 144 | |||
| 145 | @* | ||
| 146 | $isa | ||
| 147 | |||
| 148 | =head2 Direct subclasses | ||
| 149 | |||
| 150 | @* | ||
| 151 | $dsub | ||
| 152 | |||
| 153 | =head2 All subclasses | ||
| 154 | |||
| 155 | @* | ||
| 156 | $sub | ||
| 157 | |||
| 158 | |||
| 159 | =head1 COMPOSITION | ||
| 160 | |||
| 161 | @* composes the following roles: | ||
| 162 | $myclass | ||
| 163 | |||
| 164 | |||
| 165 | . | ||
| 166 | format ROLES_POD = | ||
| 167 | =head2 C<@*> | ||
| 168 | $rolepkg | ||
| 169 | |||
| 170 | Requires: | ||
| 171 | |||
| 172 | @* | ||
| 173 | $role_reqs | ||
| 174 | |||
| 175 | . | ||
| 176 | format ROLES_POD_CLOSE = | ||
| 177 | |||
| 178 | |||
| 179 | . | ||
| 180 | # ----- / format specs ----- | ||
| 181 | } | ||
| 182 | |||
| 183 | sub _printmethods { | ||
| 184 | my ($self, $how) = @_; | ||
| 185 | |||
| 186 | if ($how eq 'narrow') { | ||
| 187 | print <<HEAD; | ||
| 188 | METHODS | ||
| 189 | ------- | ||
| 190 | HEAD | ||
| 191 | } | ||
| 192 | elsif ($how eq 'wide') { | ||
| 193 | $~ = 'METHODHEAD'; | ||
| 194 | write; | ||
| 195 | } | ||
| 196 | elsif ($how eq 'pod') { | ||
| 197 | $~ = 'METHODHEAD_POD'; | ||
| 198 | write; | ||
| 199 | } | ||
| 200 | else { | ||
| 201 | die "Don't know how to print '$how'"; | ||
| 202 | } | ||
| 203 | |||
| 204 | $self->_printmethod($_, $how) for uniq sort $self->meta->get_all_method_names; #$self->meta->get_method_list, | ||
| 205 | |||
| 206 | if ($how eq 'pod') { | ||
| 207 | $~ = 'METHOD_POD_CLOSE'; | ||
| 208 | write; | ||
| 209 | } | ||
| 210 | |||
| 211 | |||
| 212 | } | ||
| 213 | |||
| 214 | sub _printmethod { | ||
| 215 | my ($self, $methodname, $how) = @_; | ||
| 216 | return if $methodname =~ /^_/; | ||
| 217 | return if $self->meta->has_attribute($methodname); | ||
| 218 | my %internal = map {$_ => 1} qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY | ||
| 219 | DOES isa BUILDALL does VERSION dump | ||
| 220 | ); | ||
| 221 | return if $internal{$methodname}; | ||
| 222 | my $method = $self->meta->get_method($methodname) or return; # symbols imported into namespaces i.e. not known by Moose | ||
| 223 | |||
| 224 | return if $method->original_package_name eq __PACKAGE__; | ||
| 225 | |||
| 226 | my $delegate_to = ''; | ||
| 227 | my $via = ''; | ||
| 228 | my $on = ''; | ||
| 229 | my $doc = ''; | ||
| 230 | my $original_pkg = $method->original_package_name; | ||
| 231 | if ($method->can('associated_attribute')) { | ||
| 232 | $delegate_to = $method->delegate_to_method; | ||
| 233 | my $aa = $method->associated_attribute; | ||
| 234 | $on = $aa->{isa}; | ||
| 235 | $via = $aa->{name}; | ||
| 236 | $original_pkg = $on; | ||
| 237 | $doc = $original_pkg->method_documentation->{$delegate_to}->{summary}; | ||
| 238 | } | ||
| 239 | else { | ||
| 240 | $doc = $method->documentation; | ||
| 241 | } | ||
| 242 | |||
| 243 | if ($how eq 'narrow') { | ||
| 244 | $~ = 'METHOD_NARROW'; | ||
| 245 | write; | ||
| 246 | } | ||
| 247 | elsif ($how eq 'pod' and $delegate_to) { | ||
| 248 | $~ = 'METHOD_POD_DELEGATED'; | ||
| 249 | write; | ||
| 250 | } | ||
| 251 | elsif ($how eq 'pod') { | ||
| 252 | $~ = 'METHOD_POD'; | ||
| 253 | write; | ||
| 254 | } | ||
| 255 | else { | ||
| 256 | $~ = 'METHOD'; | ||
| 257 | write; | ||
| 258 | } | ||
| 259 | |||
| 260 | # ----- format specs ----- | ||
| 261 | format METHODHEAD = | ||
| 262 | |||
| 263 | METHODS | ||
| 264 | ------- | ||
| 265 | Name delegates to on via | ||
| 266 | =========================================================================================================================================================================== | ||
| 267 | . | ||
| 268 | format METHOD = | ||
| 269 | @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<... | ||
| 270 | $methodname, $delegate_to, $on, $via | ||
| 271 | . | ||
| 272 | |||
| 273 | format METHOD_NARROW = | ||
| 274 | @* | ||
| 275 | $methodname | ||
| 276 | original pkg: @* | ||
| 277 | $original_pkg | ||
| 278 | delegates to: @* | ||
| 279 | $delegate_to | ||
| 280 | on: @* | ||
| 281 | $on | ||
| 282 | via: @* | ||
| 283 | $via | ||
| 284 | |||
| 285 | . | ||
| 286 | |||
| 287 | format METHODHEAD_POD = | ||
| 288 | |||
| 289 | =head1 METHODS | ||
| 290 | |||
| 291 | . | ||
| 292 | |||
| 293 | format METHOD_POD = | ||
| 294 | |||
| 295 | =head2 C<@*()> | ||
| 296 | $methodname | ||
| 297 | |||
| 298 | Defined in: @* | ||
| 299 | $original_pkg | ||
| 300 | |||
| 301 | |||
| 302 | . | ||
| 303 | format METHOD_POD_DELEGATED = | ||
| 304 | |||
| 305 | =head2 C<@*()> | ||
| 306 | $methodname | ||
| 307 | |||
| 308 | Defined in: @* | ||
| 309 | $original_pkg | ||
| 310 | Delegates to: @*() | ||
| 311 | $delegate_to | ||
| 312 | On: @* | ||
| 313 | $on | ||
| 314 | Via: @*() | ||
| 315 | $via | ||
| 316 | Doc: @* | ||
| 317 | $doc | ||
| 318 | Same as: $self->@*->@*() | ||
| 319 | $via, $delegate_to | ||
| 320 | |||
| 321 | . | ||
| 322 | format METHOD_POD_CLOSE = | ||
| 323 | |||
| 324 | . | ||
| 325 | # ----- / format specs ----- | ||
| 326 | } | ||
| 327 | |||
| 328 | sub _printattrs { | ||
| 329 | my ($self, $how) = @_; | ||
| 330 | |||
| 331 | if ($how eq 'narrow') { | ||
| 332 | print <<HEAD; | ||
| 333 | ATTRIBUTES | ||
| 334 | ---------- | ||
| 335 | HEAD | ||
| 336 | } | ||
| 337 | elsif ($how eq 'wide') { | ||
| 338 | $~ = 'ATTRHEAD'; | ||
| 339 | write; | ||
| 340 | } | ||
| 341 | elsif ($how eq 'pod') { | ||
| 342 | $~ = 'ATTRHEAD_POD'; | ||
| 343 | write; | ||
| 344 | } | ||
| 345 | else { | ||
| 346 | die "Don't know how to print attributes '$how'"; | ||
| 347 | } | ||
| 348 | |||
| 349 | $self->_printattr($_, $how) for sort $self->meta->get_attribute_list; | ||
| 350 | |||
| 351 | if ($how eq 'pod') { | ||
| 352 | $~ = 'ATTR_POD_CLOSE'; | ||
| 353 | write; | ||
| 354 | } | ||
| 355 | } | ||
| 356 | |||
| 357 | sub _printattr { | ||
| 358 | my ($self, $attrname, $how) = @_; | ||
| 359 | return if $attrname =~ /^_/; | ||
| 360 | my $attr = $self->meta->get_attribute($attrname) or die "No attr for $attrname"; | ||
| 361 | |||
| 362 | my $is; | ||
| 363 | $is = 'rw' if $attr->get_read_method && $attr->get_write_method; | ||
| 364 | $is = 'ro' if $attr->get_read_method && ! $attr->get_write_method; | ||
| 365 | $is = 'wo' if $attr->get_write_method && ! $attr->get_read_method; | ||
| 366 | $is = '--' if ! $attr->get_write_method && ! $attr->get_read_method; | ||
| 367 | $is or die "No \$is for $attrname"; | ||
| 368 | |||
| 369 | my $tc = $attr->type_constraint || ''; | ||
| 370 | my $from = $attr->associated_class->name || ''; | ||
| 371 | my $reqd = $attr->is_required ? 'yes' : 'no'; | ||
| 372 | my $lazy = $attr->is_lazy ? 'yes' : 'no'; | ||
| 373 | my $has_doc = $attr->has_documentation ? 'yes' : 'no'; # *_api attributes will never have doc, but other attributes might have | ||
| 374 | my $doc = $attr->documentation || ''; | ||
| 375 | my $handles = join ', ', sort @{$attr->handles || []}; | ||
| 376 | $handles ||= ''; | ||
| 377 | |||
| 378 | if ($how eq 'narrow') { | ||
| 379 | $~ = 'ATTR_NARROW'; | ||
| 380 | } | ||
| 381 | elsif ($how eq 'pod') { | ||
| 382 | $~ = 'ATTR_POD'; | ||
| 383 | } | ||
| 384 | else { | ||
| 385 | $~ = 'ATTR'; | ||
| 386 | } | ||
| 387 | |||
| 388 | write; | ||
| 389 | |||
| 390 | # ----- format specs ----- | ||
| 391 | format ATTRHEAD = | ||
| 392 | |||
| 393 | ATTRIBUTES | ||
| 394 | ---------- | ||
| 395 | Name is isa reqd lazy doc handles | ||
| 396 | ============================================================================================================== | ||
| 397 | . | ||
| 398 | format ATTR = | ||
| 399 | @<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 400 | $attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles | ||
| 401 | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~ | ||
| 402 | $handles | ||
| 403 | . | ||
| 404 | |||
| 405 | format ATTR_NARROW = | ||
| 406 | @* | ||
| 407 | $attrname | ||
| 408 | is: @* | ||
| 409 | $is | ||
| 410 | isa: @* | ||
| 411 | $tc | ||
| 412 | reqd: @* | ||
| 413 | $reqd | ||
| 414 | lazy: @* | ||
| 415 | $lazy | ||
| 416 | doc: @* | ||
| 417 | $doc | ||
| 418 | handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 419 | $handles | ||
| 420 | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~ | ||
| 421 | $handles | ||
| 422 | |||
| 423 | . | ||
| 424 | format ATTRHEAD_POD = | ||
| 425 | =head1 ATTRIBUTES | ||
| 426 | |||
| 427 | . | ||
| 428 | format ATTR_POD = | ||
| 429 | |||
| 430 | =head2 C<@*> | ||
| 431 | $attrname | ||
| 432 | |||
| 433 | is: @* | ||
| 434 | $is | ||
| 435 | isa: @* | ||
| 436 | $tc | ||
| 437 | reqd: @* | ||
| 438 | $reqd | ||
| 439 | lazy: @* | ||
| 440 | $lazy | ||
| 441 | doc: @* | ||
| 442 | $doc | ||
| 443 | handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
| 444 | $handles | ||
| 445 | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~ | ||
| 446 | $handles | ||
| 447 | |||
| 448 | . | ||
| 449 | format ATTR_POD_CLOSE = | ||
| 450 | |||
| 451 | |||
| 452 | . | ||
| 453 | # ----- / format specs ----- | ||
| 454 | } | ||
| 455 | |||
| 456 | |||
| 457 | |||
| 458 | 1; |