From CockosWiki
#
# mkReaperAPIPages.pl
# Generates rough Wiki pages for the API
#
use strict;
use warnings;
my $function_name;
my $function_proto;
my $parameter_list;
my $return_val;
my $returns_list;
my $description;
my $page;
my $line;
my $tmp_line;
my $regex_str;;
my $count = 0;
while(<DATA>){
chomp;
unless(/^REAPERAPI_DECL/){
$_ = $' if /\/\/ /;
$description .= "$_\n";
next;
}
# a new function line looks like this
# REAPERAPI_DECL void (*format_timestr)(double tpos, char* buf, int buflen);
# so, pick out the function name
/\(\*/; # find start of function name
$line = $'; # set $line to all after previous regex match
$line =~ /\)/; # find end of function name
$function_name = $`; # save the function name
# then the parameters
/\)\(/; # start of parameter list
$line = $';
$line =~ /;/; # end of parameter list
$line = $`;
$parameter_list = '(' . $line;
# then the return value
/^REAPERAPI_DECL /;
$line = $';
$line =~ /\(\*/;
$return_val = $`; # the single return value
# and put together prototype
$function_proto = $return_val . " " .
$function_name . $parameter_list;
# reformat the parameters list
$parameter_list =~ s/\(/ /; # replace ( with ' '
$parameter_list =~ s/\)//; # remove )
$parameter_list =~ s/, /\n /g; # replace all ', ' with '\n '
$page = "{{API_Doc_Header}}\n" .
"=$function_name()=\n" .
"'''$function_proto'''\n\n" .
"$description\n\n" .
"==Parameters==\n" .
"$parameter_list\n" .
"==Returns==\n" .
" $return_val\n" .
"==Examples==\n" .
"==See Also==\n" .
"==Stuff==\n" .
"{{API_Doc_Footer}}\n" .
"[[Category:API]]\n" .
'-' x 50 . "\n";
print $page; # print the page which has just been collated
$page =
$function_name =
$function_proto =
$description =
$parameter_list =
$return_val = '';
}
__DATA__
// __mergesort is a stable sorting function with an API similar to qsort().
// HOWEVER, it requires some temporary space, equal to the size of the data being sorted, so you can pass it as the last parameter,
// or NULL and it will allocate and free space internally.
REAPERAPI_DECL void (*__mergesort)(void* base, size_t nmemb, size_t size, int (*cmpfunc)(const void*,const void*), void* tmpspace);
// menuidstr is some unique identifying string
// menuname is for main menus only (displayed in a menu bar somewhere), NULL otherwise
// kbdsecname is the name of the KbdSectionInfo registered by this plugin, or NULL for the main actions section
REAPERAPI_DECL bool (*AddCustomizableMenu)(const char* menuidstr, const char* menuname, const char* kbdsecname, bool addtomainmenu);
// Add an Extensions main menu, which the extension can populate/modify with plugin_register("hookcustommenu")
REAPERAPI_DECL bool (*AddExtensionsMainMenu)();
// creates a new media item.
REAPERAPI_DECL MediaItem* (*AddMediaItemToTrack)(MediaTrack* tr);
// Returns the index of the created marker/region, or -1 on failure. Supply wantidx>=0 if you want a particular index number, but you'll get a different index number a region and wantidx is already in use.
REAPERAPI_DECL int (*AddProjectMarker)(ReaProject* proj, bool isrgn, double pos, double rgnend, const char* name, int wantidx);
(and lots more)