Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for <> (missing formatcode) (#4257)
* Add test for <> (missing formatcode) * Fixup some missing C<> in pod.
- Loading branch information
Showing
20 changed files
with
80 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,6 @@ We're in 9 | |
|
||
method message() | ||
|
||
Returns "<next control exception>" | ||
Returns C<'<next control exception>'>. | ||
|
||
=end pod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,6 @@ C<take>. | |
|
||
method message() | ||
|
||
Returns "<take control exception>". | ||
Returns C<'<take control exception>'>. | ||
|
||
=end pod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,4 @@ incidence. | |
|
||
C<CX::Warn> objects are created when a warning is thrown in any block. | ||
|
||
|
||
=end pod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env raku | ||
|
||
=begin overview | ||
It's possible for users to forget to add a formatting code when | ||
wrapping something in angle brackets: | ||
This was supposed to be <bold>. | ||
This is valid pod, but in practices, these dangling <>'s often indicate an error. | ||
Complain whenever we find them, except for infix:<> and prefix:<> | ||
=end overview | ||
|
||
use Test; | ||
use lib $*PROGRAM.parent(2).child('lib'); | ||
|
||
use Test-Files; | ||
use Pod::Convenience; | ||
|
||
my @files = Test-Files.pods; | ||
|
||
if @files { | ||
plan +@files; | ||
} else { | ||
plan :skip-all<No rakudoc files specified> | ||
} | ||
|
||
sub is-valid-text($node) { | ||
# Should be ok to look at only literal strings that get passed | ||
if $node ~~ Str { | ||
if $node ~~ / $<bracketed>=['<' .*? '>'] / { | ||
return if ~$/<bracketed>.contains("prefix:<" | "infix:<" ); | ||
flunk ~$/<bracketed> ~ " is likely missing a formatting code"; | ||
} | ||
} | ||
|
||
} | ||
|
||
sub walk-content($item) { | ||
if !( | ||
$item ~~ Pod::Block::Code or | ||
$item ~~ Pod::Block::Comment or | ||
$item ~~ Pod::FormattingCode | ||
) { | ||
is-valid-text($item); | ||
next unless $item.can('contents'); | ||
for @($item.contents) -> $child { | ||
walk-content($child); | ||
} | ||
} | ||
} | ||
|
||
# Walk through pod on each file. | ||
for @files -> $file { | ||
my @chunks = extract-pod($file).contents; | ||
|
||
# This emits pass or flunk for each local L<> found. | ||
subtest $file => { | ||
walk-content($_) for @chunks; | ||
} | ||
} |