diff options
author | June McEnroe <june@causal.agency> | 2021-01-18 16:56:05 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-01-18 16:56:05 -0500 |
commit | 73f6b84e9cfd045d68e30727a57dbd94ad8ae397 (patch) | |
tree | a59c6c02b7d0240153c5bcb2ea56ae9f0c999b38 | |
parent | Publish "reusing tags" (diff) | |
download | src-73f6b84e9cfd045d68e30727a57dbd94ad8ae397.tar.gz src-73f6b84e9cfd045d68e30727a57dbd94ad8ae397.zip |
Don't compress RFCs, add rfc(1) command
-rw-r--r-- | doc/rfc/.gitignore | 5 | ||||
-rw-r--r-- | doc/rfc/Makefile | 39 | ||||
-rw-r--r-- | doc/rfc/rfc.1 | 53 | ||||
-rw-r--r-- | doc/rfc/rfc.in | 8 | ||||
-rw-r--r-- | doc/rfc/rfc.vim | 6 | ||||
-rw-r--r-- | doc/rfc/rfctags.pl | 9 |
6 files changed, 98 insertions, 22 deletions
diff --git a/doc/rfc/.gitignore b/doc/rfc/.gitignore index 808cd63e..cc3245d4 100644 --- a/doc/rfc/.gitignore +++ b/doc/rfc/.gitignore @@ -1,3 +1,2 @@ -*.txt -*.txt.gz -tags +rfc +rfctags diff --git a/doc/rfc/Makefile b/doc/rfc/Makefile index 87462a6c..445e1163 100644 --- a/doc/rfc/Makefile +++ b/doc/rfc/Makefile @@ -1,21 +1,40 @@ PREFIX ?= ~/.local +MANDIR ?= ${PREFIX}/share/man +BINS = rfc rfctags MODULE = ftp.rfc-editor.org::rfcs-text-only +RFCS = ${MODULE}/rfc-index.txt ${MODULE}/'rfc[1-9]*.txt' -tags: rfctags.pl rfc-index.txt.gz - perl rfctags.pl | sort -f > $@ +all: ${BINS} -rfc-index.txt.gz: - rsync -ptz ${MODULE}/rfc-index.txt ${MODULE}/'rfc[1-9]*.txt' . - gzip -9f *.txt +.SUFFIXES: .in .pl + +.in: + sed 's|%%PREFIX%%|${PREFIX}|g' $< > $@ + chmod a+x $@ + +.pl: + cp -f $< $@ + chmod a+x $@ clean: - rm -f tags *.txt *.txt.gz + rm -f ${BINS} + +install: ${BINS} rfc.1 + install -d ${PREFIX}/bin ${MANDIR}/man1 ${PREFIX}/share + install ${BINS} ${PREFIX}/bin + install -m 644 rfc.1 ${MANDIR}/man1 + ln -fs rfc.1 ${MANDIR}/man1/rfctags.1 + rsync -ptz ${RFCS} ${PREFIX}/share/rfc -install: tags rfc.vim - install -d ${PREFIX}/share/rfc ${PREFIX}/share/nvim/site/plugin - ln -f tags *.txt.gz ${PREFIX}/share/rfc +install-nvim: install rfc.vim + install -d ${PREFIX}/share/nvim/site/plugin install -m 644 rfc.vim ${PREFIX}/share/nvim/site/plugin + (cd ${PREFIX}/share/rfc \ + && printf '!_TAG_FILE_SORTED\t2\ttags\n' \ + && ${PREFIX}/bin/rfctags *.txt) | sort -f > ${PREFIX}/share/rfc/tags uninstall: - rm -fr ${PREFIX}/share/rfc ${PREFIX}/share/nvim/site/plugin/rfc.vim + rm -f ${BINS:%=${PREFIX}/bin/%} ${BINS:%=${MANDIR}/man1/%.1} + rm -f ${PREFIX}/share/nvim/site/plugin/rfc.vim + rm -fr ${PREFIX}/share/rfc diff --git a/doc/rfc/rfc.1 b/doc/rfc/rfc.1 new file mode 100644 index 00000000..ece5a901 --- /dev/null +++ b/doc/rfc/rfc.1 @@ -0,0 +1,53 @@ +.Dd January 18, 2021 +.Dt RFC 1 +.Os +. +.Sh NAME +.Nm rfc , +.Nm rfctags +.Nd view IETF RFCs +. +.Sh SYNOPSIS +.Nm rfc +.Op Ar number +.Nm rfctags +.Op Ar +. +.Sh DESCRIPTION +The +.Nm rfc +utility displays +an IETF RFC by number, +or the RFC index if no number is specified. +The RFC is displayed in the +.Ev PAGER +with a tags file generated by +.Nm rfctags . +. +.Pp +The +.Nm rfctags +utility generates tags +for RFC text file +section numbers, +section names +and bracketed references. +. +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It Ev PAGER +The program used to display RFCs. +It must accept the +.Fl T +flag for specifying +the path of the tags file. +The default is +.Ev PAGER=less . +.El +. +.Sh SEE ALSO +.Xr ctags 1 , +.Xr less 1 +. +.Sh AUTHORS +.An June Bug Aq Mt june@causal.agency diff --git a/doc/rfc/rfc.in b/doc/rfc/rfc.in new file mode 100644 index 00000000..adf297eb --- /dev/null +++ b/doc/rfc/rfc.in @@ -0,0 +1,8 @@ +#!/bin/sh +set -eu + +rfc=%%PREFIX%%/share/rfc/"rfc${1:--index}.txt" +tags=$(mktemp -t rfc) +trap 'rm "${tags}"' EXIT +%%PREFIX%%/bin/rfctags "${rfc}" >"${tags}" +${PAGER:-less} -T "${tags}" "${rfc}" diff --git a/doc/rfc/rfc.vim b/doc/rfc/rfc.vim index 2455d8a6..4649cdf5 100644 --- a/doc/rfc/rfc.vim +++ b/doc/rfc/rfc.vim @@ -1,5 +1,5 @@ if !exists('g:rfc_path') - let g:rfc_path = expand('<sfile>:h:h:h:h') . '/rfc' + let g:rfc_path = fnamemodify(exepath('rfc'), ':h:h') . '/share/rfc' endif function! s:RFC(number) @@ -8,7 +8,7 @@ function! s:RFC(number) else let number = '-index' endif - let path = expand(g:rfc_path . '/rfc' . number . '.txt.gz') + let path = expand(g:rfc_path . '/rfc' . number . '.txt') if filereadable(path) execute 'silent' 'noswapfile' 'view' path else @@ -26,5 +26,5 @@ endfunction command! -bar -nargs=? RFC call s:RFC(<q-args>) augroup RFC autocmd! - autocmd BufRead rfc*.txt.gz call s:BufRead() + autocmd BufRead rfc*.txt call s:BufRead() augroup END diff --git a/doc/rfc/rfctags.pl b/doc/rfc/rfctags.pl index 01324a0d..45e74f9a 100644 --- a/doc/rfc/rfctags.pl +++ b/doc/rfc/rfctags.pl @@ -1,14 +1,11 @@ +#!/usr/bin/env perl use strict; use warnings; use open ':encoding(ISO-8859-1)'; -use IO::Uncompress::Gunzip qw($GunzipError); - ($,, $\) = ("\t", "\n"); -print '!_TAG_FILE_SORTED', 2, $0; # Promise to pipe this through sort -f -for my $rfc (<*.txt.gz>) { - my $handle = new IO::Uncompress::Gunzip $rfc - or die "${rfc}: ${GunzipError}"; +for my $rfc (@ARGV) { + open my $handle, '<', $rfc or die "${rfc}: $!"; while (<$handle>) { chomp; # Section headings |