|
6 | 6 |
|
7 | 7 | =head1 Creating and using modules
|
8 | 8 |
|
9 |
| -A module is usually a source file or set of source files |
10 |
| -N<Technically a module is a set of I<compunits> which are usually files but could come from anywhere as long as there is a I<compunit repository> that can provide it. See L<S11|https://design.perl6.org/S11.html>.> |
11 |
| -that |
12 |
| -expose Perl 6 constructs. These are typically packages |
13 |
| -(L<classes|/language/objects#Classes>, |
| 9 | +A module is usually a source file or set of source files that expose Perl 6 |
| 10 | +constructs. |
| 11 | +
|
| 12 | +N<Technically a |
| 13 | +module is a set of I<compunits> which are usually files but could come from |
| 14 | +anywhere as long as there is a I<compunit repository> that can provide it. See |
| 15 | +L<S11|https://design.perl6.org/S11.html>.> |
| 16 | +
|
| 17 | +Modules are typically packages (L<classes|/language/objects#Classes>, |
14 | 18 | L<roles|/language/objects#Roles>, L<grammars|Grammar>),
|
15 | 19 | L<subroutines|/language/functions>, and sometimes
|
16 |
| -L<variables|/language/variables>. In Perl 6 I<module> can also refer |
17 |
| -to a type of package declared with the C<module> keyword (see |
18 |
| -L<Module Packages|/language/module-packages> and the examples |
19 |
| -below) but here we mostly mean "module" as a set of source |
20 |
| -files in a namespace. |
| 20 | +L<variables|/language/variables>. In Perl 6 I<module> can also refer to a type |
| 21 | +of package declared with the C<module> keyword (see L<Module |
| 22 | +Packages|/language/module-packages> and the examples below) but here we mostly |
| 23 | +mean "module" as a set of source files in a namespace. |
21 | 24 |
|
22 | 25 | =head2 Looking for and installing modules.
|
23 | 26 |
|
24 |
| -L<C<zef>|https://github.com/ugexe/zef> is the application using for installing modules in Perl 6. Modules are listed in L<the Perl 6 ecosystem|https://modules.perl6.org> and can be searched there or from the command line using C<zef search> |
| 27 | +L<C<zef>|https://github.com/ugexe/zef> is the application using for installing |
| 28 | +modules in Perl 6. Modules are listed in L<the Perl 6 |
| 29 | +ecosystem|https://modules.perl6.org> and can be searched there or from the |
| 30 | +command line using C<zef search> |
25 | 31 |
|
26 | 32 | =for code :lang<shell>
|
27 | 33 | zef search WWW
|
@@ -258,7 +264,8 @@ tags: C<ALL>, C<DEFAULT> and C<MANDATORY>.
|
258 | 264 | # lib/MyModule.pm6
|
259 | 265 | unit module MyModule;
|
260 | 266 | sub bag is export { ... }
|
261 |
| - sub pants is export(:MANDATORY) { ... } # objects with tag ':MANDATORY' are always exported |
| 267 | + # objects with tag ':MANDATORY' are always exported |
| 268 | + sub pants is export(:MANDATORY) { ... } |
262 | 269 | sub sunglasses is export(:day) { ... }
|
263 | 270 | sub torch is export(:night) { ... }
|
264 | 271 | sub underpants is export(:ALL) { ... }
|
@@ -608,7 +615,12 @@ C<Test>.
|
608 | 615 |
|
609 | 616 | =begin item
|
610 | 617 |
|
611 |
| -To document your modules, use L<Perl 6 Pod |https://design.perl6.org/S26.html> markup inside your modules. Module documentation is most appreciated and will be especially important once the Perl 6 module directory (or some other site) begins rendering Pod docs as HTML for easy browsing. If you have extra docs (in addition to the Pod docs in your module(s)), create a C<doc> directory for them. Follow the same folder structure as the C<lib> directory like so: |
| 618 | +To document your modules, use L<Perl 6 Pod |https://design.perl6.org/S26.html> |
| 619 | +markup inside your modules. Module documentation is most appreciated and will be |
| 620 | +especially important once the Perl 6 module directory (or some other site) |
| 621 | +begins rendering Pod docs as HTML for easy browsing. If you have extra docs (in |
| 622 | +addition to the Pod docs in your module(s)), create a C<doc> directory for |
| 623 | +them. Follow the same folder structure as the C<lib> directory like so: |
612 | 624 |
|
613 | 625 | =begin code :lang<text>
|
614 | 626 | doc
|
|
0 commit comments