1Padre::Browser(3) User Contributed Perl Documentation Padre::Browser(3)
2
3
4
6 Padre::Browser -- documentation browser for Padre
7
9 Provide an interface for retrieving / generating documentation,
10 resolving terms to documentation (search?) and formatting
11 documentation.
12
13 Allow new packages to be loaded and interrogated for the MIME types
14 they can generate documentation for. Provide similar mechanism for
15 registering new documentation viewers and URI schemes accepted for
16 resolving.
17
18 NOTE: I think all the method names are wrong. Blast it.
19
21 # Does perlish things by default via 'Padre::Browser::POD'
22 my $browser = Padre::Browser->new;
23 my $source = Padre::Document->new( filename=>'source/Package.pm' );
24
25 my $docs = $browser->docs( $source );
26 # $docs provided by Browser::POD->generate
27 # should be Padre::Browser::Document , application/x-pod
28
29 my $output = $browser->browse( $docs );
30 # $output provided by Browser::POD->render
31 # should be Padre::Document , text/x-html
32
33 $browser->load_viewer( 'Padre::Browser::PodAdvanced' );
34 # PodAdvanced->render might add an html TOC in addition to
35 # just pod2html
36
37 my $new_output = $browser->browse( $docs );
38 # $new_output now with a table of contents
39
41 new
42 Boring constructor, pass nothing. Yet.
43
44 load_provider
45 Accepts a single class name, will attempt to auto-use the class and
46 interrogate its "provider_for" method. Any MIME types returned will be
47 associated with the class for dispatch to "generate".
48
49 Additionally, interrogate class for "accept_schemes" and associate the
50 class with URI schemes for dispatch to "resolve".
51
52 load_viewer
53 Accepts a single class name, will attempt to auto-use the class and
54 interrogate its "viewer_for" method. Any MIME types returned will be
55 associated with the class for dispatch to "render".
56
57 resolve
58 Accepts a URI or scalar
59
60 browse
61 accept
63 package My::Browser::Doxygen;
64
65 # URI of doxygen:$string or doxygen://path?query
66 sub accept_schemes {
67 'doxygen',
68 }
69
70 sub provider_for {
71 'text/x-c++src'
72 }
73
74 sub viewer_for {
75 'text/x-doxygen',
76 }
77
78 sub generate {
79 my ($self,$doc) = @_;
80 # $doc will be Padre::Document of any type specified
81 # by ->provider_for
82
83 # push $doc through doxygen
84 # ...
85 # that was easy :)
86
87 # You know your own output type, be explicit
88 my $response = Padre::Document->new;
89 $response->{original_content} = $doxygen->output;
90 $response->set_mimetype( 'text/x-doxygen' );
91 return $response;
92 }
93
94 sub render {
95 my ($self,$docs) = @_;
96 # $docs will be of any type specified
97 # by ->viewer_for;
98
99 ## turn $docs into doxygen(y) html document
100 # ...
101 #
102
103 my $response = Padre::Document->new;
104 $response->{original_content} = $doxy2html->output;
105 $response->set_mimetype( 'text/x-html' );
106 return $response;
107
108 }
109
110
111
112perl v5.30.0 2019-07-26 Padre::Browser(3)