@@ -26,6 +26,17 @@ if @files {
26
26
plan : skip-all<No rakudoc files specified >
27
27
}
28
28
29
+ sub render-node ($ node ) {
30
+ my $ type = $ node . contents. join (' ' );
31
+ my $ result = $ node . type ~ ' <' ~ $ type ;
32
+ if $ node . type eq ' L' {
33
+ $ result ~ = ' |' ~ $ node . meta
34
+ }
35
+ $ result ~ = ' >' ;
36
+
37
+ $ result ;
38
+ }
39
+
29
40
sub is-valid-type ($ node , $ parent ) {
30
41
# only care about I<>, C<>, L<>, etc.
31
42
return unless $ node ~~ Pod ::FormattingCode;
@@ -34,25 +45,29 @@ sub is-valid-type($node, $parent) {
34
45
my $ type = $ node . contents. join (' ' ). subst (' ::' ,' /' , : g);
35
46
return unless " doc/Type/$ type .rakudoc" . IO . f ;
36
47
48
+ # Might be nested but we only report on the innermost here.
37
49
if $ node . type ne ' C' {
38
- flunk $ node . type ~ ' < ' ~ $ type ~ " > should be L<C<$ type >|/type/$ type >" ;
50
+ flunk " { render- node( $ node ) } should be L<C<$ type >|/type/$ type >" ;
39
51
return ;
40
52
}
41
53
54
+ # Probably in a paragraph
42
55
if $ parent === Nil or ! ($ parent ~~ Pod ::FormattingCode) {
43
- flunk $ node . type ~ ' < ' ~ $ type ~ " > should be L<C<$ type >|/type/$ type > - bad parent class: { $ parent .^ name } " ;
56
+ flunk " { render-node( $ node ) } should be L<C<$ type >|/type/$ type >" ;
44
57
return ;
45
58
}
46
59
60
+ # Wrapped, but not in an L<>
47
61
if $ parent . type ne ' L' {
48
- flunk $ parent . type ~ ' <C< ' ~ $ type ~ " > > should be L<C<$ type >|/type/$ type > - bad parent FormattingCode" ;
62
+ flunk " $ parent .type< { render-node( $ node ) } > should be L<C<$ type >|/type/$ type > - bad parent FormattingCode" ;
49
63
return ;
50
64
} elsif $ parent . meta ne " /type/$ type" {
51
- flunk ' L<C<' ~ $ type ~ ' |' ~ $ parent . meta~ " >> should be L<C<$ type >|/type/$ type > - bad link" ;
65
+ # Wrapped in an L<> but wrong URL
66
+ flunk " L<{ render-node($ node )} |$ parent .meta> should be L<C<$ type >|/type/$ type > - bad link" ;
52
67
} else {
68
+ # \o/
53
69
pass " $ type reference correctly formatted." ;
54
70
}
55
-
56
71
}
57
72
58
73
sub walk-content ($ item , $ parent ) {
@@ -64,6 +79,7 @@ sub walk-content($item, $parent) {
64
79
}
65
80
}
66
81
82
+ # Walk through pod on each file.
67
83
for @ files -> $ file {
68
84
my @ chunks = extract-pod($ file ). contents;
69
85
0 commit comments