;; inherited documentation:
;; load this file to make documentation strings inherited in the KLOS system

;; save old definition
(if (not (boundp 'inherited-doc:old-documentation))
  (setq inherited-doc:old-documentation documentation)
)

(defun documentation (symbol &optional doc &aux
    plist
    class-and-name
    class
    name
  )
  (if doc				; set
    (inherited-doc:old-documentation symbol doc)
    (progn				; get
      (setq doc (inherited-doc:old-documentation symbol))
      ;; try to look in class tree if name is <a-class-name>.name
      (if
	(and (not doc)
	  (setq class-and-name (match "([^.]+)[.](.+)" symbol 1 2))
	  (setq class (intern (getn class-and-name 0)))
	  (boundp class)
	  (typep (eval class) ExClass)
	)
	(progn
	  (setq name (getn class-and-name 1))
	  (setq class (class-father (eval class)))
	  (while (and (not doc) class)
	    (setq doc (inherited-doc:old-documentation
		(intern (+ (class-name class) "." name))
	    ))
	    (setq class (class-father class))
	  )
	)
      )
    )
  )
  doc
)
