#Author: Raven0 @ buxville.net
*:/generate_AC_xml = >>>
/* Create file to write into */
@file = "MethodScript.xml";
try(read(@file),chd_create
(@file));
/* Prepare start of the file */
"<?xml version=\"1.0\" encoding=\"Windows-1252\" ?>",
"<!-- author: Raven0 \@ www.buxville.net -->",
"<NotepadPlus>",
" <AutoComplete language=\"MethodScript\">",
" <Environment ignoreCase=\"no\" startFunc=\"(\" stopFunc=\")\" paramSeparator=\",\" terminal=\";\"/>"
);
/* Prepare JSON file, as we will use it to quickly get rid of some escapes */
@file_JSON_prep = array();
@file_JSON_prep["functions"] = array();
@file_JSON_prep["events"] = array();
/* Grab extensions */
/* START OF THE PROCESSING TO JSON FILE */
for(@x = 0, @x < array_size(@CH_extensions),@x++
){
/* Define extension name
and version */
@extension_Version = @CH_extensions[@extension_Name]['version'];
/* Define extension functions
and events */
@functions = @CH_extensions[@extension_Name]['functions'];
@events = @CH_extensions[@extension_Name]['events'];
/*
Catch all functions
and prepare
for JSON */
@function_Name = @functions[@y];
try {
/* Declare function
and it
's arguments */
@file_JSON_prep["functions"][@function_Name] = array();
@file_JSON_prep["functions"][@function_Name]['args'] = reflect_docs(@function_Name,"args");
@file_JSON_prep["functions"][@function_Name]['return'] = reflect_docs(@function_Name,"return");
@file_JSON_prep["functions"][@function_Name]['description'] = reflect_docs(@function_Name,"description");
} catch(FormatException @ex) {console(colorize("&eCould not show information for function: &a".@function_Name."&r"),false);}
}
}
/* Catch all events and prepare for JSON */
for(@z = 0, @z < array_size(@events), @z++){
@event_Name = @events[@z];
if(!string_starts_with(@event_Name,"_")){
try {
/* Declare event and it's arguments */
@file_JSON_prep["events"][] = @event_Name;
} catch(FormatException
@ex) {console(colorize("&eCould not show information for event: &a".
@event_Name.
"&r"),false);
}
}
}
}
/* ENCODE TO JSON FORMAT */
/* Start of the processing from JSON to XML */
/* FUNCTIONS */
@process_Functions = @file_JSON["functions"];
foreach(@function: @function_Args in @process_Functions){
/* FUNCTION NAME */
/* Process function name
and write to XML */
@process_Function_Name = @function;
@file_Write[] = " <KeyWord name=\"".@process_Function_Name."\" func=\"yes\">";
/* FUNCTION RETURNS & DESCRIPTION */
/* RETURNS */
@process_Function_Return = @function_Args["return"];
/* DESCRIPTION */
@process_Function_Description = @function_Args["description"];
/* REMOVE UNNECESSARY CHARACTERS/TAGS/ETC FROM DESCRIPTION */
# List of unwanted onesin order of removal: <code> <\/code> \u0003 <li> <\/li> <pre> <\/pre> <ul> <\/ul>
@process_Function_Description_prep_1 = replace(replace(replace(replace(replace(replace(replace(replace(replace(@process_Function_Description,"<code>",""),"<\\//code>",""),"\u0003",""),"<li>",""),"<\\//li>",""),"<pre>",""),"<\\//pre>",""),"<ul>",""),"<\\//ul>","");
/*
REPLACE end of line
and escape some characters */
# List in order of replacement: \n -> 
, @ -> \@, \/ -> \//, < -> <, > -> >, ' -> ', " -> "
@process_Function_Description_prep_2 = replace(replace(replace(replace(replace(replace(@process_Function_Description_prep_1,"\n","
"),"\@","\\@"),">",">"),"<","<"),"'","'"),'"',""");
/*
REPLACE all
{{function|some_name
}} description tags meant
for forum links */
@find_Code_prep = reg_match('\\{\\{function\\|.+\\}\\}',@process_Function_Description_prep_2)
@find_Code = @find_Code_prep[0];
@find_CodeValue = reg_match('(?<=\\|)(.*)(?=.\\})',@find_Code)[0];
@process_Function_Description_prep_3 = replace(@process_Function_Description_prep_2,@find_Code,@find_CodeValue);
}
else{
@process_Function_Description_prep_3 = @process_Function_Description_prep_2;
}
/* GET RID of all way too long descriptions, which may have html tables/tags in them */
/* Long descriptions that start with ---- */
@newString = substr(@process_Function_Description_prep_3,0,string_position(@process_Function_Description_prep_3,"----"));
@process_Function_Description_prep_4 = @newString;
} else{ @process_Function_Description_prep_4 = @process_Function_Description_prep_3; }
/* HTML bb codes for table */
@newString2 = substr(@process_Function_Description_prep_4,0,string_position(@process_Function_Description_prep_4,"{|")).substr
(@process_Function_Description_prep_4,(string_position(@process_Function_Description_prep_4,"|}") +
1));
@process_Function_Description_prep_5 = @newString2;
} else{ @process_Function_Description_prep_5 = @process_Function_Description_prep_4; }
/* Simply aesthetic
, but
replace single dot
as end of line */
@process_Function_Description_prep_6 = replace(@process_Function_Description_prep_5,". ",".
");
/*
Replace next line triggers with nothing
if on the end of description */
@process_Function_Description_prepared = replace(@process_Function_Description_prep_6,"
","");
}
else { @process_Function_Description_prepared = @process_Function_Description_prep_6;}
/* WRITE TO XML */
@file_Write[] = " <Overload retVal=\"".@process_Function_Return."\" descr=\"".@process_Function_Description_prepared."\">";
/* FUNCTION ARGS */
/* Process function arguments
and write to XML */
@process_Function_Args = @function_Args["args"];
/* Prepare counters
, as we will
split parentheses from other arguments */
@open_parentheses = 0;
@closed_parentheses = 0;
@word = 0;
/* Process arguments */
@processArgs = @process_Function_Args;
for(@countChar = 0, @countChar < length(@processArgs), @countChar++
){
@character = @processArgs[@countChar];
if(@character == ","){
if(@open_parentheses != @closed_parentheses){ @skipWrite = false; }
else{ @word++; @skipWrite = true;}
}
else if(@character == "[") { @open_parentheses++; @skipWrite = false; }
else if(@character == "]") { @closed_parentheses++; @skipWrite = false; }
else { @skipWrite = false; }
if(@skipWrite == false) {
else{ @arguments[@word] .= @character; }
}
}
/* Push arguments into XML */
foreach(@argument in @arguments){
@file_Write[] = " <Param name=\"".@argument."\"/>";
}
/* WRITE REST OF XML PORTION for function */
@file_Write[] = " </Overload>"
@file_Write[] = " </KeyWord>"
}
/* EVENTS */
@process_Events = @file_JSON["events"];
foreach(@event in @process_Events){
/* EVENT NAME */
/* Process event name
and write to XML */
@process_Event_Name = @event;
@file_Write[] = " <KeyWord name=\"".@process_Event_Name."\" func=\"yes\">";
/* WRITE REST OF XML PORTION for event */
@file_Write[] = " <Overload retVal=\"mixed\" descr=\"One of CH's or extension events.
Consult it's wiki for further information.\">";
@file_Write[] = " <Param name=\"eventData\"/>";
@file_Write[] = " </Overload>"
@file_Write[] = " </KeyWord>"
}
/* Finish XML writing */
@file_Write[] = " </AutoComplete>";
@file_Write[] = "</NotepadPlus>";
/* Write XML file */
@writeFile = "";
foreach(@stringLine in @file_Write){
@writeFile .= @stringLine."\n";
}
chd_write(@file,@writeFile,"OVERWRITE");
<<<