Skip to content

Commit 3797588

Browse files
committed
Merge pull request #181 from LLFourn/master
Made headings in control.pod searchable
2 parents 56a4274 + 633bb41 commit 3797588

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

doc/Language/control.pod

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
=SUBTITLE Statements used to control the flow of execution
66
7-
=head2 blocks
7+
=head2 X<blocks|control flow>
88
99
Like many languages, Perl6 uses C<blocks> delimited by C<{> and C<}>
1010
to compartmentalize code. When a block stands alone as a statement,
@@ -48,7 +48,7 @@ You have to watch out for this in most languages anyway to prevent things
4848
from getting accidentally commented out. Many of the examples below may
4949
have unnecessary semicolons for clarity.
5050
51-
=head2 do
51+
=head2 X<do|control flow>
5252
5353
The simplest way to run a block where it cannot be a stand-alone statement
5454
is by writing C<do> before it:
@@ -138,7 +138,7 @@ for it more strongly:
138138
$_ = 1; if 42 -> $a { $_.say; $a.say } ; # says "1" then says "42"
139139
$_ = 1; if 42 { $_.say; $^a.say } ; # says "1" then says "42"
140140
141-
=head3 else/elsif
141+
=head3 X<else/elsif|control flow,else elsif>
142142
143143
A compound conditional may be produced by following an C<if> conditional
144144
with C<else> to provide an alternative block to run when the conditional
@@ -213,7 +213,7 @@ what the C<else> sees, since it was the last one tried:
213213
214214
if False { } elsif 0 { } else -> $a { $a.say } ; # says "0"
215215
216-
=head3 unless
216+
=head3 X<unless|control flow>
217217
218218
When you get sick of typing "if not (X)" you may use C<unless> to invert
219219
the sense of a conditional statement. You cannot use C<else> or C<elsif>
@@ -238,7 +238,7 @@ two differences C<unless> works the same as L<if>:
238238
Implementation note: Currently, Rakudo will say "1 Nil 3 0" for the last
239239
example because it is not caught up to this part of the design yet.
240240
241-
=head3 with, orwith, without
241+
=head3 X<with, orwith, without|control flow,with orwith without>
242242
243243
The C<with> statement is like C<if> but tests for definedness rather than
244244
truth. In addition, it topicalizes on the condition, much like C<given>:
@@ -264,7 +264,7 @@ There are also C<with> and C<without> statement modifiers:
264264
return 42 with $answer;
265265
.throw without $answer;
266266
267-
=head2 for
267+
=head2 X<for|control flow>
268268
269269
The C<for> loop iterates over a list.
270270
@@ -310,7 +310,7 @@ for @cars <-> $_ {...}
310310
311311
=end code
312312
313-
=head2 gather/take
313+
=head2 X<gather/take|control flow,gather take>
314314
315315
C<gather> is a statement or block prefix that returns a L<sequence|/type/Seq>
316316
of values. The values come from calls to C<take> in the dynamic scope of the C<gather> block.
@@ -360,7 +360,7 @@ from within C<gather>:
360360
say weird(<a b c>, :direction<backward> ); # (c b a)
361361
362362
363-
=head2 given
363+
=head2 X<given|control flow>
364364
365365
The C<given> statement is Perl 6's topicalizing keyword in a similar way that
366366
C<switch> topicalizes in languages such as C. In other words, C<given>
@@ -382,7 +382,7 @@ This is a lot more understandable than:
382382
{ .say; .Numeric; }(EXPR)
383383
384384
385-
=head3 default and when
385+
=head3 X<default and when|control flow,default when>
386386
387387
A block containing a C<default> statement will be left immediately
388388
when the sub-block after the C<default> statement is left. It is
@@ -418,7 +418,7 @@ C<when> statements. The following code says C<"Int"> not C<42>.
418418
}
419419
#-> Int
420420
421-
=head3 proceed and succeed
421+
=head3 X<proceed and succeed|control flow,proceed succeed>
422422
423423
Both C<proceed> and C<succeed> are meant to be used only from inside C<when>
424424
or C<default> blocks.
@@ -480,7 +480,7 @@ specify a final value for the block.
480480
}
481481
#-> Int
482482
483-
=head2 loop
483+
=head2 X<loop|control flow>
484484
485485
The C<loop> statement is the C-style C<for> loop in disguise:
486486
@@ -498,7 +498,7 @@ is equivalent to the C-ish idiom:
498498
499499
loop (;;) {...}
500500
501-
=head2 while, until
501+
=head2 X<while, until|control flow,while until>
502502
503503
The C<while> statement executes the block as long as its condition is
504504
true. So
@@ -556,7 +556,7 @@ $x++ while $x < 12
556556
557557
Also see C<repeat/while> and C<repeat/until> below.
558558
559-
=head2 repeat/while, repeat/until
559+
=head2 X<repeat/while, repeat/until|control flow,repeat>
560560
561561
Perl 5 allows one to apply a statement modifier to a C<do> block such that
562562
C-like constructs such as
@@ -580,11 +580,7 @@ This can also be written quite naturally with C<until>:
580580
...
581581
} until $x >= 10;
582582
583-
=head2 while
584-
585-
=comment TODO
586-
587-
=head2 return
583+
=head2 X<return|control flow>
588584
589585
=comment TODO
590586
@@ -602,7 +598,7 @@ LINE: for $*IN.lines -> $line {
602598
603599
=end code
604600
605-
=head2 next
601+
=head2 X<next|control flow>
606602
607603
The C<next> command starts the next iteration of the loop. So the code
608604
@@ -618,7 +614,7 @@ my @x = 1, 2, 3, 4, 5;
618614
619615
prints "1245".
620616
621-
=head2 last
617+
=head2 X<last|control flow>
622618
623619
The C<last> command immediately exits the loop in question.
624620
@@ -634,7 +630,7 @@ for @x -> $x {
634630
635631
prints "12".
636632
637-
=head2 redo
633+
=head2 X<redo|control flow>
638634
639635
The C<redo> command restarts the loop block without evaluating the
640636
conditional again.
@@ -645,7 +641,7 @@ conditional again.
645641
646642
=end code
647643
648-
=head2 goto
644+
=head2 X<goto|control flow>
649645
650646
=comment TODO
651647

htmlify.p6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1, :$url) {
378378
my $fc := .[1];
379379
proceed unless $fc.type eq "X";
380380
@definitions = $fc.meta[0].flat;
381+
# set default name if none provide so X<if|control> gets name 'if'
382+
@definitions[1] = $fc.contents[0] if @definitions == 1;
381383
$unambiguous = True;
382384
}
383385
when :(Str $ where /^The \s \S+ \s \w+$/) {

0 commit comments

Comments
 (0)