eudoxia0 / docparser

Extract documentation from Common Lisp systems
41 stars 18 forks source link

The QUERY function returns nothing for slot accessors #32

Open avodonosov opened 1 year ago

avodonosov commented 1 year ago

Example, using docparser itself:


(defparameter *docparser-docs*
  (docparser:parse '#'docparser))

(defun find-docs (symbol)
  (docparser:query *docparser-docs*
                   :package-name (package-name (symbol-package symbol))
                   :symbol-name (symbol-name symbol)))

;; works for functions
(find-docs 'docparser:parse)
=>  #(#<function parse (SYSTEM-OR-LIST)>)

;; works for classes
(find-docs 'docparser:class-node)
=> #(#<class class-node>)

;; does not work for accessors
(find-docs 'docparser:class-node-superclasses)
=> #()
avodonosov commented 1 year ago

As a workaround I iterate over class-nodes in index, add all their slot-nodes to the index directly, and also adding instances of accessor-node, reader-node and writer -node, for which I defined 3 my own classes. All this code is here:

https://github.com/avodonosov/package-doc-dump/blob/57c510657be4cc9bb30b639b9b7dee92488ff097/package-doc-dump.lisp#L141

It may be thought-through better; for example, maybe instead of accessor-node add a pair of reader-node and writer node. Also, for writer-node, in case if user defined it as :writer (setf my-writer) we could make node-name just my-writer and set setf-p to true - similar to what docparser does for setf functions, as I understand. Also, maybe those 3 classes should inherit from method-node, or maybe generic-function-node.

But for my case I simply need two readers documented, so currently what I have is enough.