Permalink
Browse files

Make perl6 --doc=HTML etc do what it should.

Now --doc=foo loads Pod::To::foo module and calls
Pod::To::foo.render($=pod). Adjust Pod::To::Text as well.
  • Loading branch information...
1 parent 5511d03 commit 626ef2a8fe6a4d23148873765944cc657d2b727e @tadzik tadzik committed Apr 21, 2012
Showing with 15 additions and 19 deletions.
  1. +5 −1 lib/Pod/To/Text.pm
  2. +9 −17 src/Perl6/Actions.pm
  3. +1 −1 src/Perl6/Compiler.nqp
View
6 lib/Pod/To/Text.pm
@@ -1,4 +1,8 @@
-module Pod::To::Text;
+class Pod::To::Text;
+
+method render($pod) {
+ pod2text($pod)
+}
sub pod2text($pod) is export {
my @declarators;
View
26 src/Perl6/Actions.pm
@@ -311,28 +311,20 @@ class Perl6::Actions is HLL::Actions {
method install_doc_phaser($/) {
# Add a default DOC INIT phaser
- if %*COMPILING<%?OPTIONS><doc> {
+ my $doc := %*COMPILING<%?OPTIONS><doc>;
+ if $doc {
my $block := $*W.push_lexpad($/);
- # loading and importing
- # TODO: Skip importing and use a symbol_lookup when the
- # Pod::foo modules bug gets fixed
- my $module := $*W.load_module($/, 'Pod::To::Text', $*GLOBALish);
- if pir::exists($module, 'EXPORT') {
- my $EXPORT := $module<EXPORT>.WHO;
- if pir::exists($EXPORT, 'DEFAULT') {
- $*W.import($EXPORT<DEFAULT>);
- }
- }
- #my $pod2text := $*W.symbol_lookup(
- # ['Pod','To','Text','&pod2text'], $/
- #);
+ my $renderer := "Pod::To::$doc";
+
+ my $module := $*W.load_module($/, $renderer, $*GLOBALish);
+
my $pod2text := PAST::Op.new(
- :pasttype<call>, :node($/), :name<&pod2text>,
+ :pasttype<callmethod>, :name<render>, :node($/),
+ self.make_indirect_lookup([$renderer]),
+ PAST::Var.new(:name<$=pod>, :node($/))
);
- $pod2text.push(PAST::Var.new(:name<$=pod>, :node($/)));
-
$block.push(
PAST::Op.new(
:pasttype<call>, :node($/),
View
2 src/Perl6/Compiler.nqp
@@ -5,7 +5,7 @@ use Perl6::Optimizer;
class Perl6::Compiler is HLL::Compiler {
method command_eval(*@args, *%options) {
if pir::exists(%options, 'doc') && !%options<doc> {
- %options<doc> := 'text';
+ %options<doc> := 'Text';
}
my $hll_ns := pir::get_root_global__Ps('perl6');

0 comments on commit 626ef2a

Please sign in to comment.