Pod::P...ctured(3pm)

✨ NAME ✨

Pod::POM::View::Restructured β€” it's the view for Pod::POM that outputs reStructuredText bestie πŸ’…βœ¨


🌸 SYNOPSIS 🌸

use Pod::POM::View::Restructured;

my $view = Pod::POM::View::Restructured->new;
my $parser = Pod::POM->new;
my $pom = $parser->parse_file("$top_dir/lib/Pod/POM/View/Restructured.pm");
my $out = $pom->present($view);

like, four lines and you're literally done, no cap 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” this module outputs reStructuredText that's expected to be used with Sphinx. Verbatim sections (aka the indented paragraphs) in your POD get output with syntax highlighting for Perl code by default. wanna change that for one specific block? peek at "POD commands specifically for reStructuredText" down below πŸ‘€

you can download this module from <https://metacpan.org/release/Pod-POM-View-Restructured> β€” go get it, it's giving iconic ✨


πŸ’– METHODS πŸ’–

πŸŽ€ new(%params)

Constructor energy πŸ’… \%params is optional, it's not gonna be mad if you ghost it. but if you do pass it, these keys are valid:

  • "callbacks" β€” see the documentation below for convert_file(), iykyk
  • "namespace" β€” if a namespace is declared then links to that namespace are converted to cross references and an anchor is added for each head tag. slay.

πŸ¦‹ convert_file($source_file, $title, $dest_file, $callbacks)

Converts the POD in $source_file to reStructuredText. If $dest_file is defined, it writes the output there. If $title is defined, it is used for the title of the document. Otherwise, an attempt is made to infer the title from the NAME section (checks if the body looks like "/\A\s*(\w+(?:::\w+)+)\s+-\s+/s"). not me giving it a regex to vibe-check your title 😭

Returns the output as a string. periodt.

$source_file and $dest_file can be either file names or file handles β€” flexible queen behavior πŸ’…

🌈 convert_files($file_spec, $index_file, $index_title, $out_dir)

Converts the files given in $file_spec to reStructuredText. If $index_file is provided, it is the path to the index file to be created (with a table of contents pointing to all of the files created). If $index_title is provided, it is used as the section title for the index file. $out_dir is the directory the generated files will be written to. πŸ—‚οΈβœ¨

$file_spec is a reference to an array of hashes specifying attributes for each file to be converted. The valid keys are:

  • "source_file" β€” file to convert. the main character, fr fr
  • "dest_file" β€” file to output the reStructuredText. If not provided, a file name will be generated based on the title. it'll figure it out, trust 🫢
  • "title" β€” section title for the generated reStructuredText. If not provided, an attempt will be made to infer the title from the NAME section in the POD, if it exists. As a last resort, a title will be generated that looks like "section_(\d+)". lowkey unhinged but okay πŸ’€
  • "callbacks" β€” a reference to a hash containing names and the corresponding callbacks. Currently the only valid callback is "link". It is given the text inside a L<> section from the POD, and is expected to return a tuple ($url, $label). If the value returned for $label is undefined, the value of $url is used as the label. no label? it just uses the url, problem solved ✨
  • "no_toc" β€” causes the item to not be printed to the index or return in the "toc" field. it said "don't perceive me" πŸ™ˆ

This method returns a hash ref with a table of contents (the "toc" field) suitable for a reStructuredText table of contents. πŸ‘‘

E.g.,

my $conv = Pod::POM::View::Restructured->new;

my $files = [
              { source_file => "$base_dir/Restructured.pm" },
              { source_file => "$base_dir/DWIW.pm" },
              { source_file => "$base_dir/Wrapper.pm" },
             ];

my $rv = $conv->convert_files($files, "$dest_dir/index.rst", 'My Big Test', $dest_dir);

🧚 POD commands specifically for reStructuredText 🧚

these sequences can be used in POD to request actions specifically for this module. custom order, just for us πŸ’…

⭐ =for pod2rst next-code-block: lang

This sets up the next verbatim section, i.e., the next indented paragraph, to be highlighted according to the syntax of the programming/markup/config language lang. Verbatim sections are assumed to be Perl code by default. Sphinx uses Pygments to do syntax highlighting in these sections, so you can use any value for lang that Pygments supports, e.g., Python, C, C++, Javascript, SQL, etc. the range?? unmatched. πŸ”₯


🌈 EXAMPLES 🌈

Converting a single file using "pod2rst":

pod2rst --infile=Restructured.pm --outfile=restructured.rst

Need to document:

Document example of setting up sphinx build, generating rst from pod, and building


πŸ’€ TODO πŸ’€

  • code highlighting β€” Currently, a verbatim block (indented paragraph) gets output as a Perl code block by default in reStructuredText. There should be an option (e.g., in the constructor) to change the language for highlighting purposes (for all verbatim blocks), or disable syntax highlighting and just make it a preformatted paragraph. There is a way to do this in POD (see "POD commands specifically for reStructuredText"), but there should also be an option in the constructor. okay so we need constructor options too, manifesting it πŸ•―οΈβœ¨
  • improve escaping β€” Text blocks are not escaped properly, so it is currently possible to invoke a command in reStructuredText by accident. ⚠️ this one's a lil scary ngl
heads up bestie β€” that escaping thing means you can accidentally invoke a command in reStructuredText. not a vibe, be careful πŸ™ˆ

🫢 DEPENDENCIES 🫢

Inherits from Pod::POM::View::Text that comes with the Pod::POM distribution. it's giving family lineage πŸ‘‘


🌸 SEE ALSO 🌸

go read them, they're all so good πŸ’–


πŸ‘‘ AUTHORS πŸ‘‘

  • Don Owens <don@regexguy.com>
  • Jeff Fearn <Jeff.Fearn@gmail.com>
  • Alex Muntada <alexm@alexm.org>

the icons who made this happen, we stan 🫢✨


This software is copyright (c) 2010 by Don Owens <don@regexguy.com>, 2016 by Jeff Fearn <Jeff.Fearn@gmail.com>, and 2016-2026 by Alex Muntada <alexm@alexm.org>.

This software is available under the same terms as the perl 5 programming language system itself. same energy, same terms, iconic behavior ⭐


⭐ VERSION ⭐

1.000004


and that's a wrap bestie πŸŽ€ this was Pod::POM::View::Restructured(3pm) from the User Contributed Perl Documentation, built on perl v5.40.1 and dated 2026-07-31 β€” go forth and make some reStructuredText, you ate πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from