[alexandria.git] updated branch master: 829db7c... documentation updates

Nikodemus Siivola nsiivola at common-lisp.net
Tue Mar 9 16:53:04 UTC 2010


The branch master has been updated:
       via  829db7c7cb06d0a1693af9d25292d666be3eb487 (commit)
       via  b098d0fdb56da9a7ab7c040a6afd5d0b3e38208d (commit)
      from  01a5b9bfcf13f927c38c59b3ad90bece3c0ecf2a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 829db7c7cb06d0a1693af9d25292d666be3eb487
Author: Nikodemus Siivola <nikodemus at random-state.net>
Date:   Tue Mar 9 18:51:46 2010 +0200

    documentation updates
    
      Add bunch of missing symbols to the manual, and go over several
      docstrings reformatting them for the benefit of the documentation
      generator.
    
      (A crapton of symbols are still not in the manual.)

commit b098d0fdb56da9a7ab7c040a6afd5d0b3e38208d
Author: Nikodemus Siivola <nikodemus at random-state.net>
Date:   Tue Mar 9 18:50:29 2010 +0200

    copy docstrings.lisp from SBCL
    
      Easier to work with like this. Note: the code has already mutated a bit.

-----------------------------------------------------------------------

Summary of changes:
 arrays.lisp            |    9 +-
 control-flow.lisp      |    4 +-
 doc/Makefile           |    7 +-
 doc/alexandria.texinfo |  138 +++++---
 doc/docstrings.lisp    |  864 ++++++++++++++++++++++++++++++++++++++++++++++++
 functions.lisp         |    1 +
 lists.lisp             |   13 +-
 macros.lisp            |   49 ++-
 numbers.lisp           |    2 +-
 package.lisp           |    2 +-
 sequences.lisp         |   13 +-
 symbols.lisp           |    5 +-
 12 files changed, 1021 insertions(+), 86 deletions(-)
 create mode 100644 doc/docstrings.lisp

diff --git a/arrays.lisp b/arrays.lisp
index 146d7d3..670880f 100644
--- a/arrays.lisp
+++ b/arrays.lisp
@@ -5,9 +5,11 @@
                    (fill-pointer (and (array-has-fill-pointer-p array)
                                       (fill-pointer array)))
                    (adjustable (adjustable-array-p array)))
-  "Returns an undisplaced copy of ARRAY, with same fill-pointer
-and adjustability (if any) as the original, unless overridden by
-the keyword arguments."
+  "Returns an undisplaced copy of ARRAY, with same fill-pointer and
+adjustability (if any) as the original, unless overridden by the keyword
+arguments. Performance depends on efficiency of general ADJUST-ARRAY in the
+host lisp -- for most cases a special purpose copying function is likely to
+perform better."
   (let ((dims (array-dimensions array)))
     ;; Dictionary entry for ADJUST-ARRAY requires adjusting a
     ;; displaced array to a non-displaced one to make a copy.
@@ -16,4 +18,3 @@ the keyword arguments."
                  :element-type element-type :fill-pointer fill-pointer
                  :adjustable adjustable :displaced-to array)
      dims)))
-
diff --git a/control-flow.lisp b/control-flow.lisp
index bf64728..0aafb2a 100644
--- a/control-flow.lisp
+++ b/control-flow.lisp
@@ -88,8 +88,8 @@ value."
 
 (defmacro nth-value-or (nth-value &body forms)
   "Evaluates FORM arguments one at a time, until the NTH-VALUE returned by one
-of the forms is non-NIL. It then returns all the values returned by evaluating
-that form. If none of the forms return a non-nil nth value, this form returns
+of the forms is true. It then returns all the values returned by evaluating
+that form. If none of the forms return a true nth value, this form returns
 NIL."
   (once-only (nth-value)
     (with-gensyms (values)
diff --git a/doc/Makefile b/doc/Makefile
index 5ae667c..0782a87 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -6,11 +6,10 @@ clean:
 # Hook into the super sekrit texinfo generator in the SBCL tree -- this is just a quick way
 # to bootrap documentation for now.
 include:
-	sbcl --eval '(progn (require :asdf) (require :alexandria) (rename-package :alexandria :alexandria))' \
-	--eval '(load (merge-pathnames "doc/manual/docstrings.lisp" (posix-getenv "SBCL_SOURCE_ROOT")))' \
-	--eval '(sb-texinfo:generate-includes "include/" :alexandria)' \
+	sbcl --eval '(progn (require :asdf) (require :alexandria))' \
+	--load docstrings.lisp \
+	--eval '(sb-texinfo:generate-includes "include/" (list :alexandria) :base-package :alexandria)' \
 	--eval '(quit)'
-	mv include/fun-alexandria-type=.texinfo include/fun-alexandria-type-equal.texinfo
 
 pdf: include
 	texi2pdf alexandria.texinfo
diff --git a/doc/alexandria.texinfo b/doc/alexandria.texinfo
index fc620dd..d9b23ce 100644
--- a/doc/alexandria.texinfo
+++ b/doc/alexandria.texinfo
@@ -13,10 +13,10 @@
 @end direntry
 
 @copying
- at quotation
 Alexandria software and associated documentation are in the public
 domain:
 
+ at quotation
   Authors dedicate this work to public domain, for the benefit of the
   public at large and to the detriment of the authors' heirs and
   successors. Authors intends this dedication to be an overt act of
@@ -31,11 +31,13 @@ domain:
   built upon, or otherwise exploited by anyone for any purpose,
   commercial or non-commercial, and in any way, including by methods
   that have not yet been invented or conceived.
+ at end quotation
 
 In those legislations where public domain dedications are not
 recognized or possible, Alexandria is distributed under the following
 terms and conditions:
 
+ at quotation
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
   (the "Software"), to deal in the Software without restriction,
@@ -70,19 +72,6 @@ terms and conditions:
 
 @ifnottex
 
- at menu
-* Hash Table Utilities::        
-* Higher Order Functions::      
-* List Manipulation::           
-* Sequence Manipulation::       
-* Macro Writing Utilities::     
-* Symbol Utilities::            
-* Array Utilities::             
-* Type Designator Manipulation::  
-* Mathematical Utilities::      
-* Features::                    
- at end menu
-
 @node Top
 @comment  node-name,  next,  previous,  up
 @top sbcl
@@ -90,14 +79,24 @@ terms and conditions:
 @insertcopying
 
 @menu
+* Hash Tables::                 
+* Data and Control Flow::       
+* Conses::                      
+* Sequences::                   
+* Macro Writing::               
+* Symbols::                     
+* Arrays::                      
+* Types::                       
+* Numbers::                     
 @end menu
 
 @end ifnottex
 
- at node Hash Table Utilities
+ at node Hash Tables
 @comment  node-name,  next,  previous,  up
- at section Hash Table Utilities
+ at chapter Hash Tables
 
+ at include include/fun-alexandria-ensure-gethash.texinfo
 @include include/fun-alexandria-copy-hash-table.texinfo
 @include include/fun-alexandria-maphash-keys.texinfo
 @include include/fun-alexandria-maphash-values.texinfo
@@ -108,43 +107,76 @@ terms and conditions:
 @include include/fun-alexandria-alist-hash-table.texinfo
 @include include/fun-alexandria-plist-hash-table.texinfo
 
- at node Higher Order Functions
+ at node Data and Control Flow
 @comment  node-name,  next,  previous,  up
- at section Higher Order Functions
+ at chapter Data and Control Flow
+
+ at include include/macro-alexandria-define-constant.texinfo
+ at include include/macro-alexandria-ensure-functionf.texinfo
+ at include include/macro-alexandria-multiple-value-prog2.texinfo
+ at include include/macro-alexandria-named-lambda.texinfo
+ at include include/macro-alexandria-nth-value-or.texinfo
+ at include include/macro-alexandria-if-let.texinfo
+ at include include/macro-alexandria-when-let.texinfo
+ at include include/macro-alexandria-when-let-star.texinfo
+ at include include/macro-alexandria-switch.texinfo
+ at include include/macro-alexandria-cswitch.texinfo
+ at include include/macro-alexandria-eswitch.texinfo
+ at include include/macro-alexandria-whichever.texinfo
+ at include include/macro-alexandria-xor.texinfo
 
 @include include/fun-alexandria-disjoin.texinfo
 @include include/fun-alexandria-conjoin.texinfo
 @include include/fun-alexandria-compose.texinfo
+ at include include/fun-alexandria-ensure-function.texinfo
 @include include/fun-alexandria-multiple-value-compose.texinfo
 @include include/fun-alexandria-curry.texinfo
 @include include/fun-alexandria-rcurry.texinfo
 
- at node List Manipulation
+ at node Conses
 @comment  node-name,  next,  previous,  up
- at section List Manipulation
+ at chapter Conses
 
 @include include/type-alexandria-proper-list.texinfo
 @include include/type-alexandria-circular-list.texinfo
+
 @include include/macro-alexandria-appendf.texinfo
 @include include/macro-alexandria-nconcf.texinfo
- at include include/fun-alexandria-circular-list.texinfo
+ at include include/macro-alexandria-remove-from-plistf.texinfo
+ at include include/macro-alexandria-delete-from-plistf.texinfo
+ at include include/macro-alexandria-reversef.texinfo
+ at include include/macro-alexandria-nreversef.texinfo
+ at include include/macro-alexandria-unionf.texinfo
+ at include include/macro-alexandria-nunionf.texinfo
+
+ at include include/macro-alexandria-doplist.texinfo
+
 @include include/fun-alexandria-circular-list-p.texinfo
 @include include/fun-alexandria-circular-tree-p.texinfo
 @include include/fun-alexandria-proper-list-p.texinfo
+
+ at include include/fun-alexandria-alist-plist.texinfo
+ at include include/fun-alexandria-plist-alist.texinfo
+ at include include/fun-alexandria-circular-list.texinfo
+ at include include/fun-alexandria-make-circular-list.texinfo
+ at include include/fun-alexandria-ensure-car.texinfo
+ at include include/fun-alexandria-ensure-cons.texinfo
+ at include include/fun-alexandria-ensure-list.texinfo
+ at include include/fun-alexandria-flatten.texinfo
 @include include/fun-alexandria-lastcar.texinfo
 @include include/fun-alexandria-setf-lastcar.texinfo
+ at include include/fun-alexandria-proper-list-length.texinfo
 @include include/fun-alexandria-make-circular-list.texinfo
- at include include/fun-alexandria-ensure-list.texinfo
- at include include/fun-alexandria-sans.texinfo
 @include include/fun-alexandria-mappend.texinfo
 @include include/fun-alexandria-map-product.texinfo
+ at include include/fun-alexandria-remove-from-plist.texinfo
+ at include include/fun-alexandria-delete-from-plist.texinfo
 @include include/fun-alexandria-set-equal.texinfo
 @include include/fun-alexandria-setp.texinfo
- at include include/fun-alexandria-flatten.texinfo
 
- at node Sequence Manipulation
+ at node Sequences
 @comment  node-name,  next,  previous,  up
- at section Sequence Manipulation
+ at chapter Sequences
 
 @include include/type-alexandria-proper-sequence.texinfo
 
@@ -152,70 +184,82 @@ terms and conditions:
 @include include/macro-alexandria-removef.texinfo
 
 @include include/fun-alexandria-rotate.texinfo
- at include include/fun-alexandria-suffle.texinfo
+ at include include/fun-alexandria-shuffle.texinfo
 @include include/fun-alexandria-random-elt.texinfo
 @include include/fun-alexandria-emptyp.texinfo
 @include include/fun-alexandria-sequence-of-length-p.texinfo
+ at include include/fun-alexandria-length-equals.texinfo
 @include include/fun-alexandria-copy-sequence.texinfo
 @include include/fun-alexandria-first-elt.texinfo
 @include include/fun-alexandria-setf-first-elt.texinfo
 @include include/fun-alexandria-last-elt.texinfo
 @include include/fun-alexandria-setf-last-elt.texinfo
 @include include/fun-alexandria-starts-with.texinfo
+ at include include/fun-alexandria-starts-with-subseq.texinfo
 @include include/fun-alexandria-ends-with.texinfo
+ at include include/fun-alexandria-ends-with-subseq.texinfo
+ at include include/fun-alexandria-map-combinations.texinfo
+ at include include/fun-alexandria-map-derangements.texinfo
+ at include include/fun-alexandria-map-permutations.texinfo
 
- at node Macro Writing Utilities
+ at node Macro Writing
 @comment  node-name,  next,  previous,  up
- at section Macro Writing Utilities
+ at chapter Macro Writing
 
- at include include/macro-alexandria-with-unique-names.texinfo
 @include include/macro-alexandria-once-only.texinfo
+ at include include/macro-alexandria-with-gensyms.texinfo
+ at include include/macro-alexandria-with-unique-names.texinfo
+ at include include/fun-alexandria-featurep.texinfo
+ at include include/fun-alexandria-parse-body.texinfo
+ at include include/fun-alexandria-parse-ordinary-lambda-list.texinfo
 
- at node Symbol Utilities
+ at node Symbols
 @comment  node-name,  next,  previous,  up
- at section Symbol Utilities
+ at chapter Symbols
 
 @include include/fun-alexandria-ensure-symbol.texinfo
 @include include/fun-alexandria-format-symbol.texinfo
 @include include/fun-alexandria-make-keyword.texinfo
+ at include include/fun-alexandria-make-gensym.texinfo
 @include include/fun-alexandria-make-gensym-list.texinfo
+ at include include/fun-alexandria-symbolicate.texinfo
 
- at node Array Utilities
+ at node Arrays
 @comment  node-name,  next,  previous,  up
- at section Array Utilities
+ at chapter Arrays
 
 @include include/type-alexandria-array-index.texinfo
+ at include include/type-alexandria-array-length.texinfo
 @include include/fun-alexandria-copy-array.texinfo
 
- at node Type Designator Manipulation
+ at node Types
 @comment  node-name,  next,  previous,  up
- at section Type Designator Manipulation
+ at chapter Types
 
- at include include/fun-alexandria-of-type.texinfo
- at include include/fun-alexandria-type-equal.texinfo
+ at include include/type-alexandria-string-designator.texinfo
 @include include/macro-alexandria-coercef.texinfo
+ at include include/fun-alexandria-of-type.texinfo
+ at include include/fun-alexandria-type-equals.texinfo
 
- at node Mathematical Utilities
+ at node Numbers
 @comment  node-name,  next,  previous,  up
- at section Mathematical Utilities
+ at chapter Numbers
 
 @include include/macro-alexandria-maxf.texinfo
 @include include/macro-alexandria-minf.texinfo
 
+ at include include/fun-alexandria-binomial-coefficient.texinfo
+ at include include/fun-alexandria-count-permutations.texinfo
 @include include/fun-alexandria-clamp.texinfo
 @include include/fun-alexandria-lerp.texinfo
+ at include include/fun-alexandria-factorial.texinfo
+ at include include/fun-alexandria-subfactorial.texinfo
 @include include/fun-alexandria-gaussian-random.texinfo
 @include include/fun-alexandria-iota.texinfo
+ at include include/fun-alexandria-map-iota.texinfo
 @include include/fun-alexandria-mean.texinfo
 @include include/fun-alexandria-median.texinfo
 @include include/fun-alexandria-variance.texinfo
 @include include/fun-alexandria-standard-deviation.texinfo
 
- at c FIXME: get a better section name
- at node Features
- at comment  node-name,  next,  previous,  up
- at section Features
-
- at include include/fun-alexandria-featurep.texinfo
-
 @bye
diff --git a/doc/docstrings.lisp b/doc/docstrings.lisp
new file mode 100644
index 0000000..2ff7dff
--- /dev/null
+++ b/doc/docstrings.lisp
@@ -0,0 +1,864 @@
+;;; -*- lisp -*-
+
+;;;; A docstring extractor for the sbcl manual.  Creates
+;;;; @include-ready documentation from the docstrings of exported
+;;;; symbols of specified packages.
+
+;;;; This software is part of the SBCL software system. SBCL is in the
+;;;; public domain and is provided with absolutely no warranty. See
+;;;; the COPYING file for more information.
+;;;;
+;;;; Written by Rudi Schlatte <rudi at constantly.at>, mangled
+;;;; by Nikodemus Siivola.
+
+;;;; TODO
+;;;; * Verbatim text
+;;;; * Quotations
+;;;; * Method documentation untested
+;;;; * Method sorting, somehow
+;;;; * Index for macros & constants?
+;;;; * This is getting complicated enough that tests would be good
+;;;; * Nesting (currently only nested itemizations work)
+;;;; * doc -> internal form -> texinfo (so that non-texinfo format are also
+;;;;   easily generated)
+
+;;;; FIXME: The description below is no longer complete. This
+;;;; should possibly be turned into a contrib with proper documentation.
+
+;;;; Formatting heuristics (tweaked to format SAVE-LISP-AND-DIE sanely):
+;;;;
+;;;; Formats SYMBOL as @code{symbol}, or @var{symbol} if symbol is in
+;;;; the argument list of the defun / defmacro.
+;;;;
+;;;; Lines starting with * or - that are followed by intented lines
+;;;; are marked up with @itemize.
+;;;;
+;;;; Lines containing only a SYMBOL that are followed by indented
+;;;; lines are marked up as @table @code, with the SYMBOL as the item.
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (require 'sb-introspect))
+
+(defpackage :sb-texinfo
+  (:use :cl :sb-mop)
+  (:shadow #:documentation)
+  (:export #:generate-includes #:document-package)
+  (:documentation
+   "Tools to generate TexInfo documentation from docstrings."))
+
+(in-package :sb-texinfo)
+
+;;;; various specials and parameters
+
+(defvar *texinfo-output*)
+(defvar *texinfo-variables*)
+(defvar *documentation-package*)
+(defvar *base-package*)
+
+(defparameter *undocumented-packages* '(sb-pcl sb-int sb-kernel sb-sys sb-c))
+
+(defparameter *documentation-types*
+  '(compiler-macro
+    function
+    method-combination
+    setf
+    ;;structure  ; also handled by `type'
+    type
+    variable)
+  "A list of symbols accepted as second argument of `documentation'")
+
+(defparameter *character-replacements*
+  '((#\* . "star") (#\/ . "slash") (#\+ . "plus")
+    (#\< . "lt") (#\> . "gt")
+    (#\= . "equals"))
+  "Characters and their replacement names that `alphanumize' uses. If
+the replacements contain any of the chars they're supposed to replace,
+you deserve to lose.")
+
+(defparameter *characters-to-drop* '(#\\ #\` #\')
+  "Characters that should be removed by `alphanumize'.")
+
+(defparameter *texinfo-escaped-chars* "@{}"
+  "Characters that must be escaped with #\@ for Texinfo.")
+
+(defparameter *itemize-start-characters* '(#\* #\-)
+  "Characters that might start an itemization in docstrings when
+  at the start of a line.")
+
+(defparameter *symbol-characters* "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*:-+&#'"
+  "List of characters that make up symbols in a docstring.")
+
+(defparameter *symbol-delimiters* " ,.!?;")
+
+(defparameter *ordered-documentation-kinds*
+  '(package type structure condition class macro))
+
+;;;; utilities
+
+(defun flatten (list)
+  (cond ((null list)
+         nil)
+        ((consp (car list))
+         (nconc (flatten (car list)) (flatten (cdr list))))
+        ((null (cdr list))
+         (cons (car list) nil))
+        (t
+         (cons (car list) (flatten (cdr list))))))
+
+(defun whitespacep (char)
+  (find char #(#\tab #\space #\page)))
+
+(defun setf-name-p (name)
+  (or (symbolp name)
+      (and (listp name) (= 2 (length name)) (eq (car name) 'setf))))
+
+(defgeneric specializer-name (specializer))
+
+(defmethod specializer-name ((specializer eql-specializer))
+  (list 'eql (eql-specializer-object specializer)))
+
+(defmethod specializer-name ((specializer class))
+  (class-name specializer))
+
+(defun ensure-class-precedence-list (class)
+  (unless (class-finalized-p class)
+    (finalize-inheritance class))
+  (class-precedence-list class))
+
+(defun specialized-lambda-list (method)
+  ;; courtecy of AMOP p. 61
+  (let* ((specializers (method-specializers method))
+         (lambda-list (method-lambda-list method))
+         (n-required (length specializers)))
+    (append (mapcar (lambda (arg specializer)
+                      (if  (eq specializer (find-class 't))
+                           arg
+                           `(,arg ,(specializer-name specializer))))
+                    (subseq lambda-list 0 n-required)
+                    specializers)
+           (subseq lambda-list n-required))))
+
+(defun string-lines (string)
+  "Lines in STRING as a vector."
+  (coerce (with-input-from-string (s string)
+            (loop for line = (read-line s nil nil)
+               while line collect line))
+          'vector))
+
+(defun indentation (line)
+  "Position of first non-SPACE character in LINE."
+  (position-if-not (lambda (c) (char= c #\Space)) line))
+
+(defun docstring (x doc-type)
+  (cl:documentation x doc-type))
+
+(defun flatten-to-string (list)
+  (format nil "~{~A~^-~}" (flatten list)))
+
+(defun alphanumize (original)
+  "Construct a string without characters like *`' that will f-star-ck
+up filename handling. See `*character-replacements*' and
+`*characters-to-drop*' for customization."
+  (let ((name (remove-if (lambda (x) (member x *characters-to-drop*))
+                         (if (listp original)
+                             (flatten-to-string original)
+                             (string original))))
+        (chars-to-replace (mapcar #'car *character-replacements*)))
+    (flet ((replacement-delimiter (index)
+             (cond ((or (< index 0) (>= index (length name))) "")
+                   ((alphanumericp (char name index)) "-")
+                   (t ""))))
+      (loop for index = (position-if #'(lambda (x) (member x chars-to-replace))
+                                     name)
+         while index
+         do (setf name (concatenate 'string (subseq name 0 index)
+                                    (replacement-delimiter (1- index))
+                                    (cdr (assoc (aref name index)
+                                                *character-replacements*))
+                                    (replacement-delimiter (1+ index))
+                                    (subseq name (1+ index))))))
+    name))
+
+;;;; generating various names
+
+(defgeneric name (thing)
+  (:documentation "Name for a documented thing. Names are either
+symbols or lists of symbols."))
+
+(defmethod name ((symbol symbol))
+  symbol)
+
+(defmethod name ((cons cons))
+  cons)
+
+(defmethod name ((package package))
+  (short-package-name package))
+
+(defmethod name ((method method))
+  (list
+   (generic-function-name (method-generic-function method))
+   (method-qualifiers method)
+   (specialized-lambda-list method)))
+
+;;; Node names for DOCUMENTATION instances
+
+(defgeneric name-using-kind/name (kind name doc))
+
+(defmethod name-using-kind/name (kind (name string) doc)
+  (declare (ignore kind doc))
+  name)
+
+(defmethod name-using-kind/name (kind (name symbol) doc)
+  (declare (ignore kind))
+  (format nil "~@[~A:~]~A" (short-package-name (get-package doc)) name))
+
+(defmethod name-using-kind/name (kind (name list) doc)
+  (declare (ignore kind))
+  (assert (setf-name-p name))
+  (format nil "(setf ~@[~A:~]~A)" (short-package-name (get-package doc)) (second name)))
+
+(defmethod name-using-kind/name ((kind (eql 'method)) name doc)
+  (format nil "~A~{ ~A~} ~A"
+          (name-using-kind/name nil (first name) doc)
+          (second name)
+          (third name)))
+
+(defun node-name (doc)
+  "Returns TexInfo node name as a string for a DOCUMENTATION instance."
+  (let ((kind (get-kind doc)))
+    (format nil "~:(~A~) ~(~A~)" kind (name-using-kind/name kind (get-name doc) doc))))
+
+(defun short-package-name (package)
+  (unless (eq package *base-package*)
+    (car (sort (copy-list (cons (package-name package) (package-nicknames package)))
+               #'< :key #'length))))
+
+;;; Definition titles for DOCUMENTATION instances
+
+(defgeneric title-using-kind/name (kind name doc))
+
+(defmethod title-using-kind/name (kind (name string) doc)
+  (declare (ignore kind doc))
+  name)
+
+(defmethod title-using-kind/name (kind (name symbol) doc)
+  (declare (ignore kind))
+  (format nil "~@[~A:~]~A" (short-package-name (get-package doc)) name))
+
+(defmethod title-using-kind/name (kind (name list) doc)
+  (declare (ignore kind))
+  (assert (setf-name-p name))
+  (format nil "(setf ~@[~A:~]~A)" (short-package-name (get-package doc)) (second name)))
+
+(defmethod title-using-kind/name ((kind (eql 'method)) name doc)
+  (format nil "~{~A ~}~A"
+          (second name)
+          (title-using-kind/name nil (first name) doc)))
+
+(defun title-name (doc)
+  "Returns a string to be used as name of the definition."
+  (string-downcase (title-using-kind/name (get-kind doc) (get-name doc) doc)))
+
+(defun include-pathname (doc)
+  (let* ((kind (get-kind doc))
+         (name (nstring-downcase
+                (if (eq 'package kind)
+                    (format nil "package-~A" (alphanumize (get-name doc)))
+                    (format nil "~A-~A-~A"
+                            (case (get-kind doc)
+                              ((function generic-function) "fun")
+                              (structure "struct")
+                              (variable "var")
+                              (otherwise (symbol-name (get-kind doc))))
+                            (alphanumize (let ((*base-package* nil))
+                                           (short-package-name (get-package doc))))
+                            (alphanumize (get-name doc)))))))
+    (make-pathname :name name  :type "texinfo")))
+
+;;;; documentation class and related methods
+
+(defclass documentation ()
+  ((name :initarg :name :reader get-name)
+   (kind :initarg :kind :reader get-kind)
+   (string :initarg :string :reader get-string)
+   (children :initarg :children :initform nil :reader get-children)
+   (package :initform *documentation-package* :reader get-package)))
+
+(defmethod print-object ((documentation documentation) stream)
+  (print-unreadable-object (documentation stream :type t)
+    (princ (list (get-kind documentation) (get-name documentation)) stream)))
+
+(defgeneric make-documentation (x doc-type string))
+
+(defmethod make-documentation ((x package) doc-type string)
+  (declare (ignore doc-type))
+  (make-instance 'documentation
+                 :name (name x)
+                 :kind 'package
+                 :string string))
+
+(defmethod make-documentation (x (doc-type (eql 'function)) string)
+  (declare (ignore doc-type))
+  (let* ((fdef (and (fboundp x) (fdefinition x)))
+         (name x)
+         (kind (cond ((and (symbolp x) (special-operator-p x))
+                      'special-operator)
+                     ((and (symbolp x) (macro-function x))
+                      'macro)
+                     ((typep fdef 'generic-function)
+                      (assert (or (symbolp name) (setf-name-p name)))
+                      'generic-function)
+                     (fdef
+                      (assert (or (symbolp name) (setf-name-p name)))
+                      'function)))
+         (children (when (eq kind 'generic-function)
+                     (collect-gf-documentation fdef))))
+    (make-instance 'documentation
+                   :name (name x)
+                   :string string
+                   :kind kind
+                   :children children)))
+
+(defmethod make-documentation ((x method) doc-type string)
+  (declare (ignore doc-type))
+  (make-instance 'documentation
+                 :name (name x)
+                 :kind 'method
+                 :string string))
+
+(defmethod make-documentation (x (doc-type (eql 'type)) string)
+  (make-instance 'documentation
+                 :name (name x)
+                 :string string
+                 :kind (etypecase (find-class x nil)
+                         (structure-class 'structure)
+                         (standard-class 'class)
+                         (sb-pcl::condition-class 'condition)
+                         ((or built-in-class null) 'type))))
+
+(defmethod make-documentation (x (doc-type (eql 'variable)) string)
+  (make-instance 'documentation
+                 :name (name x)
+                 :string string
+                 :kind (if (constantp x)
+                           'constant
+                           'variable)))
+
+(defmethod make-documentation (x (doc-type (eql 'setf)) string)
+  (declare (ignore doc-type))
+  (make-instance 'documentation
+                 :name (name x)
+                 :kind 'setf-expander
+                 :string string))
+
+(defmethod make-documentation (x doc-type string)
+  (make-instance 'documentation
+                 :name (name x)
+                 :kind doc-type
+                 :string string))
+
+(defun maybe-documentation (x doc-type)
+  "Returns a DOCUMENTATION instance for X and DOC-TYPE, or NIL if
+there is no corresponding docstring."
+  (let ((docstring (docstring x doc-type)))
+    (when docstring
+      (make-documentation x doc-type docstring))))
+
+(defun lambda-list (doc)
+  (case (get-kind doc)
+    ((package constant variable type structure class condition nil)
+     nil)
+    (method
+     (third (get-name doc)))
+    (t
+     ;; KLUDGE: Eugh.
+     ;;
+     ;; believe it or not, the above comment was written before CSR
+     ;; came along and obfuscated this.  (2005-07-04)
+     (when (symbolp (get-name doc))
+       (labels ((clean (x &key optional key)
+                  (typecase x
+                    (atom x)
+                    ((cons (member &optional))
+                     (cons (car x) (clean (cdr x) :optional t)))
+                    ((cons (member &key))
+                     (cons (car x) (clean (cdr x) :key t)))
+                    ((cons cons)
+                     (cons
+                      (cond (key (if (consp (caar x))
+                                     (caaar x)
+                                     (caar x)))
+                            (optional (caar x))
+                            (t (clean (car x))))
+                      (clean (cdr x) :key key :optional optional)))
+                    (cons
+                     (cons
+                      (cond ((or key optional) (car x))
+                            (t (clean (car x))))
+                      (clean (cdr x) :key key :optional optional))))))
+         (clean (sb-introspect:function-lambda-list (get-name doc))))))))
+
+(defun get-string-name (x)
+  (let ((name (get-name x)))
+    (cond ((symbolp name)
+           (symbol-name name))
+          ((and (consp name) (eq 'setf (car name)))
+           (symbol-name (second name)))
+          ((stringp name)
+           name)
+          (t
+           (error "Don't know which symbol to use for name ~S" name)))))
+
+(defun documentation< (x y)
+  (let ((p1 (position (get-kind x) *ordered-documentation-kinds*))
+        (p2 (position (get-kind y) *ordered-documentation-kinds*)))
+    (if (or (not (and p1 p2)) (= p1 p2))
+        (string< (get-string-name x) (get-string-name y))
+        (< p1 p2))))
+
+;;;; turning text into texinfo
+
+(defun escape-for-texinfo (string &optional downcasep)
+  "Return STRING with characters in *TEXINFO-ESCAPED-CHARS* escaped
+with #\@. Optionally downcase the result."
+  (let ((result (with-output-to-string (s)
+                  (loop for char across string
+                        when (find char *texinfo-escaped-chars*)
+                        do (write-char #\@ s)
+                        do (write-char char s)))))
+    (if downcasep (nstring-downcase result) result)))
+
+(defun empty-p (line-number lines)
+  (and (< -1 line-number (length lines))
+       (not (indentation (svref lines line-number)))))
+
+;;; line markups
+
+(defvar *not-symbols* '("ANSI" "CLHS"))
+
+(defun locate-symbols (line)
+  "Return a list of index pairs of symbol-like parts of LINE."
+  ;; This would be a good application for a regex ...
+  (let (result)
+    (flet ((grab (start end)
+             (unless (member (subseq line start end) '("ANSI" "CLHS"))
+               (push (list start end) result))))
+      (do ((begin nil)
+           (maybe-begin t)
+           (i 0 (1+ i)))
+          ((= i (length line))
+           ;; symbol at end of line
+           (when (and begin (or (> i (1+ begin))
+                                (not (member (char line begin) '(#\A #\I)))))
+             (grab begin i))
+           (nreverse result))
+        (cond
+          ((and begin (find (char line i) *symbol-delimiters*))
+           ;; symbol end; remember it if it's not "A" or "I"
+           (when (or (> i (1+ begin)) (not (member (char line begin) '(#\A #\I))))
+             (grab begin i))
+           (setf begin nil
+                 maybe-begin t))
+          ((and begin (not (find (char line i) *symbol-characters*)))
+           ;; Not a symbol: abort
+           (setf begin nil))
+          ((and maybe-begin (not begin) (find (char line i) *symbol-characters*))
+           ;; potential symbol begin at this position
+           (setf begin i
+                 maybe-begin nil))
+          ((find (char line i) *symbol-delimiters*)
+           ;; potential symbol begin after this position
+           (setf maybe-begin t))
+          (t
+           ;; Not reading a symbol, not at potential start of symbol
+           (setf maybe-begin nil)))))))
+
+(defun texinfo-line (line)
+  "Format symbols in LINE texinfo-style: either as code or as
+variables if the symbol in question is contained in symbols
+*TEXINFO-VARIABLES*."
+  (with-output-to-string (result)
+    (let ((last 0))
+      (dolist (symbol/index (locate-symbols line))
+        (write-string (subseq line last (first symbol/index)) result)
+        (let ((symbol-name (apply #'subseq line symbol/index)))
+          (format result (if (member symbol-name *texinfo-variables*
+                                     :test #'string=)
+                             "@var{~A}"
+                             "@code{~A}")
+                  (string-downcase symbol-name)))
+        (setf last (second symbol/index)))
+      (write-string (subseq line last) result))))
+
+;;; lisp sections
+
+(defun lisp-section-p (line line-number lines)
+  "Returns T if the given LINE looks like start of lisp code --
+ie. if it starts with whitespace followed by a paren or
+semicolon, and the previous line is empty"
+  (let ((offset (indentation line)))
+    (and offset
+         (plusp offset)
+         (find (find-if-not #'whitespacep line) "(;")
+         (empty-p (1- line-number) lines))))
+
+(defun collect-lisp-section (lines line-number)
+  (let ((lisp (loop for index = line-number then (1+ index)
+                    for line = (and (< index (length lines)) (svref lines index))
+                    while (indentation line)
+                    collect line)))
+    (values (length lisp) `("@lisp" , at lisp "@end lisp"))))
+
+;;; itemized sections
+
+(defun maybe-itemize-offset (line)
+  "Return NIL or the indentation offset if LINE looks like it starts
+an item in an itemization."
+  (let* ((offset (indentation line))
+         (char (when offset (char line offset))))
+    (and offset
+         (member char *itemize-start-characters* :test #'char=)
+         (char= #\Space (find-if-not (lambda (c) (char= c char))
+                                     line :start offset))
+         offset)))
+
+(defun collect-maybe-itemized-section (lines starting-line)
+  ;; Return index of next line to be processed outside
+  (let ((this-offset (maybe-itemize-offset (svref lines starting-line)))
+        (result nil)
+        (lines-consumed 0))
+    (loop for line-number from starting-line below (length lines)
+       for line = (svref lines line-number)
+       for indentation = (indentation line)
+       for offset = (maybe-itemize-offset line)
+       do (cond
+            ((not indentation)
+             ;; empty line -- inserts paragraph.
+             (push "" result)
+             (incf lines-consumed))
+            ((and offset (> indentation this-offset))
+             ;; nested itemization -- handle recursively
+             ;; FIXME: tables in itemizations go wrong
+             (multiple-value-bind (sub-lines-consumed sub-itemization)
+                 (collect-maybe-itemized-section lines line-number)
+               (when sub-lines-consumed
+                 (incf line-number (1- sub-lines-consumed)) ; +1 on next loop
+                 (incf lines-consumed sub-lines-consumed)
+                 (setf result (nconc (nreverse sub-itemization) result)))))
+            ((and offset (= indentation this-offset))
+             ;; start of new item
+             (push (format nil "@item ~A"
+                           (texinfo-line (subseq line (1+ offset))))
+                   result)
+             (incf lines-consumed))
+            ((and (not offset) (> indentation this-offset))
+             ;; continued item from previous line
+             (push (texinfo-line line) result)
+             (incf lines-consumed))
+            (t
+             ;; end of itemization
+             (loop-finish))))
+    ;; a single-line itemization isn't.
+    (if (> (count-if (lambda (line) (> (length line) 0)) result) 1)
+        (values lines-consumed `("@itemize" ,@(reverse result) "@end itemize"))
+        nil)))
+
+;;; table sections
+
+(defun tabulation-body-p (offset line-number lines)
+  (when (< line-number (length lines))
+    (let ((offset2 (indentation (svref lines line-number))))
+      (and offset2 (< offset offset2)))))
+
+(defun tabulation-p (offset line-number lines direction)
+  (let ((step  (ecase direction
+                 (:backwards (1- line-number))
+                 (:forwards (1+ line-number)))))
+    (when (and (plusp line-number) (< line-number (length lines)))
+      (and (eql offset (indentation (svref lines line-number)))
+           (or (when (eq direction :backwards)
+                 (empty-p step lines))
+               (tabulation-p offset step lines direction)
+               (tabulation-body-p offset step lines))))))
+
+(defun maybe-table-offset (line-number lines)
+  "Return NIL or the indentation offset if LINE looks like it starts
+an item in a tabulation. Ie, if it is (1) indented, (2) preceded by an
+empty line, another tabulation label, or a tabulation body, (3) and
+followed another tabulation label or a tabulation body."
+  (let* ((line (svref lines line-number))
+         (offset (indentation line))
+         (prev (1- line-number))
+         (next (1+ line-number)))
+    (when (and offset (plusp offset))
+      (and (or (empty-p prev lines)
+               (tabulation-body-p offset prev lines)
+               (tabulation-p offset prev lines :backwards))
+           (or (tabulation-body-p offset next lines)
+               (tabulation-p offset next lines :forwards))
+           offset))))
+
+;;; FIXME: This and itemization are very similar: could they share
+;;; some code, mayhap?
+
+(defun collect-maybe-table-section (lines starting-line)
+  ;; Return index of next line to be processed outside
+  (let ((this-offset (maybe-table-offset starting-line lines))
+        (result nil)
+        (lines-consumed 0))
+    (loop for line-number from starting-line below (length lines)
+          for line = (svref lines line-number)
+          for indentation = (indentation line)
+          for offset = (maybe-table-offset line-number lines)
+          do (cond
+               ((not indentation)
+                ;; empty line -- inserts paragraph.
+                (push "" result)
+                (incf lines-consumed))
+               ((and offset (= indentation this-offset))
+                ;; start of new item, or continuation of previous item
+                (if (and result (search "@item" (car result) :test #'char=))
+                    (push (format nil "@itemx ~A" (texinfo-line line))
+                          result)
+                    (progn
+                      (push "" result)
+                      (push (format nil "@item ~A" (texinfo-line line))
+                            result)))
+                (incf lines-consumed))
+               ((> indentation this-offset)
+                ;; continued item from previous line
+                (push (texinfo-line line) result)
+                (incf lines-consumed))
+               (t
+                ;; end of itemization
+                (loop-finish))))
+     ;; a single-line table isn't.
+    (if (> (count-if (lambda (line) (> (length line) 0)) result) 1)
+        (values lines-consumed
+                `("" "@table @emph" ,@(reverse result) "@end table" ""))
+        nil)))
+
+;;; section markup
+
+(defmacro with-maybe-section (index &rest forms)
+  `(multiple-value-bind (count collected) (progn , at forms)
+    (when count
+      (dolist (line collected)
+        (write-line line *texinfo-output*))
+      (incf ,index (1- count)))))
+
+(defun write-texinfo-string (string &optional lambda-list)
+  "Try to guess as much formatting for a raw docstring as possible."
+  (let ((*texinfo-variables* (flatten lambda-list))
+        (lines (string-lines (escape-for-texinfo string nil))))
+      (loop for line-number from 0 below (length lines)
+            for line = (svref lines line-number)
+            do (cond
+                 ((with-maybe-section line-number
+                    (and (lisp-section-p line line-number lines)
+                         (collect-lisp-section lines line-number))))
+                 ((with-maybe-section line-number
+                    (and (maybe-itemize-offset line)
+                         (collect-maybe-itemized-section lines line-number))))
+                 ((with-maybe-section line-number
+                    (and (maybe-table-offset line-number lines)
+                         (collect-maybe-table-section lines line-number))))
+                 (t
+                  (write-line (texinfo-line line) *texinfo-output*))))))
+
+;;;; texinfo formatting tools
+
+(defun hide-superclass-p (class-name super-name)
+  (let ((super-package (symbol-package super-name)))
+    (or
+     ;; KLUDGE: We assume that we don't want to advertise internal
+     ;; classes in CP-lists, unless the symbol we're documenting is
+     ;; internal as well.
+     (and (member super-package #.'(mapcar #'find-package *undocumented-packages*))
+          (not (eq super-package (symbol-package class-name))))
+     ;; KLUDGE: We don't generally want to advertise SIMPLE-ERROR or
+     ;; SIMPLE-CONDITION in the CPLs of conditions that inherit them
+     ;; simply as a matter of convenience. The assumption here is that
+     ;; the inheritance is incidental unless the name of the condition
+     ;; begins with SIMPLE-.
+     (and (member super-name '(simple-error simple-condition))
+          (let ((prefix "SIMPLE-"))
+            (mismatch prefix (string class-name) :end2 (length prefix)))
+          t ; don't return number from MISMATCH
+          ))))
+
+(defun hide-slot-p (symbol slot)
+  ;; FIXME: There is no pricipal reason to avoid the slot docs fo
+  ;; structures and conditions, but their DOCUMENTATION T doesn't
+  ;; currently work with them the way we'd like.
+  (not (and (typep (find-class symbol nil) 'standard-class)
+            (docstring slot t))))
+
+(defun texinfo-anchor (doc)
+  (format *texinfo-output* "@anchor{~A}~%" (node-name doc)))
+
+;;; KLUDGE: &AUX *PRINT-PRETTY* here means "no linebreaks please"
+(defun texinfo-begin (doc &aux *print-pretty*)
+  (let ((kind (get-kind doc)))
+    (format *texinfo-output* "@~A {~:(~A~)} ~({~A}~@[ ~{~A~^ ~}~]~)~%"
+            (case kind
+              ((package constant variable)
+               "defvr")
+              ((structure class condition type)
+               "deftp")
+              (t
+               "deffn"))
+            (map 'string (lambda (char) (if (eql char #\-) #\Space char)) (string kind))
+            (title-name doc)
+            ;; &foo would be amusingly bold in the pdf thanks to TeX/Texinfo
+            ;; interactions,so we escape the ampersand -- amusingly for TeX.
+            ;; sbcl.texinfo defines macros that expand @&key and friends to &key.
+            (mapcar (lambda (name)
+                      (if (member name lambda-list-keywords)
+                          (format nil "@~A" name)
+                          name))
+                    (lambda-list doc)))))
+
+(defun texinfo-index (doc)
+  (let ((title (title-name doc)))
+    (case (get-kind doc)
+      ((structure type class condition)
+       (format *texinfo-output* "@tindex ~A~%" title))
+      ((variable constant)
+       (format *texinfo-output* "@vindex ~A~%" title))
+      ((compiler-macro function method-combination macro generic-function)
+       (format *texinfo-output* "@findex ~A~%" title)))))
+
+(defun texinfo-inferred-body (doc)
+  (when (member (get-kind doc) '(class structure condition))
+    (let ((name (get-name doc)))
+      ;; class precedence list
+      (format *texinfo-output* "Class precedence list: @code{~(~{@lw{~A}~^, ~}~)}~%~%"
+              (remove-if (lambda (class)  (hide-superclass-p name class))
+                         (mapcar #'class-name (ensure-class-precedence-list (find-class name)))))
+      ;; slots
+      (let ((slots (remove-if (lambda (slot) (hide-slot-p name slot))
+                              (class-direct-slots (find-class name)))))
+        (when slots
+          (format *texinfo-output* "Slots:~%@itemize~%")
+          (dolist (slot slots)
+            (format *texinfo-output*
+                    "@item ~(@code{~A}~#[~:; --- ~]~
+                      ~:{~2*~@[~2:*~A~P: ~{@code{@w{~S}}~^, ~}~]~:^; ~}~)~%~%"
+                    (slot-definition-name slot)
+                    (remove
+                     nil
+                     (mapcar
+                      (lambda (name things)
+                        (if things
+                            (list name (length things) things)))
+                      '("initarg" "reader"  "writer")
+                      (list
+                       (slot-definition-initargs slot)
+                       (slot-definition-readers slot)
+                       (slot-definition-writers slot)))))
+            ;; FIXME: Would be neater to handler as children
+            (write-texinfo-string (docstring slot t)))
+          (format *texinfo-output* "@end itemize~%~%"))))))
+
+(defun texinfo-body (doc)
+  (write-texinfo-string (get-string doc)))
+
+(defun texinfo-end (doc)
+  (write-line (case (get-kind doc)
+                ((package variable constant) "@end defvr")
+                ((structure type class condition) "@end deftp")
+                (t "@end deffn"))
+              *texinfo-output*))
+
+(defun write-texinfo (doc)
+  "Writes TexInfo for a DOCUMENTATION instance to *TEXINFO-OUTPUT*."
+  (texinfo-anchor doc)
+  (texinfo-begin doc)
+  (texinfo-index doc)
+  (texinfo-inferred-body doc)
+  (texinfo-body doc)
+  (texinfo-end doc)
+  ;; FIXME: Children should be sorted one way or another
+  (mapc #'write-texinfo (get-children doc)))
+
+;;;; main logic
+
+(defun collect-gf-documentation (gf)
+  "Collects method documentation for the generic function GF"
+  (loop for method in (generic-function-methods gf)
+        for doc = (maybe-documentation method t)
+        when doc
+        collect doc))
+
+(defun collect-name-documentation (name)
+  (loop for type in *documentation-types*
+        for doc = (maybe-documentation name type)
+        when doc
+        collect doc))
+
+(defun collect-symbol-documentation (symbol)
+  "Collects all docs for a SYMBOL and (SETF SYMBOL), returns a list of
+the form DOC instances. See `*documentation-types*' for the possible
+values of doc-type."
+  (nconc (collect-name-documentation symbol)
+         (collect-name-documentation (list 'setf symbol))))
+
+(defun collect-documentation (package)
+  "Collects all documentation for all external symbols of the given
+package, as well as for the package itself."
+  (let* ((*documentation-package* (find-package package))
+         (docs nil))
+    (check-type package package)
+    (do-external-symbols (symbol package)
+      (setf docs (nconc (collect-symbol-documentation symbol) docs)))
+    (let ((doc (maybe-documentation *documentation-package* t)))
+      (when doc
+        (push doc docs)))
+    docs))
+
+(defmacro with-texinfo-file (pathname &body forms)
+  `(with-open-file (*texinfo-output* ,pathname
+                                    :direction :output
+                                    :if-does-not-exist :create
+                                    :if-exists :supersede)
+    , at forms))
+
+(defun generate-includes (directory packages &key (base-package :cl-user))
+  "Create files in `directory' containing Texinfo markup of all
+docstrings of each exported symbol in `packages'. `directory' is
+created if necessary. If you supply a namestring that doesn't end in a
+slash, you lose. The generated files are of the form
+\"<doc-type>_<packagename>_<symbol-name>.texinfo\" and can be included
+via @include statements. Texinfo syntax-significant characters are
+escaped in symbol names, but if a docstring contains invalid Texinfo
+markup, you lose."
+  (handler-bind ((warning #'muffle-warning))
+    (let ((directory (merge-pathnames (pathname directory)))
+          (*base-package* (find-package base-package)))
+      (ensure-directories-exist directory)
+      (dolist (package packages)
+        (dolist (doc (collect-documentation (find-package package)))
+          (with-texinfo-file (merge-pathnames (include-pathname doc) directory)
+            (write-texinfo doc))))
+      directory)))
+
+(defun document-package (package &optional filename)
+  "Create a file containing all available documentation for the
+exported symbols of `package' in Texinfo format. If `filename' is not
+supplied, a file \"<packagename>.texinfo\" is generated.
+
+The definitions can be referenced using Texinfo statements like
+ at ref{<doc-type>_<packagename>_<symbol-name>.texinfo}. Texinfo
+syntax-significant characters are escaped in symbol names, but if a
+docstring contains invalid Texinfo markup, you lose."
+  (handler-bind ((warning #'muffle-warning))
+    (let* ((package (find-package package))
+           (filename (or filename (make-pathname
+                                   :name (string-downcase (short-package-name package))
+                                   :type "texinfo")))
+           (docs (sort (collect-documentation package) #'documentation<)))
+      (with-texinfo-file filename
+        (dolist (doc docs)
+          (write-texinfo doc)))
+      filename)))
diff --git a/functions.lisp b/functions.lisp
index 8d2fd38..5a45d70 100644
--- a/functions.lisp
+++ b/functions.lisp
@@ -15,6 +15,7 @@ it must be a function name and its FDEFINITION is returned."
 (define-modify-macro ensure-functionf/1 () ensure-function)
 
 (defmacro ensure-functionf (&rest places)
+  "FIXME: UNDOCUMENTED!"
   `(progn ,@(mapcar (lambda (x) `(ensure-functionf/1 ,x)) places)))
 
 (defun disjoin (predicate &rest more-predicates)
diff --git a/lists.lisp b/lists.lisp
index 69c21f7..ffe418a 100644
--- a/lists.lisp
+++ b/lists.lisp
@@ -215,7 +215,7 @@ designator of the expected type in a TYPE-ERROR."
   
   (def lastcar (list)
       "Returns the last element of LIST. Signals a type-error if LIST is not a
-proper list." 
+proper list."
     nil
     nil
     (cadr last)
@@ -278,8 +278,10 @@ provided plist."
   ;; FIXME: should not cons
   (apply 'remove-from-plist plist keys))
 
-(define-modify-macro remove-from-plistf (&rest keys) remove-from-plist)
-(define-modify-macro delete-from-plistf (&rest keys) delete-from-plist)
+(define-modify-macro remove-from-plistf (&rest keys) remove-from-plist
+                     "Modify macro for REMOVE-FROM-PLIST.")
+(define-modify-macro delete-from-plistf (&rest keys) delete-from-plist
+                     "Modify macro for DELETE-FROM-PLIST.")
 
 (declaim (inline sans))
 (defun sans (plist &rest keys)
@@ -322,8 +324,9 @@ In other words, returns the product of LIST and MORE-LISTS using FUNCTION.
 
 Example:
 
- (map-product 'list '(1 2) '(3 4) '(5 6)) => ((1 3 5) (1 3 6) (1 4 5) (1 4 6)
-                                              (2 3 5) (2 3 6) (2 4 5) (2 4 6))
+ (map-product 'list '(1 2) '(3 4) '(5 6))
+  => ((1 3 5) (1 3 6) (1 4 5) (1 4 6)
+      (2 3 5) (2 3 6) (2 4 5) (2 4 6))
 "
   (labels ((%map-product (f lists)
              (let ((more (cdr lists))
diff --git a/macros.lisp b/macros.lisp
index 031109d..75ff3f4 100644
--- a/macros.lisp
+++ b/macros.lisp
@@ -28,15 +28,23 @@ unique symbol the named variable will be bound to."
   `(with-gensyms ,names , at forms))
 
 (defmacro once-only (specs &body forms)
-  "Each SPEC must be either a NAME, or a (NAME INITFORM), with plain
-NAME using the named variable as initform.
+  "Evaluates FORMS with symbols specified in SPECS rebound to temporary
+variables, ensuring that each initform is evaluated only once.
 
-Evaluates FORMS with names rebound to temporary variables, ensuring
-that each is evaluated only once.
+Each of SPECS must either be a symbol naming the variable to be rebound, or of
+the form:
+
+  (symbol initform)
+
+Bare symbols in SPECS are equivalent to
+
+  (symbol symbol)
 
 Example:
+
   (defmacro cons1 (x) (once-only (x) `(cons ,x ,x)))
-  (let ((y 0)) (cons1 (incf y))) => (1 . 1)"
+  (let ((y 0)) (cons1 (incf y))) => (1 . 1)
+"
   (let ((gensyms (make-gensym-list (length specs) "ONCE-ONLY"))
         (names-and-forms (mapcar (lambda (spec)
                                    (etypecase spec
@@ -84,18 +92,25 @@ arguments when given."
                                    (normalize-optional normalize)
                                    (normalize-keyword normalize)
                                    (normalize-auxilary normalize))
-  "Parses an ordinary lambda-list, returning:
-
-\(values requireds optionals rest keywords allow-other-keys? auxiliaries)
-
- 1. Required parameters.
- 2. Optional parameter specifications, normalized into form (NAME INIT SUPPLIEDP)
-    where SUPPLIEDP is NIL if not present.
- 3. Name of the rest parameter, or NIL.
- 4. Keyword parameter specifications, normalized into form ((KEYWORD-NAME NAME) INIT SUPPLIEDP)
-    where SUPPLIEDP is NIL if not present.
- 5. Boolean indicating &ALLOW-OTHER-KEYS presence.
- 6. &AUX parameter specifications, normalized into form (NAME INIT).
+  "Parses an ordinary lambda-list, returning as multiple values:
+
+1. Required parameters.
+
+2. Optional parameter specifications, normalized into form:
+
+   (name init suppliedp)
+
+3. Name of the rest parameter, or NIL.
+
+4. Keyword parameter specifications, normalized into form:
+
+   ((keyword-name name) init suppliedp)
+
+5. Boolean indicating &ALLOW-OTHER-KEYS presence.
+
+6. &AUX parameter specifications, normalized into form
+
+   (name init).
 
 Signals a PROGRAM-ERROR is the lambda-list is malformed."
   (let ((state :required)
diff --git a/numbers.lisp b/numbers.lisp
index 7252e2a..bf6ef0b 100644
--- a/numbers.lisp
+++ b/numbers.lisp
@@ -2,7 +2,7 @@
 
 (declaim (inline clamp))
 (defun clamp (number min max)
-  "Clamps the NUMBER into [MIN, MAX] range. Returns MIN if NUMBER lesser then
+  "Clamps the NUMBER into [min, max] range. Returns MIN if NUMBER is lesser then
 MIN and MAX if NUMBER is greater then MAX, otherwise returns NUMBER."
   (if (< number min)
       min
diff --git a/package.lisp b/package.lisp
index 81c1e58..c7f9bf1 100644
--- a/package.lisp
+++ b/package.lisp
@@ -137,7 +137,7 @@
    #:negative-float-p
    #:negative-long-float
    #:negative-long-float-p
-   #:negative-rational 
+   #:negative-rational
    #:negative-rational-p
    #:negative-real
    #:negative-single-float-p
diff --git a/sequences.lisp b/sequences.lisp
index 2c797b9..a4b2a95 100644
--- a/sequences.lisp
+++ b/sequences.lisp
@@ -64,10 +64,15 @@ SEQUENCE is not a sequence. Returns FALSE for circular lists."
 SEQUENCE rotated by N: N elements are moved from the end of the sequence to
 the front if N is positive, and -N elements moved from the front to the end if
 N is negative. SEQUENCE must be a proper sequence. N must be an integer,
-defaulting to 1. If absolute value of N is greater then the length of the
-sequence, the results are identical to calling ROTATE with (* (SIGNUM N) (MOD
-N (LENGTH SEQUENCE))). The original sequence may be destructively altered, and
-result sequence may share structure with it."
+defaulting to 1.
+
+If absolute value of N is greater then the length of the sequence, the results
+are identical to calling ROTATE with
+
+  (* (signum n) (mod n (length sequence))).
+
+Note: the original sequence may be destructively altered, and result sequence may
+share structure with it."
   (if (plusp n)
       (rotate-tail-to-head sequence n)
       (if (minusp n)
diff --git a/symbols.lisp b/symbols.lisp
index 0347548..44c0d71 100644
--- a/symbols.lisp
+++ b/symbols.lisp
@@ -7,7 +7,10 @@ designated by PACKAGE. If symbol is not already accessible in PACKAGE, it is
 interned there. Returns a secondary value reflecting the status of the symbol
 in the package, which matches the secondary return value of INTERN.
 
-Example: (ENSURE-SYMBOL :CONS :CL) => CL:CONS, :EXTERNAL"
+Example:
+
+  (ensure-symbol :cons :cl) => cl:cons, :external
+"
   (intern (string name) package))
 
 (defun maybe-intern (name package)
-- 
Alexandria hooks/post-receive




More information about the alexandria-cvs mailing list