| 567 | impl(with_params, with_docs, with_visibility) |
| 568 | |
| 569 | def static_method(): |
| 570 | def impl(with_visibility): |
| 571 | if with_visibility: |
| 572 | visibility_capture = '$visibility:vis' |
| 573 | visibility_expansion = '$visibility' |
| 574 | else: |
| 575 | visibility_capture = '' |
| 576 | visibility_expansion = 'pub' |
| 577 | |
| 578 | generate_case( |
| 579 | '$(#[doc=$doc:expr])* @staticmethod %s def $name:ident ($($p:tt)*) -> $res_type:ty { $( $body:tt )* }' % (visibility_capture,), |
| 580 | new_impl=''' |
| 581 | $crate::py_argparse_parse_plist!{ |
| 582 | py_class_impl_item { $class, $py, %s, $name() $res_type; { $($body)* } } |
| 583 | ($($p)*) |
| 584 | } |
| 585 | ''' % (visibility_expansion,), |
| 586 | new_members=[('$name', ''' |
| 587 | $crate::py_argparse_parse_plist!{ |
| 588 | py_class_static_method {$py, $class::$name, { |
| 589 | concat!($($doc, "\\n"),*) |
| 590 | } } |
| 591 | ($($p)*) |
| 592 | } |
| 593 | ''')]) |
| 594 | |
| 595 | for with_visibility in (False, True): |
| 596 | impl(with_visibility) |
| 597 | |
| 598 | def static_data(): |
| 599 | generate_case('static $name:ident = $init:expr;', |