Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
pod documentation in zsh scripts (Was: Block comments ala Ray)
- X-seq: zsh-workers 48071
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Juergen Christoffel <jc+zsh@xxxxxxxxx>
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: pod documentation in zsh scripts (Was: Block comments ala Ray)
- Date: Tue, 16 Feb 2021 18:21:31 +0000
- Archived-at: <https://zsh.org/workers/48071>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2021-02/20210216182131.xcmynfwgobuh3wlt%40chazelas.org>
- In-reply-to: <20210216153049.GA8000@unser.net>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Juergen Christoffel <jc+zsh@xxxxxxxxx>, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7YZREq7FbJCCoWoJ-vQ7+P5Z=_mKB-aStoMiBRupqD_wA@mail.gmail.com> <20210216153049.GA8000@unser.net>
2021-02-16 16:30:49 +0100, Juergen Christoffel:
[...]
> That said, wouldn't it be possible to augment the comment parsing to use
> something like perl's "plain old documentation" (pod) meachnism, e.g.
[...]
> P.S. Even the use of the here document for block comments look less
> horrible to me, because it's easily recognized when looking at a script.
[...]
As discussed earlier in this thread, here docs can already be
(ab)used to add pod documentation to zsh scripts. An example one
could look like:
#! /bin/zsh -
for a (pod head{1..4} over item back begin end for encoding)
aliases[=$a]=":||:<<'=cut' #"
=encoding utf8
=head1 NAME
mytool - blah
=head1 SYNOPSIS
B<mytool> [B<-f>] [B<-h>] [B<-o> I<flag>]...
=head1 DESCRIPTION
B<mytool> does cool stuff
=head1 OPTIONS
=over
=cut
flag=false
opt=()
while getopts hfo: o; do
case $o in
(f) flag=true
=item B<-f>
turns a flag on
=cut
;;(o) opt+=("$OPTARG")
=item B<-o> I<opt>
to pass some optional value
=cut
;;(h) LESS=${LESS}RFX exec perldoc -oterm $0:P
=item B<-h>
show this manual.
=back
=cut
;;(*) exit 1
esac
done
=head1 AUTHOR
Stéphane
=cut
Messages sorted by:
Reverse Date,
Date,
Thread,
Author