code to retrieve all method categories and methods under a category

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
tty
Reply | Threaded
Open this post in threaded view
|

code to retrieve all method categories and methods under a category

tty
Hi All.

I want to dynamically build a drop-down menu in Seaside based on the
instance side methods I have in a class.

#MyClass has method categories: "Attributes Links Paragraph....etc"
Under Method category Links are  methods #testLinkCategory,
testLinkExternal, testLink....etc.

I have been hunting for over an hour and I see no obvious way to retrieve
this info (I have found a way to get all the methods, but not the category
that houses them.


The code I have in mind has form:

*categories := categoriesFor: #MyClass.

categories do:[:cat | |methods|
             methods :=  methodForClass:#MyClass category: cat.
             methods do:[:m |
                             "dynamically build my html here"
]]l*


Any help much appreciated.

thx



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

Tim Johnson-2
Hi Timothy,

On Jan 15, 2020, at 1:26 PM, tty wrote:

> Hi All.
>
> I want to dynamically build a drop-down menu in Seaside based on the
> instance side methods I have in a class.

Have you looked at the Seaside sample code for the WABrowser?  On some Seaside images it will be registered at tools/classbrowser by default.  I believe it uses a normal Browser as its model, so that's where to go to find out what's actually going on in the background.

> I have been hunting for over an hour and I see no obvious way to retrieve
> this info (I have found a way to get all the methods, but not the category
> that houses them.
>
> Any help much appreciated.

Have you looked at ClassOrganizer and ClassDescription?

best,
a Tim

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

tty
Hi Tim,

Thank you for the reply.

I was able to get the data by middle clicking on the Browser pane displaying
the data and inspecting the model.

I then hand tweaked it, so my immediate task is solved.

I did look at a ClassOrganizer and ClassDescription but I keep getting
nothing for what look like obvious candidates.

For example:

*WikitextParserFactory
allMethodCategoriesIntegratedThrough:WikitextParserFactory

WikitextParserFactory whichCategoryIncludesSelector:#testTableCaption

*both return nada.






--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

tty
In reply to this post by tty
I just realized that I am trying to get Class side methods.

I have no Instance side methods.

Interesting!

I am going to change my WikitextParserFactory to a Singleton and move all
the methods to Instanced side.

bet it will work then.

cheers!



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

Christoph Thiede
In reply to this post by tty

[resent due to attachment limit, sorry for the delay!]


Hi Timothy,


not sure if your question has already been answered, but maybe this approach can help you in general to find answers to problems like these. Let's dive into some reverse engineering tools of Squeak!


First, start a normal System Browser and open the halo on the message category list:

Then open its debug menu by clicking the wrench icon and choose "browse action code":
And you get the method which the list is configured to call in order to get its contents:
 
By selecting #rawMessageCategoryList and pressing <cmd>m, you also get the second screenshot where you can see that your desired method is named #categories. Select #classOrMetaClassOrganizer and press <cmd>m again to find out where the organizer comes from:

Okay, this is stored as an instance variable, but how is it set? Right-click the message from the list and choose "assignments..." (you can also do this in any class browser, btw). Next, select classOrganizer from the list.

And you will find:


So your script might look like this: MyClass organization categories.

I hope this might help you to answer future questions! And please forgive me if I told you something you already knew :-)
Have a nice time with Squeak!

Best,
Christoph


Von: Beginners <[hidden email]> im Auftrag von tty <[hidden email]>
Gesendet: Mittwoch, 15. Januar 2020 20:26 Uhr
An: [hidden email]
Betreff: [Newbies] code to retrieve all method categories and methods under a category
 
Hi All.

I want to dynamically build a drop-down menu in Seaside based on the
instance side methods I have in a class.

#MyClass has method categories: "Attributes Links Paragraph....etc"
Under Method category Links are  methods #testLinkCategory,
testLinkExternal, testLink....etc.

I have been hunting for over an hour and I see no obvious way to retrieve
this info (I have found a way to get all the methods, but not the category
that houses them.


The code I have in mind has form:

*categories := categoriesFor: #MyClass.

categories do:[:cat | |methods|
             methods :=  methodForClass:#MyClass category: cat.
             methods do:[:m |
                             "dynamically build my html here"
]]l*


Any help much appreciated.

thx



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
forum.world.st
Squeak - Beginners forum and mailing list archive. This list is the place to ask all the "simple" questions you as a newcomer to squeak always wanted to ask.


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!
tty
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

tty
Thank you Christoph.



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
tty
Reply | Threaded
Open this post in threaded view
|

Re: code to retrieve all method categories and methods under a category

tty
In reply to this post by tty
Thanks to all for the pointers.

Here is what I came up with.
To get all the categories, remove the "reject:" block



> Transcript clear.
> (((WikitextParserFactory
> allMethodCategoriesIntegratedThrough:WikitextParserFactory) sorted)
>  reject:[:r |
> |oc|
> oc := OrderedCollection
> with:#accessing
> with: #'initialize-release'
> with: #parsing
> with: #'Templates Bogus'.
> oc includes:r]) do:[:c |
>
> (WikitextParserFactory packageInfo methodsInCategory: c
> ofClass:WikitextParserFactory)
> do:[:m |
> Transcript show: c , ' -> ',  m methodSymbol; cr.
> ]].

cheers.



--
Sent from: http://forum.world.st/Squeak-Beginners-f107673.html
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners