| 1 | package Padre::Plugin::Perl6::Help; | ||
| 2 | BEGIN { | ||
| 3 | $Padre::Plugin::Perl6::Help::VERSION = '0.71'; | ||
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: Perl 6 Help provider for Padre | ||
| 7 | |||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | |||
| 11 | # For Perl 6 documentation support | ||
| 12 | use Padre::Help (); | ||
| 13 | |||
| 14 | our @ISA = 'Padre::Help'; | ||
| 15 | |||
| 16 | use Class::XSAccessor accessors => { | ||
| 17 | _grok => '_grok', # App::Grok -> Perl 6 Documentation Reader | ||
| 18 | }; | ||
| 19 | |||
| 20 | |||
| 21 | # | ||
| 22 | # Initialize help | ||
| 23 | # | ||
| 24 | sub help_init { | ||
| 25 | my $self = shift; | ||
| 26 | require App::Grok; | ||
| 27 | $self->_grok( App::Grok->new ); | ||
| 28 | } | ||
| 29 | |||
| 30 | # | ||
| 31 | # Renders the help topic content using App::Grok into XHTML | ||
| 32 | # | ||
| 33 | sub help_render { | ||
| 34 | my ( $self, $topic ) = @_; | ||
| 35 | |||
| 36 | my $grok = $self->_grok; | ||
| 37 | my $html = $grok->render_target( $topic, 'xhtml' ); | ||
| 38 | my $location = $grok->locate_target($topic); | ||
| 39 | return ( $html, $location ); | ||
| 40 | } | ||
| 41 | |||
| 42 | # | ||
| 43 | # Returns the help topic list | ||
| 44 | # | ||
| 45 | sub help_list { | ||
| 46 | my ($self) = @_; | ||
| 47 | |||
| 48 | # Return Grok's target index | ||
| 49 | my @index = $self->_grok->target_index; | ||
| 50 | |||
| 51 | # Return a unique sorted index | ||
| 52 | my %seen = (); | ||
| 53 | my @unique_sorted_index = sort grep { !$seen{$_}++ } @index; | ||
| 54 | return \@unique_sorted_index; | ||
| 55 | } | ||
| 56 | |||
| 57 | 1; | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | =pod | ||
| 62 | |||
| 63 | =head1 NAME | ||
| 64 | |||
| 65 | Padre::Plugin::Perl6::Help - Perl 6 Help provider for Padre | ||
| 66 | |||
| 67 | =head1 VERSION | ||
| 68 | |||
| 69 | version 0.71 | ||
| 70 | |||
| 71 | =head1 DESCRIPTION | ||
| 72 | |||
| 73 | Perl 6 Help index is built here and rendered. | ||
| 74 | |||
| 75 | =head1 AUTHORS | ||
| 76 | |||
| 77 | =over 4 | ||
| 78 | |||
| 79 | =item * | ||
| 80 | |||
| 81 | Ahmad M. Zawawi <ahmad.zawawi@gmail.com> | ||
| 82 | |||
| 83 | =item * | ||
| 84 | |||
| 85 | Gabor Szabo L<http://szabgab.com/> | ||
| 86 | |||
| 87 | =back | ||
| 88 | |||
| 89 | =head1 COPYRIGHT AND LICENSE | ||
| 90 | |||
| 91 | This software is copyright (c) 2010 by Ahmad M. Zawawi. | ||
| 92 | |||
| 93 | This is free software; you can redistribute it and/or modify it under | ||
| 94 | the same terms as the Perl 5 programming language system itself. | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | |||
| 99 | __END__ |