-
Notifications
You must be signed in to change notification settings - Fork 36
/
S26-documentation.pod
2959 lines (2192 loc) · 90.9 KB
/
S26-documentation.pod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=begin pod
=comment
This file is deliberately specified in Perl 6 Pod format
=TITLE
Synopsis 26 - Documentation
=begin VERSION
=table
Maintainer: Damian Conway
Date: 9 Apr 2005
Last Modified: 25 Jul 2014
=end VERSION
=head1
Pod
D<Pod> is an easy-to-use markup language with a simple, consistent
underlying document object model. Pod can be used for writing language
documentation, for documenting programs and modules, as well as for
other types of document composition.
Pod is an evolution of Perl 5's L<I<Plain Ol' Documentation>|doc:perlpod>
(POD) markup. Compared to POD, Perl 6's Pod is much more
uniform, somewhat more compact, and considerably more expressive. The
Pod dialect also differs in that it is a purely descriptive mark-up
notation, with no presentational components.
=head2 General syntactic structure
Pod documents are specified using D<directives|directive>, which are
used to declare configuration information and to delimit blocks of
textual content. All Pod directives are considered to be special types
of comments in Perl 6.
Every directive starts either with an equals sign (C<=>) followed
immediately by an identifier N<as specified in Synopsis 2>, or with
a C<#=> or C<#|> followed immediately by whitespace or an opening bracket.
Directives that start with C<=> can be indented like the code they
interleave, but their initial C<=> must still be the first non-whitespace
character on their line. Directives that start with C<#=> or C<#|> can be placed
anywhere that a Perl 6 comment can appear, though they are meaningful
only in a subset of those places; see L<#Declarator blocks>.
An indented Pod block is considered to have a I<virtual left margin>,
determined by the indentation of its opening delimiter.
In other words, if a directive is indented from the left margin, the
column at which the first character of its opening delimiter appears is
thereafter considered the first column of the entire block's contents.
As with Perl 6 heredocs, the virtual margin treats leading tabs as
aligning to tabstops spaced every C<($?TABSTOP // 8)> characters.
=head2
Pod blocks
The content of a document is specified within one or more D<blocks|block>.
Every Pod block may be declared in any of four forms:
L<I<delimited style>|#Delimited blocks>, L<I<paragraph style>|#Paragraph
blocks>, L<I<abbreviated style>|#Abbreviated blocks>, or L<I<declarator
style>|#Declarator blocks>. The first three forms are all equivalent; the
fourth is distinct.
Anything in a document that is neither a Pod directive nor contained
within a Pod block is treated as "ambient" material. Typically this
would be the source code of the program that the Pod is documenting. Pod
parsers still parse this text into the internal representation of the
file, representing it as a C<Pod::Block::Ambient> block. Renderers
will I<usually> ignore such blocks, but see L<#Aliases>.
In Perl 5's POD format, once a POD directive is encountered, the parser
considers everything that follows to be POD, until an explicit C<=cut>
directive is encountered, at which point the parser flips back to
parsing ambient source code. The Perl 6 Pod format is different. All Pod
directives have a defined terminator and the Pod parser always reverts to
"ambient" at the end of each Pod directive or block. To cause the parser
to remain in Pod mode, you must enclose the desired Pod region in a
C<pod> block:
=begin code :allow<B>
B<=begin pod>
=head1 A heading
This is Pod too. Specifically, this is a simple C<para> block
$this = pod('also'); # Specifically, a code block
B<=end pod>
=end code
=head3 Delimited blocks
Delimited blocks are bounded by C<=begin> and C<=end> markers, both of
which are followed by a valid Perl 6 identifier, which is the
D<typename> of the block. Typenames that are entirely lowercase (for
example: C<=begin head1>) or entirely uppercase (for example: C<=begin
SYNOPSIS>) are reserved.
After the typename, the rest of the C<=begin> marker line is treated as
configuration information for the block. This information is used in
different ways by different types of blocks, but is always specified using
Perl6-ish option pairs. That is, any of:
=for table :nested
Value is... Specify with... Or with... Or with...
=============== =================== ============== ======================
Boolean (true) C«:key» C«:key(1)» C«key => 1»
Boolean (false) C«:!key» C«:key(0)» C«key => 0»
String C«:key<str>» C«:key('str')» C«key => 'str'»
List C«:key<1 2 3>» C«:key[1,2,3]» C«key => [1,2,3]»
Hash C«:key{a=>1, b=>2}» C«key => {a=>1, b=>2}»
All option keys and values must, of course, be constants since Pod is a
specification language, not a programming language. Specifically, option
values cannot be closures. See Synopsis 2 for details of the various
Perl 6 pair notations.
The configuration section may be extended over subsequent lines by
starting those lines with an C<=> in the first (virtual) column followed
by a whitespace character.
The lines following the opening delimiter and configuration are the
data or contents of the block, which continue until the block's matching
C<=end> marker line. For most block types, these contents may be
indented if you wish, without them being treated as L<code blocks|#Code
blocks>. Unlike Perl 5, indented text is only treated as code within
C<=pod>, L<C<=nested>|#Nesting blocks>, L<C<=item>|#Lists>, C<=code>,
and L<semantic|#Semantic blocks> blocks.
The general syntax is:
=begin code :allow< R >
=begin R<BLOCK_TYPE> R<OPTIONAL CONFIG INFO>
= R<OPTIONAL EXTRA CONFIG INFO>
R<BLOCK CONTENTS>
=end R<BLOCK_TYPE>
=end code
For example:
=begin code
=begin table :caption<Table of Contents>
Constants 1
Variables 10
Subroutines 33
Everything else 57
=end table
=begin Name :required
= :width(50)
The applicant's full name
=end Name
=begin Contact :optional
The applicant's contact details
=end Contact
=end code
Note that no blank lines are required around the directives; blank
lines within the contents are always treated as part of the contents.
This is a universal feature of Pod.
Note also that in the following specifications, a "blank line" is a line
that is either empty or that contains only whitespace characters. That
is, a blank line matches the Perl 6 pattern: C</^^ \h* $$/>. Pod uses
blank lines as delimiters, rather than empty lines, to minimize unpleasant
surprises when stray spaces or tabs mysteriously turn up in hitherto
empty lines.
=head3 Paragraph blocks
Paragraph blocks are introduced by a C<=for> marker and terminated by
the next Pod directive or the first blank line (which is I<not>
considered to be part of the block's contents). The C<=for> marker is
followed by the name of the block and optional configuration
information. The general syntax is:
=begin code :allow< R >
=for R<BLOCK_TYPE> R<OPTIONAL CONFIG INFO>
= R<OPTIONAL EXTRA CONFIG INFO>
R<BLOCK DATA>
=end code
For example:
=begin code
=for table :caption<Table of Contents>
Constants 1
Variables 10
Subroutines 33
Everything else 57
=for Name :required
= :width(50)
The applicant's full name
=for Contact :optional
The applicant's contact details
=end code
=head3 Abbreviated blocks
Abbreviated blocks are introduced by an C<'='> sign in the
first column, which is followed immediately by the typename of the
block. The rest of the line is treated as block data, rather than as
configuration. The content terminates at the next Pod directive or the
first blank line (which is not part of the block data). The general
syntax is:
=begin code :allow< R >
=R<BLOCK_TYPE> R<BLOCK DATA>
R<MORE BLOCK DATA>
=end code
For example:
=begin code
=table
Constants 1
Variables 10
Subroutines 33
Everything else 57
=Name The applicant's full name
=Contact The applicant's contact details
=end code
Note that abbreviated blocks cannot specify configuration information. If
configuration is required, use a C<=for> or C<=begin>/C<=end> instead.
=head3 Declarator blocks
The fourth form of Pod block differs from the first three in that it
does not specify an explicit typename. Instead, it obtains its identity
and purpose from the Perl 6 source code to which it is attached;
specifically, from some nearby declarator.
Declarator blocks are introduced by a special Perl comment: either C<#=>
or C<#|>, which must be immediately followed by either by a space or an
opening bracket. If followed by a space, the block is terminated by the
end of line; if followed by one or more opening brackets, the block is
terminated by the matching sequence of closing brackets.
That is, declarator Pod blocks are syntactically like ordinary Perl 6
single-line comments and embedded comments. The general syntax is:
=begin code :allow< R >
#| R<BLOCK DATA TO END OF LINE>
#|{ R<BLOCK DATA>
R<MORE BLOCK DATA>
}
#= R<BLOCK DATA TO END OF LINE>
#={ R<BLOCK DATA>
R<MORE BLOCK DATA>
}
=end code
except that the bracketed forms may use I<any> valid Perl 6 bracket delimiter
(including repeated opening brackets), as described in Synopsis 2.
Declarator Pod blocks must either precede or immediately follow a valid
Perl 6 declarator, and are then said to be "attached" to it. They are
primarily intended to simplify the documentation of code interfaces.
Declarator blocks that start with C<#|> attach to the declarator immediately
after them (separated only by whitespace). Declarator blocks that start with
C<#=> attach to the declarator declared at the start of the line immediately
before them. In all other respects they act just like comments (i.e. they are
themselves whitespace as far as ambient source code is concerned). This means
multiple declarator blocks can be specified in a row and will all attach to the
same declarator.
For example:
=begin code
#| Base class for comms necromancy hierarchy
class Magic::Necrotelecomnicon {
has $.elemental; #= Source of all power
has $!true_name; # Source of all self-protection (not documented)
method cast(#|{ A spell } Spell $s)
#= Initiate a specified spell normally
#= (do not use for class 7 spells)
{
do_raw_magic($s);
}
method kast( #= Initiate a specified spell abnormally
Spell $s #= The spell to be abnormally initiated
) {
do_raw_magic($s, :alternative);
}
#| This subroutine does the real work
sub do_raw_magic (
Spell $s, #= Which spell to invoke
*%options #= How to invoke it
) {...}
}
sub fu (Any $bar)
#=[ This text stored in C<&fu.WHY>, not in C<$bar.WHY>,
(because C<sub fu> is the declarator
at the I<start> of the preceding line)
]
multi sub baz(Int $count, Str $name)
#=[ This text stored in C<&baz:(Int,Str).WHY>
(i.e. the C<.WHY> of the variant, not of the entire multisub)
]
#| Attaches to the specific parameterized role, rather than the role group itself
role R[::T] {}
role R {}
=end code
A declarator can have multiple leading and/or trailing Pod comments, in
which case they are concatenated with an intermediate newline when
their object's C<.WHY> return value is stringified:
#| This is a special chainsaw
#| (Why, you ask?)
my SwissArmy $chainsaw #= (It has a rocket launcher!)
say $chainsaw.WHY; # prints: This is a special chainsaw
# (Why, you ask?)
# (It has a rocket launcher!)
The individual leading and trailing Pod comments can be retrieved
via the returned Pod object's C<.leading> and C<.trailing> methods:
say $chainsaw.WHY.leading; # prints: This is a special chainsaw
(Why, you ask?)
say $chainsaw.WHY.trailing; # prints: (It has a rocket launcher!)
The Pod object representing each Declarator block is still appended to
the current surrounding Pod object (e.g. to C<$=pod> at the top level).
Each such block representation is an object of class
C<Pod::Block::Declarator>, and has a C<.WHEREFORE> method that returns
the code object or metaobject created by the declarator to which the
documentation is attached.
In other words, C<.WHY> and C<.WHEREFORE> are inverse operations:
=code
.WHY
----------------------------
| |
| v
----------------- -----------------
| Declared code | | Documentation |
| object | | object |
----------------- -----------------
^ |
| |
----------------------------
.WHEREFORE
When the L<default C<DOC INIT> block|#How Pod is parsed and processed>
renders these Pod objects, it automatically includes information about
the declarator as well. For instance, the earlier Necrotelecomnicon
example might produce something like:
=begin output
Name: Magic::Necrotelecomnicon:
Desc: Base class for comms necromancy hierarchy
Attrs:
.elemental : Source of all power
Methods:
.cast(Spell $s) : Initiate a specified spell normally
.kast(Spell $s) : Initiate a specified spell abnormally
Subroutines:
do_raw_magic( : This subroutine does the real work
Spell $s, : Which spell to invoke
*%options : How to invoke it
)
=end output
Note, however, that the exact rendering used for declarator blocks is
implementation dependent, and may also be pre-empted explicitly by some
L<C<DOC> configuration statement|#How Pod is parsed and processed>
within the document, such as:
DOC use Pod::Markovian;
or:
DOC INIT {
use Pod::Eiffelish::Long;
say eiffelish_long($=pod);
exit;
}
=head3 Block equivalence
The first three block specifications (delimited, paragraph, and
abbreviated) are treated identically by the underlying documentation
model, so you can use whichever form is most convenient for a particular
documentation task. In the descriptions that follow, the abbreviated
form will generally be used, but should be read as standing for all
three forms equally.
For example, although L<#Headings> shows only:
=begin code
=head1 Top Level Heading
=end code
this automatically implies that you could also write that block as:
=begin code
=for head1
Top Level Heading
=end code
or:
=begin code
=begin head1
Top Level Heading
=end head1
=end code
Declarator blocks are distinct from these three forms. They do not have
typenames of their own, but rather take their meaning and identity from
the declared object or type to which they are attached. In general, they
are used specifically to describe that declarand.
=head3 Standard configuration options
Pod predefines a small number of standard configuration options that can be
applied uniformly to any built-in block type. These include:
=begin defn
C<:nested>
This option specifies that the block is to be nested within its current
context. For example, nesting might be applied to block quotes, to textual
examples, or to commentaries. In addition the L<C<=code>|#Code blocks>,
L<C<=item>|#Lists>, L<C<=input>|#I/O blocks>, and L<C<=output>|#I/O blocks>
blocks all have implicit nesting.
Nesting of blocks is usually rendered by adding extra indentation to the
block contents, but may also be indicated in other ways:
by boxing the contents, by changing the font or size of the nested text,
or even by folding the text (so long as a visible placeholder is provided).
Occasionally it is desirable to nest content by more than one level:
=begin code
=begin para :nested
=begin para :nested
=begin para :nested
"We're going deep, deep, I<deep> undercover!"
=end para
=end para
=end para
=end code
This can be simplified by giving the C<:nested> option a positive integer
value:
=begin code :allow<B>
=begin para B<:nested(3)>
"We're going deep, deep, I<deep> undercover!"
=end para
=end code
You can also give the option a value of zero, to defeat any implicit
nesting that might normally be applied to a paragraph. For example, to
specify a block of code that should appear I<without> its usual
nesting:
=begin code :allow<B V>
=comment Don't nest this code block in the usual way...
B<=begin code :nested(0)>
1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890
|------|-----------------------|---------------------------|
line instruction comments
number code
V<=end code>
=end code
Note that C<:!nested> could also be used for this purpose:
=begin code
=Z<>begin code :!nested
=end code
=end defn
=begin defn
C<:numbered>
This option specifies that the block is to be numbered. The most common
use of this option is to create L<numbered headings|#Numbered headings> and
L<ordered lists|#Ordered lists>, but it can be applied to any block.
The numbering conventions for headings and lists are specified in those
sections, but it is up to individual renderers to decide how to display
any numbering associated with other types of blocks.
Note that numbering is never explicit; it is always implied by context.
=end defn
=begin defn
C<:formatted>
This option specifies that the contents of the block should be treated as if
they had one or more L<formatting codes|#Formatting codes> placed around them.
For example, instead of:
=begin code
=for comment
The next para is both important and fundamental,
so doubly emphasize it...
=begin para
B<I<
Warning: Do not immerse in water. Do not expose to bright light.
Do not feed after midnight.
>>
=end para
=end code
you can just write:
=begin code :allow<B>
=begin para B<:formatted<B I>>
Warning: Do not immerse in water. Do not expose to bright light.
Do not feed after midnight.
=end para
=end code
The internal representations of these two versions are exactly the same,
except that the second one retains the C<:formatted> option information
as part of the resulting block object.
Like all formatting codes, codes applied via a C<:formatted> are
inherently cumulative. For example, if the block itself is already
inside a formatting code, that formatting code will still apply, in
addition to the extra "basis" and "important" formatting specified by
C<:formatted<B I>>.
=end defn
=begin defn
C<:like>
This option specifies that a block or config has the same formatting
properties as the type named by its value. This is useful for creating
related L<configurations|#Block pre-configuration> or for making
user-defined synonyms for existing types. For example:
=begin code
=config head2 :like<head1> :formatted<I>
=config Subhead :like<head2>
=end code
=end defn
=begin defn
C<:allow>
This option expects a list of formatting codes that are to be recognized
within any C<V<>> codes that appear in (or are implicitly applied to)
the current block. The option is most often used on C<=code> blocks to
allow mark-up within those otherwise verbatim blocks, though it can be
used in I<any> block that contains verbatim text. See L<#Formatting
within code blocks>.
=end defn
=begin defn
C<:margin>
This option specifies a character that indicates the left margin of the
contents of the block. Normally this left margin is determined by the column
at which the C<=> of the opening block-delimiter occurs. For example:
=begin code
=head1 Indenting Pod blocks
=begin para
This text is flush with the (virtual) left margin of
the Pod block because that margin is implicitly specified
by the C<=> of the C<=begin>
=end para
=end code
However, by using the C<:margin> option it is possible to specify a
character that acts like an explicit margin when it occurs as the first
non-whitespace character on any line within the block. For example:
=begin code
=head1 Indenting Pod blocks
=begin para :margin<|>
|This text is flush with the (virtual) left margin of
|the Pod block because that margin is explicitly marked
|by the C<|>, as specified by the block's C<:margin<|>> option.
=end para
=end code
The virtual margin can even be to the left of the opening delimiter, which can
be convenient to guide subsequent indentations. For example:
=begin code
sub foo {
V<=begin> pod :margin<|>
|=head1 Hey Look: Indented Pod!
|
|You can indent Pod in Perl 6
|which makes code look cleaner
|when documentation is interspersed
|
| my $this is Code;
|
|=end pod
...
}
=end code
When a C<:margin> option is used, each subsequent line (until the
corresponding closing delimiter is encountered) simply has any text matching
C</^^ \s* $margin_char/> automatically removed. This may include a line that
then becomes the closing delimiter, as in the above example.
Any line from which such a margin marker is removed automatically resets
the implicit margin for subsequent lines of the block, setting it to the
length of the "marginalized" indent that was just removed. This implicit
margin is then used until the next line with an explicit margin marker
is encountered, or the block terminates.
=end defn
=head2 Block types
Pod offers notations for specifying a wide range of standard block types...
=head3 Headings
Pod provides an unlimited number of levels of heading, specified by the
C<=head>R<N> block marker. For example:
=begin code
=head1 A Top Level Heading
=head2 A Second Level Heading
=head3 A third level heading
=head86 A "Missed it by I<that> much!" heading
=end code
While Pod parsers are required to recognize and distinguish all levels
of heading, Pod renderers are only required to provide distinct
I<renderings> of the first four levels of heading (though they may, of
course, provide more than that). Headings at levels without distinct
renderings would typically be rendered like the lowest distinctly
rendered level.
=head4 Numbered headings
You can specify that a heading is numbered using the C<:numbered> option. For
example:
=begin code
=for head1 :numbered
The Problem
=for head1 :numbered
The Solution
=for head2 :numbered
Analysis
=for head3
Overview
=for head3
Details
=for head2 :numbered
Design
=for head1 :numbered
The Implementation
=end code
which would produce:
=begin nested :formatted<B>
1. The Problem
2. The Solution
=begin nested
2.1. Analysis
=begin nested
Overview
Details
=end nested
2.2: Design
=end nested
3. The Implementation
=end nested
It is usually better to preset a numbering scheme for each heading
level, in a series of L<configuration blocks|#Block pre-configuration>:
=begin code :allow<B Z>
B<=config head1 :numbered
Z<>=config head2 :numbered
Z<>=config head3 :!numbered>
=head1 The Problem
=head1 The Solution
=head2 Analysis
=head3 Overview
=head3 Details
=head2 Design
=head1 The Implementation
=end code
Alternatively, as a short-hand, if the first whitespace-delimited word
in a heading consists of a single literal C<#> character, the C<#> is
removed and the heading is treated as if it had a C<:numbered> option:
=begin code
=head1 # The Problem
=head1 # The Solution
=head2 # Analysis
=head3 Overview
=head3 Details
=head2 # Design
=head1 # The Implementation
=end code
Note that, even though renderers are not required to distinctly render
more than the first four levels of heading, they I<are> required to
correctly honour arbitrarily nested numberings. That is:
=begin code
=head6 # The Rescue of the Kobayashi Maru
=end code
should produce something like:
=nested
B<2.3.8.6.1.9. The Rescue of the Kobayashi Maru>
=head3 Ordinary paragraph blocks
Ordinary paragraph blocks consist of text that is to be formatted into
a document at the current level of nesting, with whitespace
squeezed, lines filled, and any special L<inline mark-up|#Formatting codes>
applied.
Ordinary paragraphs consist of one or more consecutive lines of text,
each of which starts with a non-whitespace character at (virtual) column
1. The paragraph is terminated by the first blank line or block
directive. For example:
=begin code
=head1 This is a heading block
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled. It is terminated by
the first blank line.
This is another ordinary paragraph.
Its text will also be squeezed and
short lines filled. It is terminated by
the trailing directive on the next line.
=head2 This is another heading block
This is yet another ordinary paragraph,
at the first virtual column set by the
previous directive
=end code
Within a C<=pod>, C<=item>, C<=defn>, C<=nested>, C<=finish>, or
L<semantic|#Semantic blocks> block, ordinary paragraphs do not require
an explicit marker or delimiters, but there is also an explicit C<para>
marker (which may be used anywhere):
=begin code :allow<B>
B<=para>
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled.
=end code
and likewise the longer C<=for> and C<=begin>/C<=end> forms. For example:
=begin code :allow<B>
B<=begin para>
This is an ordinary paragraph.
Its text will be squeezed and
short lines filled.
This is I<still> part of the same paragraph,
which continues until an...
B<=end para>
=end code
As the previous example implies, when any form of explicit C<para> block
is used, any whitespace at the start of each line is removed during rendering.
In addition, within a delimited C<=begin para>/C<=end para> block, any
blank lines are preserved.
=head3 Code blocks
Code blocks are used to specify pre-formatted text (typically source
code), which should be rendered without rejustification, without
whitespace-squeezing, and without recognizing any inline formatting
codes. Code blocks also have an implicit L<nesting|#Nesting blocks>
associated with them. Typically these blocks are used to show examples
of code, mark-up, or other textual specifications, and are rendered
using a fixed-width font.
A code block may be implicitly specified as one or more lines of text,
each of which starts with a whitespace character at the block's virtual
left margin. The implicit code block is then terminated by a blank line.
For example:
=begin code
This ordinary paragraph introduces a code block:
$this = 1 * code('block');
$which.is_specified(:by<indenting>);
=end code
Implicit code blocks may only be used within C<=pod>, C<=item>, C<=defn>,
C<=nested>, C<=finish>, or L<semantic|#Semantic blocks> blocks.
There is also an explicit C<=code> block (which can be specified within
I<any> other block type, not just C<=pod>, C<=item>, etc.):
=begin code :allow<B>
The C<loud_update()> subroutine adds feedback:
B<=begin code>
sub loud_update ($who, $status) {
say "$who -> $status";
silent_update($who, $status);
}
B<=end code>
=end code
As the previous example demonstrates, within an explicit C<=code> block
the code can start at the (virtual) left margin. Furthermore, lines that
start with whitespace characters after that margin have subsequent
whitespace preserved exactly (in addition to the implicit nesting of the
code). Explicit C<=code> blocks may also contain empty lines.
=head4 Formatting within code blocks
Although C<=code> blocks automatically disregard all L<formatting
codes|#Formatting codes>, occasionally you may still need to specify
some formatting within a code block. For example, you may wish
to emphasize a particular keyword in an example (using a C<B<>> code). Or
you may want to indicate that part of the example is metasyntactic
(using the C<R<>> code). Or you might need to insert a non-ASCII
character (using the C<E<>> code).
You can specify a list of formatting codes that should still be
recognized within a code block using the C<:allow> option. The value of
the C<:allow> option must be a list of the (single-letter) names of one
or more formatting codes. Those codes will then remain active inside the
code block. For example:
=begin code
=begin code :allow< B R >
sub demo {
B<say> 'Hello R<name>';
}
=end code
=end code
would be rendered:
=begin code :allow< B R >
sub demo {
B<say> 'Hello R<name>';
}
=end code
Note that the use of the C<:allow> option also makes it possible
for verbatim L<formatting codes|#Formatting codes> (such as C<C<>>
and C<V<>>) to L<contain other codes as well|#Pre-configuring formatting codes>.
=head3 I/O blocks
Pod also provides blocks for specifying the input and output of programs.
The C<=input> block is used to specify pre-formatted keyboard input,
which should be rendered without rejustification or squeezing of whitespace.
The C<=output> block is used to specify pre-formatted terminal or file
output which should also be rendered without rejustification or
whitespace-squeezing.
Note that, like C<=code> blocks, both C<=input> and C<=output> blocks have an
implicit level of nesting. They are also like C<=code> blocks in that they
are typically rendered in a fixed-width font, though ideally all three blocks
would be rendered in distinct font/weight combinations (for example: regular
serifed for code, bold sans-serif for input, and regular sans-serif for
output).
Unlike C<=code> blocks, both C<=input> and C<=output> blocks honour any
nested formatting codes. This is particularly useful since a sample of
input will often include prompts (which are, of course, output).
Likewise a sample of output may contain the occasional interactive
component. Pod provides L<special formatting codes|#Example specifiers>
(C<K<>> and C<T<>>) to indicate embedded input or output, so you can use
the block type that indicates the overall purpose of the sample (i.e. is
it demonstrating an input operation or an output sequence?) and then use
the "contrasting" formatting code within the block.
For example, to include a small amount of input in a sample of output
you could use the C<K<>> formatting code:
=begin code :allow<B>
=begin output
Name: Baracus, B.A.
Rank: Sgt
Serial: 1PTDF007
Do you want additional personnel details? B<K<y>>
Height: 180cm/5'11"
Weight: 104kg/230lb
Age: 49
Print? B<K<n>>
=end output
=end code
=head3 Lists
Lists in Pod are specified as a series of contiguous C<=item> blocks. No
special "container" directives or other delimiters are required to
enclose the entire list. For example:
=begin code