Huhm....
A: get-global-funcs ;Create block
B: first A ;get the first one..
do rejoin [{C: helps } B];Create a command and execute it
print C ;And there ya go!
(^.-)
----- Original Message -----
From: "Tim Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 02, 2004 11:47 AM
Subject: [REBOL] Re: Need help with help
>
> * Gabriele Santilli <[EMAIL PROTECTED]> [041202 03:21]:
>>
>> Hi Tim,
>>
>> On Thursday, December 2, 2004, 3:37:34 AM, you wrote:
>>
>> TJ> What do I need to do here?
>>
>> One possibility is to take the source of HELP and redefine it so
>> that it matches your need.
>>
>> Otherwise, you'll need to do something like:
>>
>> do compose [help (fnc)]
> Hi Gabriele:
> That doesn't *help* either. Just returns a wildcard statement.
> I'm going to include the two main functions that I am using at the
> end of this email. Prior to that I want to show some console
> code that gets at the heart of this problem.
> To recap: 'helps (a rewrite of 'help to return docs as a string)
> Properly documents a function if it is evaluated outside of a
> block. My code has 'helps attempting to return documentation from
> a block of function words. That function is 'get-global-funcs.
>
> If I do this:
>>> helps *
> word
> == {USAGE:
> ^-value1 * value2
>
> DESCRIPTION:
> ^-Returns the first value multiplied by the second.
> ^-* is an op value.
>
> ARGUMENTS:
> ^-v...
> ;; Cool. Good.
> If I do this:
>>> fncs: get-global-funcs
> == [* ** + ++ - -- / // ...] ;; Good!
> If I do this:
>>> t: first fncs
> == *
>>> helps t
> word
> == none
> ;; argh!
>
> ;; I'm lost here, but there is a glimmer of light ...
> If I do this
> fncs1: compose/deep[(:*) (:append)]
> and I do this
> foreach f fncs1[helps f]
> I get something like this:
> == {USAGE:
> ^-F series value /only
>
> DESCRIPTION:
> ^-Appends a value to the tail of a series and returns the series head.
> ^-F is a fu...
> ;;; Now we are getting somewhere, The proper documentation is returned,
> ;;; not the right spelling, but I can live with that.
> I think the key is in how 'get-global-funcs gathers the function names,
> but my tiny little brain can't quite get it so far.
> Code for 'helps and get-global-funcs follows:
> Thanks Gabrielle
> helps: func [
> {returns information about words and values as a string.
> Currently ignores anything but functions. Rewrite of 'help}
> 'word [any-type!]
> /local value args item name refmode types attrs rtype return-string
> ][
> if unset? get/any 'word [ return none]
> if all [word? :word not value? :word] [word: mold :word]
> if any [string? :word all [word? :word datatype? get :word]][ return
> none ]
> type-name: func [value] [
> value: mold type? :value
> clear back tail value
> join either find "aeiou" first value [" an "] [" a "] value
> ]
> if not any [word? :word path? :word] [ return none ]
> value: either path? :word [first reduce reduce [word]] [get :word]
> if not any-function? :value [ return none]
> args: third :value
> ;; retrieve response as a string
> return-string: copy ""
> prn: func[val[any-type!]][
> ; dbg val
> append return-string val
> ]
> prn "USAGE:^/^-"
> if not op? :value [prn append uppercase mold word " "]
> while [not tail? args] [
> item: first args
> if :item = /local [break]
> if any [all [any-word? :item not set-word? :item] refinement?
> :item] [
> prn append mold :item " "
> if op? :value [prn append uppercase mold word " " value: none]
> ]
> args: next args
> ]
> prn newline
> args: head args
> value: get word
> prn "^/DESCRIPTION:^/"
> either string? pick args 1 [
> prn rejoin[tab first args newline tab uppercase mold word " is"
> type-name :value " value." newline]
> args: next args
> ] [ prn "^-(undocumented)^/" ]
> if block? pick args 1 [
> attrs: first args
> args: next args
> ]
> if tail? args [exit]
> while [not tail? args] [
> item: first args
> args: next args
> if :item = /local [break]
> either not refinement? :item [
> all [set-word? :item :item = first [return:] block? first args
> rtype: first args]
> if none? refmode [
> prn "^/ARGUMENTS:^/"
> refmode: 'args
> ]
> ] [
> if refmode <> 'refs [
> prn "^/REFINEMENTS:^/"
> refmode: 'refs
> ]
> ]
> either refinement? :item [
> prn rejoin[tab mold item]
> if string? pick args 1 [prn rejoin[" --" first args] args: next
> args]
> prn newline
> ] [
> if all [any-word? :item not set-word? :item] [
> if refmode = 'refs [prn tab]
> prn rejoin[tab :item "-- "]
> types: if block? pick args 1 [args: next args first back
> args]
> if string? pick args 1 [prn rejoin[first args ""] args:
> next args]
> if not types [types: 'any]
> prn rejoin ["(Type: " types ")"]
> prn newline
> ]
> ]
> ]
> if rtype [prn rejoin["^/RETURNS:^/^-" rtype newline]]
> if attrs [
> prn "^/(SPECIAL ATTRIBUTES)^/"
> while [not tail? attrs] [
> value: first attrs
> attrs: next attrs
> if any-word? value [
> prn rejoin[tab value]
> if string? pick attrs 1 [
> prn rejoin[" -- " first attrs]
> attrs: next attrs
> ]
> prn newline
> ]
> ]
> ]
> return-string
> ]
>
> get-global-funcs: func [
> "collects a list of globally-defined functions."
> /local vals args here total res ][
> total: copy []
> vals: second system/words
> foreach word first system/words [
> if any-function? first vals [
> args: first first vals
> if here: find args /local [args: copy/part args here]
> append total reduce [word mold args]
> ]
> vals: next vals
> ]
> global-funcs: extract sort/skip total 2 2
> ]
>
>> Regards,
>> Gabriele.
>> --
>> Gabriele Santilli <[EMAIL PROTECTED]> -- REBOL Programmer
>> Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/
>>
>> --
>> To unsubscribe from the list, just send an email to rebol-request
>> at rebol.com with unsubscribe as the subject.
>
> --
> Tim Johnson <[EMAIL PROTECTED]>
> http://www.alaska-internet-solutions.com
> --
> To unsubscribe from the list, just send an email to rebol-request
> at rebol.com with unsubscribe as the subject.
>
--
To unsubscribe from the list, just send an email to rebol-request
at rebol.com with unsubscribe as the subject.