Debian Codegraph @

README

raw
1 NAME
2 Pod::POM::View::Restructured - View for Pod::POM that outputs
3 reStructuredText
4
5 SYNOPSIS
6 use Pod::POM::View::Restructured;
7
8 my $view = Pod::POM::View::Restructured->new;
9 my $parser = Pod::POM->new;
10 my $pom = $parser->parse_file("$top_dir/lib/Pod/POM/View/Restructured.pm");
11 my $out = $pom->present($view);
12
13 DESCRIPTION
14 This module outputs reStructuredText that is expected to be used with
15 Sphinx. Verbatim sections (indented paragraphs) in the POD will be
16 output with syntax highlighting for Perl code by default. See "POD
17 commands specifically for reStructuredText" for how to change this for a
18 particular block.
19
20 This module can be downloaded from
21 <https://metacpan.org/release/Pod-POM-View-Restructured>.
22
23 METHODS
24 "new(\%params)"
25 Constructor. \%params is optional. If present, the following keys are
26 valid:
27
28 "callbacks"
29 See documentation below for "convert_file()".
30
31 "namespace"
32 If a namespace is declared then links to that namespace are
33 converted to cross references and an anchor is added for each head
34 tag.
35
36 "convert_file($source_file, $title, $dest_file, $callbacks)"
37 Converts the POD in $source_file to reStructuredText. If $dest_file is
38 defined, it writes the output there. If $title is defined, it is used
39 for the title of the document. Otherwise, an attempt is made to infer
40 the title from the NAME section (checks if the body looks like
41 "/\A\s*(\w+(?:::\w+)+)\s+-\s+/s").
42
43 Returns the output as a string.
44
45 $source_file and $dest_file can be either file names or file handles.
46
47 "convert_files($file_spec, $index_file, $index_title, $out_dir)"
48 Converts the files given in $file_spec to reStructuredText. If
49 $index_file is provided, it is the path to the index file to be created
50 (with a table of contents pointing to all of the files created). If
51 $index_title is provided, it is used as the section title for the index
52 file. $out_dir is the directory the generated files will be written to.
53
54 $file_spec is a reference to an array of hashes specifying attributes
55 for each file to be converted. The valid keys are:
56
57 "source_file"
58 File to convert.
59
60 "dest_file"
61 File to output the reStructuredText. If not provided, a file name
62 will be generated based on the title.
63
64 "title"
65 Section title for the generated reStructuredText. If not provided,
66 an attempt will be made to infer the title from the NAME section in
67 the POD, if it exists. As a last resort, a title will be generated
68 that looks like "section_(\d+)".
69
70 "callbacks"
71 A reference to a hash containing names and the corresponding
72 callbacks.
73
74 Currently the only valid callback is "link". It is given the text
75 inside a L<> section from the POD, and is expected to return a tuple
76 "($url, $label)". If the value returned for $label is undefined, the
77 value of $url is used as the label.
78
79 "no_toc"
80 Causes the item to not be printed to the index or return in the
81 "toc" field.
82
83 This method returns a hash ref with a table of contents (the "toc"
84 field) suitable for a reStructuredText table of contents.
85
86 E.g.,
87
88 my $conv = Pod::POM::View::Restructured->new;
89
90 my $files = [
91 { source_file => "$base_dir/Restructured.pm" },
92 { source_file => "$base_dir/DWIW.pm" },
93 { source_file => "$base_dir/Wrapper.pm" },
94 ];
95
96 my $rv = $conv->convert_files($files, "$dest_dir/index.rst", 'My Big Test', $dest_dir);
97
98 POD commands specifically for reStructuredText
99 The following sequences can be used in POD to request actions
100 specifically for this module.
101
102 =for pod2rst next-code-block: *lang*
103 This sets up the next verbatim section, i.e., the next indented
104 paragraph to be highlighted according to the syntax of the
105 programming/markup/config language *lang*. Verbatim sections are assumed
106 to be Perl code by default. Sphinx uses Pygments to do syntax highlighting
107 in these sections, so you can use any value for *lang* that Pygments
108 supports, e.g., Python, C, C++, Javascript, SQL, etc.
109
110 EXAMPLES
111 Converting a single file using "pod2rst"
112 pod2rst --infile=Restructured.pm --outfile=restructured.rst
113
114 Need to document:
115
116 Document example of setting up sphinx build, generating rst from pod,
117 and building
118
119 TODO
120 code highlighting
121 Currently, a verbatim block (indented paragraph) gets output as a
122 Perl code block by default in reStructuredText. There should be an
123 option (e.g., in the constructor) to change the language for
124 highlighting purposes (for all verbatim blocks), or disable syntax
125 highlighting and just make it a preformatted paragraph. There is a way
126 to do this in POD (see "POD commands specifically for
127 reStructuredText"), but there should also be an option in the
128 constructor.
129
130 improve escaping
131 Text blocks are not escaped properly, so it is currently possible to
132 invoke a command in reStructuredText by accident.
133
134 DEPENDENCIES
135 Inherits from Pod::POM::View::Text that comes with the Pod::POM
136 distribution.
137
138 AUTHORS
139 Don Owens <[email protected]>
140 Jeff Fearn <[email protected]>
141 Alex Muntada <[email protected]>
142
143 LICENSE AND COPYRIGHT
144 Copyright (c) 2010 Don Owens <[email protected]>. All rights reserved.
145 Copyright (c) 2016 Jeff Fearn <[email protected]>. All rights
146 reserved.
147 Copyright (c) 2016-2026 Alex Muntada <[email protected]>. All rights
148 reserved.
149
150 This is free software; you can redistribute it and/or modify it under
151 the same terms as Perl itself. See perlartistic.
152
153 This program is distributed in the hope that it will be useful, but
154 WITHOUT ANY WARRANTY; without even the implied warranty of
155 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
156
157 SEE ALSO
158 Pod::POM
159
160 Pod::POM::View::HTML
161
162 pod2rst (distributed with Pod::POM::View::HTML)
163
164 reStructuredText: <http://docutils.sourceforge.net/rst.html>
165
166 Sphinx (uses reStructuredText): <https://www.sphinx-doc.org/>
167
168 Pygments (used by Sphinx for syntax highlighting):
169 <https://pygments.org/>