Talk:Ash Functions: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
No edit summary
imported>Heeheehee
mNo edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 6: Line 6:


Well, the problem that always comes up with using wiki category pages here is the formatting. Plus, it's not like the category page is going to automatically list new functions that no one has made a page for. My original intent was to write a simple script to parse the correct file(s) from KoLmafia's source and auto-generate the master function list page text. Then, anything without a page will show up red & we'll know what needs to be added, as well as having a well-formed page. Anyone want to take a stab at that? Or perhaps some other ideas for an automated solution? --[[Special:Contributions/75.48.127.248|75.48.127.248]] 08:35, 21 July 2010 (UTC)
Well, the problem that always comes up with using wiki category pages here is the formatting. Plus, it's not like the category page is going to automatically list new functions that no one has made a page for. My original intent was to write a simple script to parse the correct file(s) from KoLmafia's source and auto-generate the master function list page text. Then, anything without a page will show up red & we'll know what needs to be added, as well as having a well-formed page. Anyone want to take a stab at that? Or perhaps some other ideas for an automated solution? --[[Special:Contributions/75.48.127.248|75.48.127.248]] 08:35, 21 July 2010 (UTC)
Edit to add: Of course, it might be easier just to write a script to parse "ashref." Hmm. Also, why am I not auto-logging-in anymore? (--StDoodle)
:Cookie problem? Also, I haven't really looked at the code behind "ashref", nor do I really know how one would parse it using ASH, if that's what you're referring to. I might write up a bot, if I have enough time to figure it out. I'd assume that it'd parse RuntimeLibrary.java, though, and use some sort of regexp for matching nonsense. --[[User:Heeheehee|Heeheehee]] 15:52, 21 July 2010 (UTC)
:Probably it would be easier to type "ashref" in the CLI and copy-paste the result to a text file. Then write a program to parse that text into the correct format. That seems rather amateurish, but reasonably simple. --[[User:Bale|Bale]] 21:35, 21 July 2010 (UTC)
What Bale said. It's one of those time saved vs. work required things that's hard to justify. After all, this isn't something that needs to run every hour, day, or even week. Once a month would be more than enough. I'm still fairly swamped with work, so this isn't a project I can take on soon. In the meantime, it may be a good idea to explicitly link to the category page from the ash functions page if desired. --[[User:StDoodle|StDoodle (#1059825)]] 21:56, 21 July 2010 (UTC)
Threw together a dirty little ASH script to do all the page-visiting and cross-referencing of variables.
<div><syntaxhighlight>
buffer results;
results.append(visit_url("http://kolmafia.svn.sourceforge.net/viewvc/kolmafia/src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java"));
m = create_matcher("params = new Type\\[\\] \\{(.*?)\\};", results);
string[string,string]functions; // Keys are fname, params. Value is ftype.
while(m.find()) {
    string s;
    if(m.group(1)!="0") s = m.group(1).replace_string("DataTypes.","").replace_string("_TYPE","").to_lower_case();
    results.delete(0,m.end());
    matcher f = create_matcher("functions\\.add\\( new LibraryFunction\\( \"(\\w+)\", DataTypes\\.([A-Z]+?)_TYPE, params \\) \\);", results);
    if(f.find()) {
        functions[f.group(1), s] = f.group(2).to_lower_case();
    }
    m.reset(results);
}
results.set_length(0);
results.append(visit_url("http://wiki.kolmafia.us/index.php?title=Ash_Functions"));
foreach a,b,c in functions
    if(!results.contains_text(a)) print(a+":"+b+":"+c);
</syntaxhighlight></div>
Turns out {{f|enthrone_familiar}} was misnamed, and also missing were {{f|craft}} and {{f|get_related}}. So far it just checks for the latest build so it can check the latest revision of RuntimeLibrary.java, then adds the functions to a map which is then cross-referenced against [[Ash Functions]] and finally prints the function names if they're not found. (whew) Could make it more robust, but for now, I think this is good enough.
--[[User:Heeheehee|Heeheehee]] 18:05, 23 July 2010 (UTC)
Edit: Okay, yeah, there are quite a few bugs it runs into. It's obviously not perfect yet. --[[User:Heeheehee|Heeheehee]] 18:38, 23 July 2010 (UTC)
* Minor quirk in your code: <code>results.delete(0,results.length())</code> should be replaced by <code>results.set_length(0)</code> That's why {{f|set_length}} exists. --[[User:Bale|Bale]] 07:08, 24 July 2010 (UTC)
** Fair enough, fixed locally (and above). Also, I realized that the revision checking is probably unnecessary if you end the URL after ".java". And the last thing for now (I promise!) is that I'll probably need to modify the regex so that it also matches functions that return special types (e.g. {{f|appearance_rates}}) --[[User:Heeheehee|Heeheehee]] 01:55, 25 July 2010 (UTC)

Latest revision as of 01:55, 25 July 2010

Now that all the functions on this page have their own pages, wouldn't it be best to remove the page and allow Category:Ash Functions to be our master list of all functions? That would save the trouble of remembering to add new functions to this page like form_fields, entity_encode and entity_decode which aren't listed here. I think that this page has finished serving its purpose. --Bale 00:01, 18 May 2010 (UTC)

I repeat my question. Does anyone want to update this listing, or shall we replace it with [1] --Bale 20:48, 23 May 2010 (UTC)

Now that Heeeheehee commented in his edit, "Two functions that never found their way onto this list. I forget -- do we even maintain this page any more?" I'd like to reiterate that we can stop updating the list and replace it with this. That list will automatically update every time a new function is added. That's the wonder of categories. --Bale 04:25, 21 July 2010 (UTC)

Well, the problem that always comes up with using wiki category pages here is the formatting. Plus, it's not like the category page is going to automatically list new functions that no one has made a page for. My original intent was to write a simple script to parse the correct file(s) from KoLmafia's source and auto-generate the master function list page text. Then, anything without a page will show up red & we'll know what needs to be added, as well as having a well-formed page. Anyone want to take a stab at that? Or perhaps some other ideas for an automated solution? --75.48.127.248 08:35, 21 July 2010 (UTC)

Edit to add: Of course, it might be easier just to write a script to parse "ashref." Hmm. Also, why am I not auto-logging-in anymore? (--StDoodle)

Cookie problem? Also, I haven't really looked at the code behind "ashref", nor do I really know how one would parse it using ASH, if that's what you're referring to. I might write up a bot, if I have enough time to figure it out. I'd assume that it'd parse RuntimeLibrary.java, though, and use some sort of regexp for matching nonsense. --Heeheehee 15:52, 21 July 2010 (UTC)
Probably it would be easier to type "ashref" in the CLI and copy-paste the result to a text file. Then write a program to parse that text into the correct format. That seems rather amateurish, but reasonably simple. --Bale 21:35, 21 July 2010 (UTC)

What Bale said. It's one of those time saved vs. work required things that's hard to justify. After all, this isn't something that needs to run every hour, day, or even week. Once a month would be more than enough. I'm still fairly swamped with work, so this isn't a project I can take on soon. In the meantime, it may be a good idea to explicitly link to the category page from the ash functions page if desired. --StDoodle (#1059825) 21:56, 21 July 2010 (UTC)


Threw together a dirty little ASH script to do all the page-visiting and cross-referencing of variables.

buffer results;
results.append(visit_url("http://kolmafia.svn.sourceforge.net/viewvc/kolmafia/src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java"));
m = create_matcher("params = new Type\\[\\] \\{(.*?)\\};", results);
string[string,string]functions; // Keys are fname, params. Value is ftype.
while(m.find()) {
    string s;
    if(m.group(1)!="0") s = m.group(1).replace_string("DataTypes.","").replace_string("_TYPE","").to_lower_case();
    results.delete(0,m.end());
    matcher f = create_matcher("functions\\.add\\( new LibraryFunction\\( \"(\\w+)\", DataTypes\\.([A-Z]+?)_TYPE, params \\) \\);", results);
    if(f.find()) {
        functions[f.group(1), s] = f.group(2).to_lower_case();
    }
    m.reset(results);
}
results.set_length(0);
results.append(visit_url("http://wiki.kolmafia.us/index.php?title=Ash_Functions"));
foreach a,b,c in functions
    if(!results.contains_text(a)) print(a+":"+b+":"+c);

Turns out enthrone_familiar() was misnamed, and also missing were craft() and get_related(). So far it just checks for the latest build so it can check the latest revision of RuntimeLibrary.java, then adds the functions to a map which is then cross-referenced against Ash Functions and finally prints the function names if they're not found. (whew) Could make it more robust, but for now, I think this is good enough. --Heeheehee 18:05, 23 July 2010 (UTC)

Edit: Okay, yeah, there are quite a few bugs it runs into. It's obviously not perfect yet. --Heeheehee 18:38, 23 July 2010 (UTC)

  • Minor quirk in your code: results.delete(0,results.length()) should be replaced by results.set_length(0) That's why set_length() exists. --Bale 07:08, 24 July 2010 (UTC)
    • Fair enough, fixed locally (and above). Also, I realized that the revision checking is probably unnecessary if you end the URL after ".java". And the last thing for now (I promise!) is that I'll probably need to modify the regex so that it also matches functions that return special types (e.g. appearance_rates()) --Heeheehee 01:55, 25 July 2010 (UTC)