Hi Sunanda,

<< 02 -- Help Unit-timer in the original returns an "overview" plus help for
each refinement. If Unit-timer were an object, there'd be no obvious place
for the overview. And I don't know any easy way of getting help for a
function embedded in an object  -- >>

I've started playing with an idea, just a rough one at this point, to make
it easier to get help for objects. Of course it could grow from there.

The idea is to provide a virtual base object (maybe "template" is a more
REBOLish term). I'm calling the draft version lib-kernel as my first target
is function LIBraries built as objects.


>> my-lib: make lib-kernel [
[        my-prn: :print
[        my-add: func [a b][a + b]
[    ]
>> my-lib/words
== [? help words help-words my-prn my-add]
>> my-lib/help
? [
    "Shows help for the object."
    /with "Means you want help for one, specific word."
    word "The word you want help for."
    /local value
]
------------------------------------------------------------------
help [
    "Shows help for the object."
    /with "Means you want help for one, specific word."
    word "The word you want help for."
    /local value
]
------------------------------------------------------------------
words []
------------------------------------------------------------------
help-words []
------------------------------------------------------------------
my-prn native
------------------------------------------------------------------
my-add [a b]
------------------------------------------------------------------
>> my-lib/help/with 'my-add
USAGE:
    MY-ADD a b

DESCRIPTION:
    (undocumented)

ARGUMENTS:
     a -- (Type: any)
     b -- (Type: any)


;--------------------------------------------
;-- lib-kernel.r source
;--------------------------------------------

REBOL [
    Title:   "lib-kernel"
    Author:  "Gregg Irwin"
    Email:   [EMAIL PROTECTED]
    Version: 0.0.1
]

lib-kernel: make object! [

    ;-- This is used to make the help functions in the sub-libraries.
    ;   They can redefine it, of course, but this gives us a base of
    ;   functionality.
    ?: help: func [
        "Shows help for the object."
        /with       "Means you want help for one, specific word."
            word    "The word you want help for."
        /local value
    ][
        either with [
            value: in get 'self :word
            either none? :value
                [print rejoin [:word " is not a word in library."]]
                [system/words/help :value]
        ][
            ;?? It might be better to show just the interface for each
            ;   function and/or an overview help text for the object.
            foreach word help-words [
                ; a)
                ;value: in get 'self :word
                ;system/words/help :value
                ; b)
                print either function? value: get in get 'self word [
                    [word mold third :value]
                ][
                    [word mold :value]
                ]
                print to-string array/initial 66 "-"
            ]
        ]
    ]

    ;-- List of words defined in the object.
    words: does [next first self]

    ;-- By default, help will return help for all words in the object.
    ;   You can override this to show help for just a subset of words.
    help-words: :words

]

--Gregg

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to