ruricolist / cl-yesql

Common Lisp library for using SQL
67 stars 5 forks source link

Implement #'DOCUMENTATION entries for CL-YESQL functions #6

Open phoe opened 6 years ago

phoe commented 6 years ago

I hereby request a feature where, given CL-YESQL code,

-- name: users-by-country @rows
-- Counts the users in a given country.
SELECT count(*) AS count
FROM user
WHERE country_code = :country_code

evaluating

(documentation 'create-table-player 'function)

returns "Counts the users in a given country."

Please make it work for multiline comments as well.

ruricolist commented 6 years ago

This is mostly supported now in the dev branch. Only mostly supported, because it works on SBCL but not on Clozure -- Clozure seems to discard the docstrings of lambdas. I might have to look into fixing that in Clozure itself.

phoe commented 6 years ago

Clozure seems to discard the docstrings of lambdas

What do you mean? How exactly do you set the documentation of an anonymous function?

The canonical way mentioned by http://clhs.lisp.se/Body/f_docume.htm (http://clhs.lisp.se/Body/f_docume.htm) is (setf (documentation 'foo 'function) "sadfasdfsdfsdf")

phoe commented 5 years ago

I can see multiline docstrings as required in SBCL.

GATEWAY/SQL> (describe 'select-players-by-display-name)
GATEWAY/SQL:SELECT-PLAYERS-BY-DISPLAY-NAME
  [symbol]

SELECT-PLAYERS-BY-DISPLAY-NAME names a compiled function:
  Lambda-list: (CL-YESQL/STATEMENT::?0 &KEY
                (CL-YESQL-USER::LIMIT
                 (REQUIRED-ARGUMENT 'CL-YESQL-USER::LIMIT)))
  Derived type: (FUNCTION (T &KEY (:LIMIT T)) *)
  Documentation:
    Selects an ordered list of players whose display name is similar to the argument.
    At most :LIMIT players are returned.
  Inline proclamation: NOTINLINE (no inline expansion available)
  Source file: /home/phoe/Projects/Lisp/Gateway/src/sql/yesql/player.sql