| 1 | package Pod::Generated::Attributes; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | use Attribute::Handlers; | ||
| 5 | use Pod::Generated 'add_doc'; | ||
| 6 | our $VERSION = '0.05'; | ||
| 7 | |||
| 8 | sub add_attr_doc { | ||
| 9 | my ($type, $package, $symbol, $referent, $attr, $data, $phase) = @_; | ||
| 10 | |||
| 11 | # Work around an API change in Attribute::Handlers 0.79, shipped with perl | ||
| 12 | # 5.10, where a single scalar value is returned as an array ref when | ||
| 13 | # ATTR(SCALAR) is used. Not in the other ATTR cases though... We can't | ||
| 14 | # just require A::H 0.79 though because as of this writing it only exists | ||
| 15 | # as part of perl 5.10; the most recent standalone distribution on CPAN is | ||
| 16 | # 0.78. | ||
| 17 | $data = $data->[0] if ref($data) eq 'ARRAY' && @$data == 1; | ||
| 18 | add_doc($package, ref($referent), *{$symbol}{NAME}, $type, $data); | ||
| 19 | } | ||
| 20 | no warnings 'redefine'; | ||
| 21 | |||
| 22 | sub UNIVERSAL::Purpose : ATTR { | ||
| 23 | add_attr_doc(purpose => @_); | ||
| 24 | } | ||
| 25 | |||
| 26 | sub UNIVERSAL::Id : ATTR { | ||
| 27 | add_attr_doc(id => @_); | ||
| 28 | } | ||
| 29 | |||
| 30 | sub UNIVERSAL::Author : ATTR { | ||
| 31 | add_attr_doc(author => @_); | ||
| 32 | } | ||
| 33 | |||
| 34 | sub UNIVERSAL::Param : ATTR(CODE) { | ||
| 35 | add_attr_doc(param => @_); | ||
| 36 | } | ||
| 37 | |||
| 38 | sub UNIVERSAL::Returns : ATTR(CODE) { | ||
| 39 | add_attr_doc(returns => @_); | ||
| 40 | } | ||
| 41 | |||
| 42 | sub UNIVERSAL::Throws : ATTR(CODE) { | ||
| 43 | add_attr_doc(throws => @_); | ||
| 44 | } | ||
| 45 | |||
| 46 | sub UNIVERSAL::Example : ATTR { | ||
| 47 | add_attr_doc(example => @_); | ||
| 48 | } | ||
| 49 | |||
| 50 | sub UNIVERSAL::Deprecated : ATTR { | ||
| 51 | add_attr_doc(deprecated => @_); | ||
| 52 | } | ||
| 53 | |||
| 54 | sub UNIVERSAL::Default : ATTR(SCALAR) { | ||
| 55 | add_attr_doc(default => @_); | ||
| 56 | } | ||
| 57 | |||
| 58 | sub UNIVERSAL::Default : ATTR(ARRAY) { | ||
| 59 | add_attr_doc(default => @_); | ||
| 60 | } | ||
| 61 | |||
| 62 | sub UNIVERSAL::Default : ATTR(HASH) { | ||
| 63 | add_attr_doc(default => @_); | ||
| 64 | } | ||
| 65 | 1; | ||
| 66 | __END__ |