/usr/share/perl5/Data/Stag/PerlWriter.pm is in libdata-stag-perl 0.11-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | package Data::Stag::PerlWriter;
=head1 NAME
Data::Stag::PerlWriter - writes stag events into perl POD documentation
=head1 SYNOPSIS
=cut
=head1 DESCRIPTION
=head1 PUBLIC METHODS -
=cut
use strict;
use base qw(Data::Stag::Writer Data::Stag::Writer);
use vars qw($VERSION);
$VERSION="0.11";
sub fmtstr {
return 'perl';
}
sub indent_txt {
my $self = shift;
my $stack = $self->stack;
return " " x scalar(@$stack);
}
sub this_line {
my $self = shift;
$self->{_this_line} = shift if @_;
return $self->{_this_line};
}
sub o {
my $self = shift;
my $o = "@_";
my $pre = " ";
if (($self->this_line &&
length($self->this_line) + length($o) >
60) ||
$o =~ /^\[/) {
if ($self->indent_txt) {
$pre = "\n" . $self->indent_txt;
}
else {
#$pre = "'";
}
$self->this_line($pre.$o);
}
else {
if ($o =~ /^\]/) {
$pre = "";
}
$self->this_line($self->this_line . $pre.$o);
}
$self->addtext( $pre.$o );
}
sub start_event {
my $self = shift;
my $ev = shift;
if (!defined($ev)) {
$ev = '';
}
if ($self->{__opened}) {
$self->o(',');
}
else {
$self->{__opened} = 1;
$self->o('[');
}
my $stack = $self->stack;
if ($self->use_color) {
$self->o(color('white'));
$self->o('['.color('red').$ev);
}
else {
$self->o("['$ev'=>");
}
push(@$stack, $ev);
}
sub end_event {
my $self = shift;
my $ev = shift;
my $stack = $self->stack;
my $popped = pop(@$stack);
if ($ev && $popped ne $ev) {
warn("uh oh; $ev ne $popped");
}
if ($self->use_color) {
$self->o(']');
}
else {
$self->o(']');
}
if (!@$stack) {
$self->o("\n");
}
return $ev;
}
sub evbody {
my $self = shift;
my $body = shift;
my $str;
if ($self->use_color) {
if (!defined($body)) {
$str = color('white').'""';
}
elsif ($body eq '0') {
$str = color('white').'"'.color('green').'0'.color('white').'"';
}
else {
$body =~ s/\[/\\\[/g;
$body =~ s/\]/\\\]/g;
$body =~ s/\"/\\\"/g;
$str = color('white').'"'.color('green').$body.color('white').'"';
}
}
else {
$str = perlesc($body);
}
$self->o($str);
return;
}
sub perlesc {
my $w = shift;
return '""' unless defined $w;
return '"0"' if $w eq '0';
$w =~ s/\"/\\\"/g;
return '"'.$w.'"';
}
sub color {
Term::ANSIColor::color(@_);
}
1;
|