Skip to content

Commit 81de538

Browse files
committed
Restructure and reflow refs #2483
1 parent de88216 commit 81de538

File tree

2 files changed

+35
-33
lines changed

2 files changed

+35
-33
lines changed

doc/Language/create-cli.pod6

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ X<|command line arguments>
99
1010
The default command line interface of Perl 6 scripts consists of three parts:
1111
12-
=item Parsing the command line parameters into a L<capture|/type/Capture>
12+
=head2 Parsing the command line parameters into a L<capture|/type/Capture>
1313
1414
This looks at the values in L<@*ARGS|/language/variables#index-entry-@*ARGS>,
1515
interprets these according to some policy, and creates a C<Capture> object
1616
out of that. An alternative way of parsing may be provided by the developer
1717
or installed using a module.
1818
19-
=item Calling a provided MAIN subroutine using that capture
19+
=head2 Calling a provided C<MAIN> subroutine using that capture
2020
2121
Standard L<multi dispatch|/language/functions#index-entry-declarator_multi-Multi-dispatch>
2222
is used to call the MAIN subroutine with the generated C<Capture> object.
2323
This means that your MAIN subroutine may be a C<multi sub>, each candidate
2424
of which is responsible for some part of processing the given command line
2525
arguments.
2626
27-
=item Creating / showing usage information if calling MAIN failed
27+
=item2 Creating / showing usage information if calling C<MAIN> failed
2828
2929
If multi dispatch failed, then the user of the script should be informed as
3030
well as possible as to why it failed. By default, this is done by inspecting
@@ -34,7 +34,7 @@ was specified). An alternative way of generating the usage information may
3434
be provided by the developer or installed using a module.
3535
3636
X<|MAIN>
37-
=head2 sub MAIN
37+
=head1 sub MAIN
3838
3939
The sub with the special name C<MAIN> will be executed after all relevant entry
4040
phasers (C<BEGIN>, C<CHECK>, C<INIT>, C<PRE>, C<ENTER>) have been run and
@@ -169,7 +169,7 @@ Usage:
169169
=end code
170170
171171
X<|%*SUB-MAIN-OPTS>
172-
=head3 %*SUB-MAIN-OPTS
172+
=head2 %*SUB-MAIN-OPTS
173173
174174
It's possible to alter how arguments are processed before they're passed
175175
to C<sub MAIN {}> by setting options in the C<%*SUB-MAIN-OPTS> hash. Due to
@@ -188,7 +188,7 @@ For instance:
188188
Available options are:
189189
190190
X<|named-anywhere>
191-
=head4 named-anywhere
191+
=head3 named-anywhere
192192
193193
By default, named arguments passed to the program (i.e., C<MAIN>)
194194
cannot appear after any positional argument. However, if
@@ -201,7 +201,7 @@ $ perl6 example.p6 1 --c=2 3 --d=4
201201
=end code
202202
203203
X<|hidden-from-USAGE>
204-
=head3 is hidden-from-USAGE
204+
=head2 is hidden-from-USAGE
205205
206206
Sometimes you want to exclude a C<MAIN> candidate from being shown in any
207207
automatically generated usage message. This can be achieved by adding
@@ -238,7 +238,7 @@ Usage:
238238
Which, although technically correct, doesn't read as well.
239239
240240
X<|declarator,unit (MAIN)>
241-
=head2 Unit-scoped definition of C<MAIN>
241+
=head1 Unit-scoped definition of C<MAIN>
242242
243243
If the entire program body resides within C<MAIN>, you can use the C<unit>
244244
declarator as follows (adapting an earlier example):
@@ -295,11 +295,11 @@ in the ecosystem.
295295
X<|ARGS-TO-CAPTURE>
296296
=head2 sub ARGS-TO-CAPTURE
297297
298-
The C<ARGS-TO-CAPTURE> subroutine should accept two parameters: a L<Callable|/type/Callable>
299-
representing the C<MAIN> unit to be executed (so it can be introspected if
300-
necessary) and an array with the arguments from the command line. It
301-
should return a L<Capture|/type/Capture> object that will be used to
302-
dispatch the C<MAIN> unit. A B<very> contrived example that will create
298+
The C<ARGS-TO-CAPTURE> subroutine should accept two parameters: a
299+
L<Callable|/type/Callable> representing the C<MAIN> unit to be executed (so it
300+
can be introspected if necessary) and an array with the arguments from the
301+
command line. It should return a L<Capture|/type/Capture> object that will be
302+
used to dispatch the C<MAIN> unit. A B<very> contrived example that will create
303303
a C<Capture> depending on some keyword that was entered (which can be handy
304304
during testing of a command line interface of a script):
305305
@@ -312,9 +312,9 @@ during testing of a command line interface of a script):
312312
!! &*ARGS-TO-CAPTURE(&main, @args)
313313
}
314314
315-
Note that the dynamic variable L<C<&*ARGS-TO-CAPTURE>|/language/variables#&*ARGS-TO-CAPTURE>
316-
is available to perform
317-
the default command line arguments to C<Capture> processing so you don't
315+
Note that the dynamic variable
316+
L<C<&*ARGS-TO-CAPTURE>|/language/variables#&*ARGS-TO-CAPTURE> is available to
317+
perform the default command line arguments to C<Capture> processing so you don't
318318
have to reinvent the whole wheel if you don't want to.
319319
320320
=head1 Intercepting usage message generation (2018.10, v6.d and later)
@@ -351,9 +351,9 @@ You can also use multi subroutines to create the same effect:
351351
&*GENERATE-USAGE(&main, |capture)
352352
}
353353
354-
Note that the dynamic variable L<C<&*GENERATE-USAGE>|/language/variables#&*GENERATE-USAGE>
355-
is available to perform
356-
the default usage message generation so you don't have to reinvent the
354+
Note that the dynamic variable
355+
L<C<&*GENERATE-USAGE>|/language/variables#&*GENERATE-USAGE> is available to
356+
perform the default usage message generation so you don't have to reinvent the
357357
whole wheel if you don't want to.
358358
359359
=head1 Intercepting MAIN calling (before 2018.10, v6.e)

doc/Type/IO/Path.pod6

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,11 @@ symlinked directories.
465465
'/' .IO.parent.say; # OUTPUT: «"/".IO␤»
466466
IO::Path::Win32.new('C:/').parent.say; # OUTPUT: «"C:/".IO␤»
467467
468-
If C<$level> is specified, the call is equivalent to calling C<.parent()> C<$level> times:
468+
If C<$level> is specified, the call is equivalent to calling C<.parent()>
469+
C<$level> times:
469470
470-
say "/etc/foo".IO.parent(2) eqv "/etc/foo".IO.parent.parent; # OUTPUT: «True␤»
471+
=for code
472+
say "/etc/foo".IO.parent(2) eqv "/etc/foo".IO.parent.parent; # OUTPUT: «True␤»
471473
472474
=head2 method resolve
473475
@@ -500,13 +502,13 @@ Defined as:
500502
method dir(IO::Path:D: Mu :$test = none('.', '..'))
501503
502504
Returns the contents of a directory as a lazy list of C<IO::Path> objects
503-
representing relative paths, filtered by L<smartmatching|
504-
/language/operators#infix_~~> their names (as strings) against the C<:test>
505-
parameter.
505+
representing relative paths, filtered by
506+
L<smartmatching|/language/operators#infix_~~> their names (as strings) against
507+
the C<:test> parameter.
506508
507-
Since the tests are performed against Str arguments, not IO, the tests are
508-
executed in the C<$*CWD>, instead of the target directory.
509-
When testing against file test operators, this won't work:
509+
Since the tests are performed against C<Str> arguments, not C<IO>, the tests are
510+
executed in the C<$*CWD>, instead of the target directory. When testing against
511+
file test operators, this won't work:
510512
511513
dir('mydir', test => { .IO.d })
512514
@@ -516,12 +518,12 @@ while this will:
516518
517519
B<NOTE:> a C<dir> call opens a directory for reading, which counts towards
518520
maximum per-process open files for your program. Be sure to exhaust returned
519-
L<Seq|/type/Seq> before doing something like recursively performing more C<dir> calls.
520-
You can exhaust it by assigning to a C<@->sigiled variable or simply looping
521-
over it. Note how examples below push further dirs to look through into
522-
an L<Array|/type/Array>, rather than immediately calling C<dir> on them. See also
523-
L«C<IO::Dir> module|https://modules.perl6.org/dist/IO::Dir» that gives you finer
524-
control over closing dir handles.
521+
L<Seq|/type/Seq> before doing something like recursively performing more C<dir>
522+
calls. You can exhaust it by assigning to a C<@->sigiled variable or simply
523+
looping over it. Note how examples below push further dirs to look through into
524+
an L<Array|/type/Array>, rather than immediately calling C<dir> on them. See
525+
also L«C<IO::Dir> module|https://modules.perl6.org/dist/IO::Dir» that gives you
526+
finer control over closing dir handles.
525527
526528
Examples:
527529

0 commit comments

Comments
 (0)