Skip to content

Commit ab872b8

Browse files
committed
Mark items as my to prevent namespace pollution
1 parent a3744be commit ab872b8

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

lib/Pod/To/HTML.rakumod

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ use URI::Escape:ver<0.3.8+>:auth<zef:raku-community-modules>; # uri_escape
33
use Template::Mustache:ver<1.2.4+>:auth<zef:raku-community-modules>:api<1.2.0>;
44
use Pod::Load:ver<0.7.2+>:auth<zef:jjmerelo>;
55

6-
class Pod::List is Pod::Block {};
7-
class Pod::DefnList is Pod::Block {};
8-
BEGIN { if ::('Pod::Defn') ~~ Failure { CORE::Pod::<Defn> := class {} } }
6+
my class Pod::List is Pod::Block {};
7+
my class Pod::DefnList is Pod::Block {};
8+
BEGIN { if ::('Pod::Defn') ~~ Failure { CORE::Pod::<Defn> := my class {} } }
99
class Node::To::HTML {...} # UNCOVERABLE
10-
class TOC::Calculator {...} # UNCOVERABLE
10+
my class TOC::Calculator {...} # UNCOVERABLE
1111

12-
role Pod::To::HTML::Renderer { # UNCOVERABLE
12+
my role Pod::To::HTML::Renderer { # UNCOVERABLE
1313
method render(%context) { # UNCOVERABLE
1414
...
1515
}
1616
}
1717

18-
class Pod::To::HTML::Mustache does Pod::To::HTML::Renderer {
18+
my class Pod::To::HTML::Mustache does Pod::To::HTML::Renderer {
1919
has $.template;
2020
has $.main-template-path;
2121

@@ -516,15 +516,15 @@ monitor Node::To::HTML {
516516
}
517517
}
518518

519-
sub pod2html($pod, *%nameds --> Str:D) is export {
519+
my sub pod2html($pod, *%nameds --> Str:D) is export {
520520
Pod::To::HTML.new(|%nameds).render($pod)
521521
}
522522

523-
sub node2html(*@pos, *%nameds --> Str:D) is export {
523+
my sub node2html(*@pos, *%nameds --> Str:D) is export {
524524
Node::To::HTML.new(:renderer(Pod::To::HTML.new)).node2html(|@pos, |%nameds)
525525
}
526526

527-
proto sub render(|) is export {*}
527+
my proto sub render(|) is export {*}
528528
multi sub render(
529529
Any:D $pod,
530530
Str :$title,
@@ -554,30 +554,31 @@ multi sub render(
554554

555555
my $debug := %*ENV<P6DOC_debug> // %*ENV<RAKUDO_DEBUG>;
556556

557-
sub debug(&message) { message() if $debug }
557+
my sub debug(&message) { message() if $debug }
558558

559-
sub escape_html(Str $str --> Str) {
559+
my sub escape_html(Str $str --> Str) {
560560
$str ~~ /<[ & < > " ' {   ]>/ || $str ~~ / ' ' /
561561
?? $str.trans:
562562
[q{&}, q{<}, q{>}, q{"}, q{'}, q{ } ] =>
563563
[q{&amp;}, q{&lt;}, q{&gt;}, q{&quot;}, q{&#39;}, q{&nbsp;}]
564564
!! $str
565565
}
566566

567-
sub unescape_html(Str $str --> Str) {
567+
my sub unescape_html(Str $str --> Str) {
568568
$str.trans:
569569
[rx{'&amp;'}, rx{'&lt;'}, rx{'&gt;'}, rx{'&quot;'}, rx{'&#39;'}] =>
570570
[q{&}, q{<}, q{>}, q{"}, q{'} ]
571571
}
572572

573-
sub escape_id ($id) is export {
573+
my sub escape_id ($id) is export {
574574
$id.trim
575575
.subst(/\s+/, '_', :g)
576576
.subst('"', '&quot;', :g)
577577
.subst('&nbsp;', '_', :g)
578578
.subst('&#39;', "'", :g)
579579
}
580580

581+
my proto sub visit(|) {*}
581582
multi visit(Nil, |a) {
582583
debug {
583584
note colored("visit called for Nil", "bold")
@@ -603,9 +604,9 @@ multi visit($root, :&pre, :&post, :&assemble = -> *% { Nil }) {
603604
# &colored = -> $t, $c { $t };
604605
#}
605606

606-
sub colored($text, $how) { $text }
607+
my sub colored($text, $how) { $text }
607608

608-
sub assemble-list-items(:@content, :$node, *%) {
609+
my sub assemble-list-items(:@content, :$node, *%) {
609610
my @newcont;
610611
my $found-one = False;
611612
my $ever-warn = False;
@@ -675,7 +676,7 @@ sub assemble-list-items(:@content, :$node, *%) {
675676
!! $node
676677
}
677678

678-
sub retrieve-templates($template-path, $main-template-path --> List:D) {
679+
my sub retrieve-templates($template-path, $main-template-path --> List:D) {
679680
sub get-partials($template-path --> Hash:D) {
680681
my $partials-dir = 'partials';
681682
my %partials;
@@ -709,7 +710,7 @@ sub retrieve-templates($template-path, $main-template-path --> List:D) {
709710
$template-file, %partials
710711
}
711712

712-
monitor TOC::Calculator {
713+
my monitor TOC::Calculator {
713714
has $.pod is required;
714715
has int @.levels = 0;
715716

@@ -831,7 +832,7 @@ my sub node2text($node --> Str:D) {
831832
}
832833

833834
# plain, unescaped text
834-
sub node2rawtext($node --> Str:D) is export {
835+
my sub node2rawtext($node --> Str:D) is export {
835836
debug {
836837
note colored("Generic node2rawtext called with ", "red")
837838
~ $node.raku

0 commit comments

Comments
 (0)