Re: ReSpec question

Comments inline:

On Mon, Mar 23, 2015 at 4:45 AM, Robin Berjon <robin@w3.org> wrote:

> Hi Shane,
>
> On 22/03/2015 22:22 , Shane McCarron wrote:
>
>> Sorry, I know I asked something like this before, but I have hit a
>> wall.  What I want to do is add a menu item to the respec UI.
>>
>> When I look in the profile-w3c.common.js file, I see pretty clearly how
>> to add a handler assuming I have a handle to the ui object.  But since
>> that object is somewhat buried, it is unclear to me how I can get at it
>> in a way that won't be brittle.
>>
>
> Is this for a specific draft, or something you'd like to add across the
> board for all ReSpec documents?
>

It is for a specific draft.  So I can't use either of your proposed
techniques.  I don't want to change ReSpec.  I just want to extend it.


>
> If the latter, then just add it in the same way as the others here:
>
>     https://github.com/w3c/respec/blob/develop/js/profile-w3c-
> common.js#L59
>
> Otherwise, you will need to write something along the lines of:
>
> define(["core/ui"], function (ui) {
>     ui.addCommand("Do Stuff", "ui/stuff-doer", "Ctrl+Shift+Alt-D");
> });
>
> And then have a module under ui/stuff.doer.js that's implemented in the
> same way as the others.
>
>  When do I want to get at it?  Well, the easiest way would be in an event
>> handler function:
>>
>> respecEvents.sub('end-all', function() {...});
>>
>
> A quick look at the code makes me think it would work pretty much at any
> moment, at least after the processing has started. So yeah, end-all seems
> like as good a place as any.


Are you suggesting that calling define from within an Event processor would
work?  I guess I hadn't tried that.


>
>
>  So at the end of respec processing, I add my menu and viola.  Any ideas?
>>
>
> PS: it's a common mistake, but I feel compelled to point out it's "voilĂ ",
> not "viola". The latter means "raped"; probably not what one intends to
> convey!


Yeah - I knew that.  I was too lazy to type the accented character, but
damn - sloppy!

-- 
Shane McCarron
Managing Director, Applied Testing and Technology, Inc.

Received on Monday, 23 March 2015 12:28:18 UTC