MDOM/Token/Comment.pm

filter: Statementstmt 92.3% 12 / 13 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 82.6% 19 / 23 SCAR 7.1
CC
2
Cov
80%
line
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« MDOM/Util.pm ↑ Summary MDOM/Directive.pm »
1 package MDOM::Token::Comment;
2  
3 =pod
4  
5 =head1 NAME
6  
7 MDOM::Token::Comment - A comment in Makefile source code
8  
9 =head1 INHERITANCE
10  
11 MDOM::Token::Comment
12 isa MDOM::Token
13 isa MDOM::Element
14  
15 =head1 SYNOPSIS
16  
17 # This is a MDOM::Token::Comment
18  
19 foo: bar # So is this one
20 echo 'hello'
21  
22 =head1 DESCRIPTION
23  
24 In MDOM, comments are represented by C<MDOM::Token::Comment> objects.
25  
26 These come in two flavours, line comment and inline comments.
27  
28 A C<line comment> is a comment that stands on its own line. These comments
29 hold their own newline and whitespace (both leading and trailing) as part
30 of the one C<MDOM::Token::Comment> object.
31  
32 An inline comment is a comment that appears after some code, and
33 continues to the end of the line. This does B<not> include whitespace,
34 and the terminating newlines is considered a separate
35 L<MDOM::Token::Whitespace> token.
36  
37 This is largely a convenience, simplifying a lot of normal code relating
38 to the common things people do with comments.
39  
40 Most commonly, it means when you C<prune> or C<delete> a comment, a line
41 comment disappears taking the entire line with it, and an inline comment
42 is removed from the inside of the line, allowing the newline to drop
43 back onto the end of the code, as you would expect.
44  
45 It also means you can move comments around in blocks much more easily.
46  
47 For now, this is a suitably handy way to do things. However, I do reserve
48 the right to change my mind on this one if it gets dangerously
49 anachronistic somewhere down the line.
50  
51 =head1 METHODS
52  
53 Only very limited methods are available, beyond those provided by our
54 parent L<MDOM::Token> and L<MDOM::Element> classes.
55  
56 =cut
57  
58 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 18 ▶use base 'MDOM::Token';
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 18 ▶use vars qw{$VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
62 BEGIN {
63 18 ▶ $VERSION = '0.006';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 }
65  
66 ### XS -> MDOM/XS.xs:_MDOM_Token_Comment__significant 0.900+
67 14 ▶sub significant { '' }
Subroutine significant: called CC=1 SCAR=0.0
Pod documented
68  
69 =pod
70  
71 =head2 line
72  
73 The C<line> accessor returns true if the C<MDOM::Token::Comment> is a
74 line comment, or false if it is an inline comment.
75  
76 =cut
77  
78 sub line {
79 # Entire line comments have a newline at the end
80 0 ▶ $_[0]->{content} =~ /\n$/ ? 1 : 0;
Subroutine line: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{'content'} =~ /\n$/ ? : 0 0 0
81 }
82  
83 18 1;
84  
85 =pod
86  
87 =head1 SUPPORT
88  
89 See the L<support section|MDOM/SUPPORT> in the main module.
90  
91 =head1 AUTHOR
92  
93 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
94  
95 =head1 COPYRIGHT
96  
97 Copyright 2001 - 2006 Adam Kennedy.
98  
99 This program is free software; you can redistribute
100 it and/or modify it under the same terms as Perl itself.
101  
102 The full text of the license can be found in the
103 LICENSE file included with this module.
104  
105 =cut
« MDOM/Util.pm ↑ Summary MDOM/Directive.pm »