0

POD is a markup file that is used by Perl. It's a pretty unreasonable documentation format that has nothing to do with perl (accept for being the only known use-case), and it's sometimes found intermingled with code. Think MarkDown-nroff hybrid, but optimized to distract the user from anything they may be doing. You can find more information on it from the official docs on perlpod, and perlpodspec.

I would like to fold POD, but in such a way that the

  • the fold isn't affected by generic operations (zF to unfold all) unless I'm explicitly targeting that fold, and for it to otherwise not-expand unless requested.
  • for it to not be searched when I do /

I just don't want to be bothered with POD inside the document.

  • Can you give an example or two of embedded POD code? By impervious, do you mean that eg dap with a POD fold shouldnt delete the POD ? What do you mean by pod isnt for programmers (isnt it documentation? Did i misunderstand that?)? – D. Ben Knoble Apr 12 at 1:00
  • POD is only very seldom unfolded. What I mean is I would ideally like to be able to do folding in other places, and when I set the fold level of unfold all, for the pod to stay folded and out of the way. – Evan Carroll Apr 12 at 13:19
1

You can probably use foldexpr to do this.

Here is a gist written by a person on the Internet. It defines a foldexpr function for folding the POD format.

I tried it on a random Perl script I found on this site (warning no https).

The foldexpr seems to work okay. It might work well enough for your use case that you can tweak it.

On the example script I found it managed to hide most but not all of the POD documentation.

+   +-- 11 lines: !/usr/local/bin/perl---------------------------------------------------------------------------------------------------
                                   [--clearDb] [--writeToDb]
                                   --path path --division name
                                   --out name

+   +--  2 lines: Examples:--------------------------------------------------------------------------------------------------------------
        perl parseRefSeqGenomes.pl --help

        perl parseRefSeqGenomes.pl --man

        #   Load all RefSeq data:

        perl parseRefSeqGenomes.pl --clearDb --writeToDb
                                   --path /data/genomes --division bct
                                   --out bct.genomes.pep.fasta

+   +-- 82 lines: =head1 DESCRIPTION-----------------------------------------------------------------------------------------------------
+   +-- 16 lines: package main;----------------------------------------------------------------------------------------------------------
        #   Check arguments.

        my( $help, $man, $clearDb, $writeToDb, $division, $path, $outFileName );

        Getopt::Long::GetOptions(
            'help'          =>  \$help,
            'man'           =>  \$man,
            'clearDb'       =>  \$clearDb,
            'writeToDb'     =>  \$writeToDb,
            'division=s'    =>  \$division,
            'path=s'        =>  \$path,
            'out=s'         =>  \$outFileName );

        #   Check for requests for help or for man (full documentation):

        Pod::Usage::pod2usage( -verbose => 1 ) if ( $help );
example.pl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.