Initial commit.

This commit is contained in:
Sergey Poznyakoff 2011-09-10 14:27:57 +03:00
commit 6ef96c8e5b
9 changed files with 697 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
.emacs*
*~
Makefile
Makefile.in

23
Makefile.am Normal file
View file

@ -0,0 +1,23 @@
# This file is part of Imprimatur.
# Copyright (C) 2011 Sergey Poznyakoff
#
# Imprimatur is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Imprimatur is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST=\
check-docs.sh\
imprimatur.m4\
imprimatur.mk\
mastermenu.el\
rendition.texi\
untabify.el

124
README Normal file
View file

@ -0,0 +1,124 @@
Imprimatur README
Copyright (C) 2011 Sergey Poznyakoff
See the end of file for copying conditions.
* Introduction
This file contains brief information about installing and configuring
Imprimatur. It is *not* intended as a replacement for the
documentation, and is provided as a brief reference only.
The complete documentation will be available soon.
* Overview
Imprimatur provides Texinfo macros for various editing tasks such as
adding editor notes and annotations, as well as makeinfo rules for
verifying texinfo document structure, format, and (to a certain
extent) content coverage.
In particular, it provides a mechanism for verifying whether the
entities, such as command line options, configuration file statements,
library functions, and the like, which are defined in a set of source
files are also described in the Texinfo document.
* Installation
To use Imprimatur in your project, follow these steps:
** Import the package as a submodule
This needs to be done only once:
git submodule add git://git.gnu.org.ua/imprimatur.git imprimatur
git submodule init
The `submodule add' command takes two arguments: the submodule
repository, which should be exactly as shown above, and the pathname
of the cloned submodule in your project. This latter is entirely at
your option. Throughout this document we will suppose that the module
pathname is `imprimatur'. You will need to adjust the examples if you chose
another name for it.
** Edit the toplevel Makefile.am
Add `-I imprimatur' to the ACLOCAL_AMFLAGS variable, and `imprimatur'
to the SUBDIRS variable. For example:
ACLOCAL_AMFLAGS = -I m4 -I imprimatur
SUBDIRS = imprimatur
** Edit the configure.ac file
Add a call to IMPRIMATUR_INIT. Normally no parameters are needed.
However, if you cloned Imprimatur into a directory with another name,
the actual directory name must be supplied as the first argument. For
example, if you used this submodule command
git submodule add git://git.gnu.org.ua/imprimatur.git somedir
then use
IMPRIMATUR_INIT(somedir)
in your configure.ac
** Edit Makefile.am in your doc subdirectory
Apply the following changes to the Makefile.am located in the
subdirectory where you have your Texinfo sources:
1. To AM_MAKEINFOFLAGS add -I $(top_srcdir)/@IMPRIMATUR_MODULE_DIR@
2. Define the variable `imprimatur_INPUT'. It must contain the
names of Texinfo sources to be verified by Imprimatur. Normally,
the following definition is sufficient:
imprimatur_INPUT=$(info_TEXINFOS) $(<BASE>_TEXINFOS)
where <BASE> stands for the base name of your Texinfo document (e.g.
"foo", if it is named "foo.texi").
3. Include @IMPRIMATUR_MODULE_DIR@/imprimatur.mk using relative
addressing. For example, if your documentation subdirectory is
located at the same nesting level as the directory you cloned
Imprimatur to, use:
include ../@IMPRIMATUR_MODULE_DIR@/imprimatur.mk
4. If you plan to use the `check-docs.sh' script, define the following
variable:
CHECK_DOCS=$(top_srcdir)/@IMPRIMATUR_MODULE_DIR@/check-docs.sh
For example:
AM_MAKEINFOFLAGS = -I $(top_srcdir)/@IMPRIMATUR_MODULE_DIR@
imprimatur_INPUT=$(info_TEXINFOS) $(foo_TEXINFOS)
include ../@IMPRIMATUR_MODULE_DIR@/imprimatur.mk
CHECK_DOCS=$(top_srcdir)/@IMPRIMATUR_MODULE_DIR@/check-docs.sh
** Include `rendition.texi' into your main Texinfo source.
* Bug reporting.
Send bug reports to <gray+imprimatur@gnu.org.ua>.
^L
* Copyright information:
Copyright (C) 2011 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
copyright notice and this permission notice are preserved,
thus giving the recipient permission to redistribute in turn.
Permission is granted to distribute modified versions
of this document, or of portions of it,
under the above conditions, provided also that they
carry prominent notices stating who last changed them.
Local Variables:
mode: outline
paragraph-separate: "[ ]*$"
version-control: never
End:

80
check-docs.sh Executable file
View file

@ -0,0 +1,80 @@
#! /bin/sh
# This file is part of Imprimatur.
# Copyright (C) 2006, 2007, 2010, 2011 Sergey Poznyakoff
#
# Imprimatur is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Imprimatur is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
usage() {
cat <<EOT
usage: $0 item code-sed doc-sed sources -- args...
EOT
}
if [ $# -le 4 ]; then
usage
exit 2
fi
item=$1
shift
codesexp="$1"
shift
docsexp=$1
shift
source=
while [ $# -ne 0 ]
do
if [ "$1" = "--" ]; then
shift
break;
fi
source="$source $1"
shift
done
TEMPDIR=/tmp/mfck.$$
mkdir $TEMPDIR || exit 1
trap 'rm -rf $TEMPDIR' 1 2 13 15
ltrim_ws() {
# NOTE: The brackets contain a space and a tab!
sed 's/^[ ][ ]*//'
}
sed -n "$codesexp" $source | ltrim_ws | sort | uniq > $TEMPDIR/src
$* | \
sed -n '/^@macro/,/^@end macro/d;'"$docsexp" | ltrim_ws \
| sort | uniq > $TEMPDIR/doc
join -v1 $TEMPDIR/src $TEMPDIR/doc > $TEMPDIR/src-doc
join -v2 $TEMPDIR/src $TEMPDIR/doc > $TEMPDIR/doc-src
(if [ -s $TEMPDIR/src-doc ]; then
echo "Not documented $item:"
cat $TEMPDIR/src-doc
fi
if [ -s $TEMPDIR/doc-src ]; then
echo "Non-existing $item:"
cat $TEMPDIR/doc-src
fi) > $TEMPDIR/report
if [ -s $TEMPDIR/report ]; then
cat $TEMPDIR/report
rm -rf $TEMPDIR
exit 1
else
rm -rf $TEMPDIR
exit 0
fi

49
imprimatur.m4 Normal file
View file

@ -0,0 +1,49 @@
# imprimatur.m4 serial 1
dnl This file is part of Imprimatur.
dnl Copyright (C) 2011 Sergey Poznyakoff
dnl
dnl Imprimatur is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3, or (at your option)
dnl any later version.
dnl
dnl Imprimatur is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
# IMPRIMATUR_INIT([DIR],[RENDITION])
# DIR - Directory in the source tree where imprimatur has been cloned.
# Default is "imptimatur".
# RENDITION - Documentation rendition. Default is DISTRIB for stable releases
# and PROOF for alpha releases. The release type is determined by
# the version number, assuming GNU versioning.
AC_DEFUN([IMPRIMATUR_INIT],[
m4_pushdef([imprimaturdir],[m4_if([$1],,[imprimatur],[$1])])
AC_SUBST([IMPRIMATUR_MODULE_DIR],imprimaturdir)
AC_CONFIG_FILES(imprimaturdir[/Makefile])
AC_SUBST(RENDITION)
m4_if([$2],,[
# Doc hints.
# Select a rendition level:
# DISTRIB for stable releases (at most one dot in the version number)
# and maintenance releases (two dots, patchlevel < 50)
# PROOF for alpha releases.
# PUBLISH can only be required manually when running make in doc/
case `echo $VERSION|sed 's/[[^.]]//g'` in
""|".") RENDITION=DISTRIB;;
"..") if test `echo $VERSION | sed 's/.*\.//'` -lt 50; then
RENDITION=DISTRIB
else
RENDITION=PROOF
fi;;
*) RENDITION=PROOF;;
esac
],[
RENDITION=$2
])
m4_popdef([imprimaturdir])
])

86
imprimatur.mk Normal file
View file

@ -0,0 +1,86 @@
# This file is part of Imprimatur.
# Copyright (C) 2006, 2007, 2010, 2011 Sergey Poznyakoff
#
# Imprimatur is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# Imprimatur is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
imprimatur-format:
@if test -n "`cat $(imprimatur_INPUT) | tr -d -c '\t'`"; then \
echo "Sources contain tabs; run make imprimatur-untabify"; \
false; \
fi
imprimatur-refs:
@for file in $(imprimatur_INPUT); \
do \
sed -e = $$file | \
sed -n 'N;/@FIXME-.*ref/{s/\(^[0-9][0-9]*\).*@FIXME-.*ref{\([^}]*\)}.*/'$$file':\1: \2/gp}'; \
done > $@-t; \
if [ -s $@-t ]; then \
echo "Unresolved cross-references:"; \
cat $@-t;\
rm $@-t; \
else \
rm -f $@-t; \
fi
imprimatur-fixmes:
@for file in $(imprimatur_INPUT); \
do \
sed -e = $$file | \
sed -n 'N;/@FIXME{/{s/\(^[0-9][0-9]*\).*@FIXME{\([^}]*\).*/'$$file':\1: \2/gp}'; \
done > $@-t; \
if [ -s $@-t ]; then \
echo "Unresolved FIXMEs:"; \
cat $@-t; \
rm $@-t; \
false; \
else \
rm -f $@-t; \
fi
imprimatur-writemes:
@grep -Hn @WRITEME $(imprimatur_INPUT) > $@-t; \
if [ -s $@-t ]; then \
echo "Empty nodes:"; \
cat $@-t; \
rm $@-t; \
false;\
else \
rm $@-t; \
fi
imprimatur-unrevised:
@grep -Hn @UNREVISED $(imprimatur_INPUT) > $@-t; \
if [ -s $@-t ]; then \
echo "Unrevised nodes:"; \
cat $@-t; \
rm $@-t; \
false;\
else \
rm $@-t; \
fi
imprimatur-basic-checks: imprimatur-format imprimatur-refs imprimatur-fixmes \
imprimatur-writemes imprimatur-unrevised
imprimatur-master-menu:
@emacs -batch -l $(IMPRIMATUR_MODULE_DIR)/mastermenu.el -f make-master-menu $(imprimatur_INPUT)
imprimatur-untabify:
@emacs -batch -l $(IMPRIMATUR_MODULE_DIR)/untabify.el $(imprimatur_INPUT)
imprimatur-final: imprimatur-untabify imprimatur-master-menu

83
mastermenu.el Normal file
View file

@ -0,0 +1,83 @@
;; This file is part of Imprimatur.
;; Copyright (C) 2006, 2007, 2010, 2011 Sergey Poznyakoff
;;
;; Imprimatur is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; Imprimatur is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file redefines texinfo-master-menu-list so that it takes into
;; account included files.
;; Known bugs: @menu without previous sectioning command will inherit
;; documentation string from the previous menu. However, since such a
;; menu is illegal in a texinfo file, we can live with it.
(require 'texinfo)
(require 'texnfo-upd)
(defun texinfo-master-menu-list-recursive (title)
"Auxiliary function used by `texinfo-master-menu-list'."
(save-excursion
(let (master-menu-list)
(while (re-search-forward "\\(^@menu\\|^@include\\)" nil t)
(cond
((string= (match-string 0) "@include")
(skip-chars-forward " \t")
(let ((included-name (let ((start (point)))
(end-of-line)
(skip-chars-backward " \t")
(buffer-substring start (point)))))
(end-of-line)
(let ((prev-title (texinfo-copy-menu-title)))
(save-excursion
(set-buffer (find-file-noselect included-name))
(setq master-menu-list
(append (texinfo-master-menu-list-recursive prev-title)
master-menu-list))))))
(t
(setq master-menu-list
(cons (list
(texinfo-copy-menu)
(let ((menu-title (texinfo-copy-menu-title)))
(if (string= menu-title "")
title
menu-title)))
master-menu-list)))))
master-menu-list)))
(defun texinfo-master-menu-list ()
"Return a list of menu entries and header lines for the master menu,
recursing into included files.
Start with the menu for chapters and indices and then find each
following menu and the title of the node preceding that menu.
The master menu list has this form:
\(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\)
\(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\)
...\)
However, there does not need to be a title field."
(reverse (texinfo-master-menu-list-recursive "")))
(defun make-master-menu ()
"Create master menu in the first Emacs argument."
(find-file (car command-line-args-left))
(texinfo-master-menu nil)
(save-buffer))
;;; mastermenu.el ends here

219
rendition.texi Normal file
View file

@ -0,0 +1,219 @@
@c This file is part of Imprimatur.
@c Copyright (C) 2001-2011 Sergey Poznyakoff
@c
@c Imprimatur is free software; you can redistribute it and/or modify
@c it under the terms of the GNU General Public License as published by
@c the Free Software Foundation; either version 3, or (at your option)
@c any later version.
@c
@c Imprimatur is distributed in the hope that it will be useful,
@c but WITHOUT ANY WARRANTY; without even the implied warranty of
@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@c GNU General Public License for more details.
@c
@c You should have received a copy of the GNU General Public License
@c along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
@c ======================================================================
@c This file implements Fra@,{c}ois Pinard's concept of 'renditions':
@c
@c A document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
@c as decided by @set symbols. The PUBLISH rendition does not show
@c notes or marks asking for revision. Nodes marked as unrevised or
@c empty (see below) produce a compilation error in this rendition.
@c It also implies @finalout.
@c
@c Most users will prefer having more information, even if this
@c information is not fully revised for adequacy, so DISTRIB is the
@c default for distributions.
@c
@c The PROOF rendition show all marks to the point of ugliness and is
@c intended for those working on the manual itself.
@c ======================================================================
@ifclear PUBLISH
@ifclear DISTRIB
@ifclear PROOF
@set DISTRIB
@end ifclear
@end ifclear
@end ifclear
@ifset PUBLISH
@set RENDITION The book, version
@finalout
@end ifset
@ifset DISTRIB
@set RENDITION FTP release, version
@end ifset
@ifset PROOF
@set RENDITION Proof reading version
@end ifset
@c ------------------------------------------------------------------
@c @editorsnote{text} -- emit an editor note.
@c Cannot be used inline.
@c ------------------------------------------------------------------
@macro editorsnote{text}
@ifinfo
@quotation
@center ==========================================================
@center @strong{Editor's note:} \text\@*
@center ==========================================================
@end quotation
@end ifinfo
@ifnotinfo
@cartouche
@center @strong{Editor's note:} \text\
@end cartouche
@end ifnotinfo
@end macro
@c ------------------------------------------------------------------
@c @WRITEME -- Indicate that the node is to be written.
@c
@c In PUBLISH mode, this produces a compilation error.
@c Otherwise, this macro emits a prominent editor's notice stating
@c that this node has yet to be written.
@c
@c The \errmessage function is used to indicate error when producing
@c TeX output. Otherwise, a call to undefined macro with
@c self-explaining name ``Empty-node-in-publish-rendition!'' is used.
@c ------------------------------------------------------------------
@unmacro Empty-node-in-publish-rendition!
@macro WRITEME
@ifset PUBLISH
@iftex
@errmessage{Empty node in publish rendition!}
@end iftex
@ifnottex
@comment There is no errmessage function in makeinfo nor in texi2html,
@comment so we use this command call to generate a compilation error.
@comment There is no such function, and to be on the safe side we
@comment undefined a macro with this name.
@Empty-node-in-publish-rendition!
@end ifnottex
@end ifset
@ifclear PUBLISH
@editorsnote{This node is to be written.}
@end ifclear
@end macro
@c ------------------------------------------------------------------
@c @UNREVISED -- Indicate that the node needs revision.
@c
@c In PUBLISH mode, this produces a compilation error.
@c Otherwise, this macro emits a prominent editor's notice stating
@c that this node is not revised.
@c
@c The \errmessage function is used to indicate error when producing
@c TeX output. Otherwise, a call to undefined macro with
@c self-explaining name ``Unrevised-node-in-publish-rendition!'' is
@c used.
@c ------------------------------------------------------------------
@unmacro Unrevised-node-in-publish-rendition!
@macro UNREVISED
@ifset PUBLISH
@iftex
@errmessage{Unrevised node in publish rendition!}
@end iftex
@ifnottex
@comment There is no errmessage function in makeinfo nor in texi2html,
@comment so we use this command call to generate a compilation error.
@comment There is no such function, and to be on the safe side we
@comment undefined a macro with this name.
@Unrevised-node-in-publish-rendition!
@end ifnottex
@end ifset
@ifclear PUBLISH
@editorsnote{The information in this node may be obsolete or
otherwise inaccurate. This message will disappear, once this node revised.}
@end ifclear
@end macro
@c ------------------------------------------------------------------
@c @FIXME{text} -- Output an editor's notice only in PROOF rendition.
@c ------------------------------------------------------------------
@ifset PROOF
@macro FIXME{string}
@sp 1
@editorsnote{\string\}
@w{}
@end macro
@end ifset
@ifclear PROOF
@macro FIXME{string}
@end macro
@end ifclear
@c ------------------------------------------------------------------
@c @deadlink{} -- emit a dead link notice.
@c This macro depends on the PROOF flag. Since it is used inline,
@c it has to be defined twice: one instance for when PROOF is set,
@c and another one for when it is cleared.
@c ------------------------------------------------------------------
@ifset PROOF
@macro deadlink{}
@ (@strong{Editor's note: dangling link})
@end macro
@end ifset
@ifclear PROOF
@macro deadlink{}
@end macro
@end ifclear
@c ------------------------------------------------------------------
@c @FIXMEREF{text, string} -- output a reference to (possibly)
@c undefined anchor. The `text' argument is usually ``see'' or
@c ``See'', depending on context. The `string' argument is the cross
@c reference text.
@c In PROOF mode, a dangling link notice is output after the
@c reference.
@c
@c This macro is used inline, so again, it is defined several times,
@c for various output formats.
@c ------------------------------------------------------------------
@ifhtml
@macro FIXMEREF{text,string}
@html
\text\ <span class="deadlink">\string\</span>
@end html
@deadlink{}
@end macro
@end ifhtml
@ifnothtml
@macro FIXMEREF{text,string}
\text\ @i{\string\}@deadlink{}
@end macro
@end ifnothtml
@c ------------------------------------------------------------------
@c @FIXME-ref{node} -- produces a @ref-style reference to undefined
@c node.
@c ------------------------------------------------------------------
@macro FIXME-ref{string}
@FIXMEREF{,\string\}
@end macro
@c ------------------------------------------------------------------
@c @FIXME-pxref{node} -- produces a @pxref-style reference to
@c undefined node.
@c ------------------------------------------------------------------
@macro FIXME-pxref{string}
@FIXMEREF{see,\string\}
@end macro
@c ------------------------------------------------------------------
@c @FIXME-xref{node} -- produces a @xref-style reference to
@c undefined node.
@c ------------------------------------------------------------------
@macro FIXME-xref{string}
@FIXMEREF{See,\string\}
@end macro

29
untabify.el Normal file
View file

@ -0,0 +1,29 @@
;; This file is part of Imprimatur.
;; Copyright (C) 2006, 2007, 2010, 2011 Sergey Poznyakoff
;;
;; Imprimatur is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; Imprimatur is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Imprimatur. If not, see <http://www.gnu.org/licenses/>.
;;;; Untabify the sources.
;;;; Usage: emacs -batch -l untabify.el [file ...]
(defun global-untabify (buflist)
(mapcar
(lambda (bufname)
(set-buffer (find-file bufname))
(untabify (point-min) (point-max))
(save-buffer)
(kill-buffer (current-buffer)))
buflist))
(global-untabify command-line-args-left)