Skip to content

Commit ec80af5

Browse files
tbrowdercoke
authored andcommitted
Clarify use of the '$?DISTRIBUTION.ver' (and '.content') methods
+ Add examples to accompany the descriptions
1 parent f0661bf commit ec80af5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

doc/Language/variables.rakudoc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,32 @@ unit module MyFoo;
14871487

14881488
sub module-version {
14891489
say "MyFoo is version:";
1490-
say $?DISTRIBUTION.meta<ver>;
1490+
say $?DISTRIBUTION.meta<ver>; # OUTPUT: «0.0.1␤»
14911491
}
1492+
=end code
1493+
1494+
The C<.meta> method currently has hash keys of C<ver>, C<auth>, and C<api>,
1495+
1496+
The C<.content> method provides access to files in the distribution
1497+
when provided with the relative path from the distribution's top-level
1498+
directory.
14921499

1500+
=begin code :solo
14931501
sub module-source {
14941502
say "MyFoo source code:";
14951503
say $?DISTRIBUTION.content('lib/MyFoo.rakumod');
1504+
# OUTPUT: «IO::Handle<"lib/MyFoo.rakumod".IO>(closed)␤»
1505+
}
1506+
=end code
1507+
1508+
Note the output for the C<content> example is a B<closed> filehandle.
1509+
To actually use the file's content, the user can extract it as a string
1510+
in another routine in the same module:
1511+
1512+
=begin code :solo
1513+
sub get-file-content {
1514+
say $?DISTRIBUTION.content('lib/MyFoo.rakumod').open.slurp;
1515+
# OUTPUT: «unit module MyFoo;␤»
14961516
}
14971517
=end code
14981518

0 commit comments

Comments
 (0)