anchor.diff:  		  :external))
       (markdown-warning "Symbol ~s is not exported" symbol)))  
   
  -(defun ensure-symbol (thing &optional (package nil))
  +(defun ensure-documentation-holder (thing &optional (package nil))
     (etypecase thing
       (symbol (if (and package (not (eq (symbol-package thing) package)))
   		(intern (symbol-name thing) package)
   		thing))
  -    (string (intern thing package))))
  -
  -(defextension (docs :arguments ((name) (kind)))
  -  (bind (symbol)
  +    (string (if (and package (find #\space thing))
  +		(let ((*package* package)) (read-from-string thing))
  +		(intern thing package)))
  +    (cons (if (and (eql (first thing) 'setf)
  +		   (= (length thing) 2)
  +		   (typep (second thing) 'symbol))
  +	      (list 'setf (ensure-documentation-holder (second thing) package))
  +	      (error "`~a` cannot be converted into something that can hold documentation" thing)))))
  +
  +(defextension (docs :arguments ((name) (desired-kind)))
  +  (bind ((*package* (or (docs-package) *package*))
  +	 symbol)
       (labels ((find-docs (thing)
   	       (bind (((:values kinds nil)
  -		       (aif (symbol-identities-with-docstring thing kind)
  -			    (values it t)
  -			    (values (mapcar (lambda (x) (cons x nil))
  -					    (symbol-identities thing)) nil))))
  +		       (acond ((symbol-identities-with-docstring 
  +				thing desired-kind)
  +			       (values it t))
  +			      (desired-kind
  +			       nil)
  +			      (t
  +			       (values (mapcar 
  +					(lambda (x) (cons x nil))
  +					(symbol-identities thing)) nil)))))
   		 (setf symbol thing)
   		 kinds)))
  -      (bind ((*package* (or (docs-package) *package*))
  -	     (kinds (or (find-docs (ensure-symbol name))
  -			(find-docs (ensure-symbol name *package*))))
  -	     (kind (first kinds)))
  +      (bind ((kinds (or (find-docs (ensure-documentation-holder name))
  +			(find-docs (ensure-documentation-holder
  +				    name *package*))))
  +	     (potentially-ambiguous? (> (length
  +					 (symbol-identities-with-docstring 
  +					  symbol nil))
  +					1))
  +	     (kind (or (first kinds) (cons desired-kind nil)))
  +	     (docs (and (cdr kind) (find-documentation
  +				    symbol (form-keyword (cdr kind)))))
  +	     (identity (car kind)))
   	(ecase phase 
   	  (:parse
   	   (check-exportedp symbol) 
   	   ;;?? could memoize this (where is it stored? in add-docs-item?)
   	   (when (> (length kinds) 1)
  -	     (markdown-warning "Multiple interpretations found for ~a (~{~a~^, ~}; specify type (using ~a for now)" 
  -			  name (car (first kinds))))
  +	     (markdown-warning "Multiple interpretations found for ~a (~{~a~^, ~}; specify type (using ~a for now)"
  +			  name kinds identity))
   	   (unless kinds
  -	     (markdown-warning "No docstring found for ~a (package is ~s)"
  -			  name (package-name (docs-package))))
  -	   (add-docs-item symbol (car kind)))
  +	     (markdown-warning "No docstring found for ~a (package is ~s~@[, kind is ~s~])"
  +			  name (package-name (docs-package)) kind))
  +	   (add-docs-item symbol identity)
  +	   ;; this is the result: t if we need to generate an anchor
  +	   (documentation-needs-anchor-p name identity))
   	  (:render
  -	   (let ((docs (and (cdr kind) (find-documentation symbol (cdr kind))))
  -		 (identity (car kind)))
  -	     (maybe-anchor-documentation name identity)
  -	     (render-documentation identity symbol docs))
  +	   (when (first result)
  +	     (anchor-documentation 
  +	      name identity
  +	      (and (not (documentation-needs-anchor-p name nil))
  +		   potentially-ambiguous?)))
  +	   (render-documentation (form-keyword identity) symbol docs)
   	   nil))))))
   
   (defmethod render-documentation (identity symbol docs)
  
positive.code:     (format *output-stream* "~&</div>~%"))
    (format *output-stream* "~&</div>~%"))
  
  (defun maybe-anchor-documentation (name identity)
    (unless (documentation-anchored-p name identity)
      (setf (documentation-anchored-p name identity) t)
      (output-anchor (format nil "~a.~a" name identity))
      (output-anchor name)))
  
  (defun documentation-anchors-table ()
    (or (document-property :documentation-anchors)
  
negative.code: 		 :format *current-format*
  		 :properties '(("html" . nil)
  			       (:omit-final-paragraph . t)
  			       (:omit-initial-paragraph . t))
  		 :document-class 'included-document))
        (t
         (format 
  	*output-stream* 
  