FUEL: ensuring that autodoc works for qualified word references (eg unix.ffi:accept)

char-rename
Björn Lindqvist 2017-01-07 15:20:13 +01:00
parent 28801e8d5f
commit a1f9fca4dc
4 changed files with 24 additions and 19 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
! See http://factorcode.org/license.txt for BSD license.
USING: fuel.eval io.streams.string math namespaces random.data sequences
tools.test ;
USING: fuel fuel.eval io.streams.string math namespaces random.data
sequences tools.test ;
IN: fuel.eval.tests
! Make sure prettyprint doesn't limit output.
@ -10,3 +10,11 @@ IN: fuel.eval.tests
1000 random-string fuel-eval-result set-global
[ fuel-send-retort ] with-string-writer length 1000 >
] unit-test
{
"(nil \"IN: kernel PRIMITIVE: dup ( x -- x x )\" \"\")\n<~FUEL~>\n"
} [
[
V{ "\"dup\"" "fuel-word-synopsis" } "scratchpad" V{ } fuel-eval-in-context
] with-string-writer
] unit-test

View File

@ -117,7 +117,7 @@ PRIVATE>
: fuel-vocab-help ( name -- ) (fuel-vocab-help) fuel-eval-set-result ;
: fuel-word-synopsis ( word usings -- ) (fuel-word-synopsis) fuel-eval-set-result ;
: fuel-word-synopsis ( word -- ) (fuel-word-synopsis) fuel-eval-set-result ;
: fuel-vocab-summary ( name -- )
(fuel-vocab-summary) fuel-eval-set-result ;

View File

@ -97,16 +97,13 @@ SYMBOL: describe-words
PRIVATE>
: (fuel-word-help) ( name -- elem )
: (fuel-word-help) ( name -- elem/f )
fuel-find-word [
[ auto-use? on (fuel-word-element) ] with-scope
] [ f ] if* ;
: (fuel-word-synopsis) ( word usings -- str/f )
[
[ lookup-vocab ] filter interactive-vocabs [ append ] change
fuel-find-word [ synopsis ] [ f ] if*
] with-scope ;
: (fuel-word-synopsis) ( name -- str/f )
fuel-find-word [ synopsis ] [ f ] if* ;
: (fuel-word-def) ( name -- str )
fuel-find-word [ [ def>> pprint ] with-string-writer ] [ f ] if* ; inline

View File

@ -57,16 +57,16 @@ USING: form with \\[fuel-load-usings]."
(let ((word (or word (factor-symbol-at-point)))
(fuel-log--inhibit-p t))
(when word
(let* ((usings (if fuel-autodoc-eval-using-form-p :usings t))
(cmd (if (factor-on-vocab)
`(:fuel* (,word fuel-vocab-summary) :in t)
`(:fuel* ((,word :usings fuel-word-synopsis)) t ,usings)))
(ret (fuel-eval--send/wait cmd fuel-autodoc--timeout))
(res (fuel-eval--retort-result ret)))
(when (and ret (not (fuel-eval--retort-error ret)) (stringp res))
(if fuel-autodoc-minibuffer-font-lock
(factor-font-lock-string res)
res))))))
(let ((cmd `(:fuel* (,word ,'fuel-word-synopsis)
,(factor-current-vocab)
,(factor-usings))))
(let* ((ret (fuel-eval--send/wait cmd fuel-autodoc--timeout))
(res (fuel-eval--retort-result ret)))
(if (not res)
(message "No synposis for '%s'" word)
(if fuel-autodoc-minibuffer-font-lock
(factor-font-lock-string res)
res)))))))
(defvar-local fuel-autodoc--fallback-function nil)