Quick Tip #27: Read the docs locally

The p6doc command helps you read the Perl 6 docs. It’s in the Perl 6 documentation repo (so, it doesn’t come with Rakudo).

Check out the repo and from within that directory install it with zef:

$ zef --depsonly install . 

From there you should have to p6doc command. Run it to see what it can do:

What documentation do you want to read?
Examples: p6doc Str
          p6doc Str.split
          p6doc faq

You can list some top level documents:
          p6doc -l

You can also look up specific method/routine definitions:
          p6doc -f push

You can bypass the pager and print straight to stdout:
          p6doc -n Str

Now, a word of caution here. Perl 6 has lots of undocumented bits and not everything works yet. But, you can help by sending pull requests. The -l lists the top-level pages it knows about:

$ p6doc -l
5to6-nutshell
5to6-perlfunc
5to6-perlop
5to6-perlsyn
5to6-perlvar
AST
Any
Array
Associative
Attribute
Backtrace
Bag
...
unicode_entry
unicode_texas
variables

I can read the docs from the command line:

$ p6doc Str
TITLE
class Str

SUBTITLE
String of characters

    class Str is Cool does Stringy { }

Built-in class for strings. Objects of type Str are immutable.

Methods

  routine chop

    multi sub    chop(Str:D)  returns Str:D
    multi method chop(Str:D: $chars = 1) returns Str:D

Returns the string with $chars characters removed from the end.

  routine chomp

Defined as:

    multi sub    chomp(Str:D ) returns Str:D
    multi method chomp(Str:D:) returns Str:D

But, this is 2016. Let’s read it in the browser. First, from the directory, create the HTML files. This might take awhile (a long, long time), but you can read the same docs on docs.perl6.org:

$ make html

Then, run the web app to serve it all. That’s a Mojolicious app, so you’re throwing Perl 5 a bone.

$ make run
Starting local server…
perl5.24.0 app.pl daemon
[Tue Dec  6 11:18:29 2016] [debug] Install Mojolicious::Plugin::AssetPack to enable SASS processor. You will also need CSS::Sass module or have `sass` command working
[Tue Dec  6 11:18:29 2016] [info] Listening at "http://*:3000"
Server available at http://127.0.0.1:3000

And this is what you get:

Leave a Reply

Your email address will not be published. Required fields are marked *