From 850d793c00d7e89395b5890557f28a5b807434ec Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 21 Mar 2016 21:15:26 +0100 Subject: [PATCH] cont'd lua HTML doc. --- tools/fmt-luadoc.php | 149 +++++++++++++++++++++++++++++++++---------- 1 file changed, 117 insertions(+), 32 deletions(-) diff --git a/tools/fmt-luadoc.php b/tools/fmt-luadoc.php index 758d2c600a..4a8940f30d 100755 --- a/tools/fmt-luadoc.php +++ b/tools/fmt-luadoc.php @@ -29,7 +29,6 @@ if (count ($doc) == 0) { ################################################################################ $classlist = array (); -$funclist = array (); $constlist = array (); @@ -41,6 +40,7 @@ $constlist = array (); ################################################################################ # some internal helper functions first +$funclist = array (); $classes = array (); $consts = array (); @@ -192,10 +192,52 @@ foreach ($doc as $b) { # we required C functions to be in a class namespace case "Ext C Function": checkclass ($b); + $args = array (array ('--custom--' => 0)); + $ret = array ('...' => 0); + $ns = luafn2class ($b['lua']); + $cls = $classlist[$ns]; + ## std::Vector std::List types + if (preg_match ('/.*<([^>]*)[ ]*>/', $cls['decl'], $templ)) { + // XXX -> move to C-source + switch (stripclass($ns, $b['lua'])) { + case 'add': + $args = array (array ('LuaTable {'.$templ[1].'}' => 0)); + $ret = array ('void' => 0); + break; + case 'iter': + $args = array (); + $ret = array ('LuaIter' => 0); + break; + case 'table': + $args = array (); + $ret = array ('LuaTable' => 0); + break; + default: + break; + } + } else if (strpos ($cls['type'], ' Array') !== false) { + $templ = preg_replace ('/[&*]*$/', '', $cls['decl']); + switch (stripclass($ns, $b['lua'])) { + case 'array': + $args = array (); + $ret = array ('LuaMetaTable' => 0); + break; + case 'get_table': + $args = array (); + $ret = array ('LuaTable' => 0); + break; + case 'set_table': + $args = array (array ('LuaTable {'.$templ.'}' => 0)); + $ret = array ('void' => 0); + break; + default: + break; + } + } $classlist[luafn2class ($b['lua'])]['func'][] = array ( 'name' => $b['lua'], - 'args' => array (array ('--custom--' => 0)), // XXX - 'ret' => array ('...' => 0), // XXX + 'args' => $args, + 'ret' => $ret, 'ref' => true, 'ext' => true ); @@ -278,6 +320,20 @@ foreach ($funclist as $ns => $fl) { ksort ($classlist); +################################################################################ +################################################################################ +################################################################################ + + +#### -- split here -- #### + +# from here on, only $classlist and $constlist arrays are relevant. + +# TODO: read function documentation from doxygen +# and/or reference source-code lines e.g from CSV list: +# ctags -o /tmp/tags.csv --fields=+afiKkmnsSzt libs/ardour/ardour/session.h + + ################################################################################ # OUTPUT ################################################################################ @@ -291,6 +347,10 @@ function ctorname ($name) { return htmlentities (str_replace (':', '.', $name)); } +function shortname ($name) { + return htmlentities (substr ($name, strrpos ($name, ':') + 1)); +} + function varname ($a) { return array_keys ($a)[0]; } @@ -299,15 +359,33 @@ function name_sort_cb ($a, $b) { return strcmp ($a['name'], $b['name']); } -function typelink ($a, $linkcls = '', $argcls = '') { +function traverse_parent ($ns, &$inherited) { + global $classlist; + $rv = ''; + if (isset ($classlist[$ns]['luaparent'])) { + $parents = array_unique ($classlist[$ns]['luaparent']); + asort ($parents); + foreach ($parents as $p) { + if (!empty ($rv)) { $rv .= ', '; } + $rv .= typelink ($p); + $inherited[$p] = $classlist[$p]; + traverse_parent ($p, $inherited); + } + } + return $rv; +} + +function typelink ($a, $short = false, $argcls = '', $linkcls = '', $suffix = '') { global $classlist; global $constlist; + # all cross-reference links are generated here. + # currently anchors on a single page. if (in_array ($a, array_keys ($classlist))) { - return ''.$a.''; + return ''.($short ? shortname($a) : htmlentities($a)).$suffix.''; } else if (in_array ($a, array_keys ($constlist))) { - return ''.ctorname ($a).''; + return ''.($short ? shortname($a) : ctorname($a)).$suffix.''; } else { - return ''.$a.''; + return ''.htmlentities($a).$suffix.''; } } @@ -318,9 +396,9 @@ function format_args ($args) { if (!$first) { $rv .= ', '; }; $first = false; $flags = $a[varname ($a)]; if ($flags & 1) { - $rv .= typelink (varname ($a).'&', '', 'em'); + $rv .= typelink (varname ($a), true, 'em', '', '&'); } else { - $rv .= typelink (varname ($a), '', 'em'); + $rv .= typelink (varname ($a), true, 'em'); } } $rv .= ')'; @@ -354,26 +432,26 @@ function format_class_members ($ns, $cl, &$dups) { $rv.= ' '; if ($f['ref'] && isset ($f['ext'])) { # external C functions - $rv.= 'LuaTable'; + $rv.= ''.varname ($f['ret']).''; } elseif ($f['ref'] && varname ($f['ret']) == 'void') { # functions with reference args return args $rv.= 'LuaTable(...)'; } elseif ($f['ref']) { - $rv.= 'LuaTable('.typelink (varname ($f['ret'])).', ...)'; + $rv.= 'LuaTable('.typelink (varname ($f['ret'], false, 'em')).', ...)'; } else { - $rv.= typelink (varname ($f['ret'])); + $rv.= typelink (varname ($f['ret']), true, 'em'); } $rv.= ''; $rv.= ''.stripclass ($ns, $f['name']).''; $rv.= format_args ($f['args']); $rv.= ''.NL; -} + } } if (isset ($cl['data'])) { usort ($cl['data'], 'name_sort_cb'); $rv.= ' Data Members'.NL; foreach ($cl['data'] as $f) { - $rv.= ' '.typelink (array_keys ($f['ret'])[0]).''; + $rv.= ' '.typelink (array_keys ($f['ret'])[0], false, 'em').''; $rv.= ''.stripclass ($ns, $f['name']).''; $rv.= ''.NL; } @@ -384,6 +462,7 @@ function format_class_members ($ns, $cl, &$dups) { ################################################################################ # Start Output + ?> @@ -401,7 +480,7 @@ h2.pointerclass { background-color: #eeaa66; } h2.array { background-color: #66aaee; } h2.opaque { background-color: #6666aa; } p.cdecl { text-align: right; float:right; font-size:90%; margin:0; padding: 0 0 0 1em;} -ul.classlist { columns: 2; -webkit-columns: 2; -moz-columns: 2; } +ul.classindex { columns: 2; -webkit-columns: 2; -moz-columns: 2; } div.clear { clear:both; } table.classmembers { width: 100%; } table.classmembers th { text-align:left; border-bottom:1px solid black; padding-top:1em; } @@ -427,6 +506,20 @@ div.header p {margin:.25em;}
+

Overview

+

+The top-level entry point are and . +Most other Classes are used indirectly starting with a Session function. e.g. Session:get_routes(). +

+

+A few classes are dedicated to certain script types, e.g. Lua DSP processors have exclusive access to + and . Action Hooks Scripts to + etc. +

+

+Detailed documentation (parameter names, method description) is not yet available. Please stay tuned. +

+ Class Documentation'.NL; @@ -434,8 +527,8 @@ foreach ($classlist as $ns => $cl) { $dups = array (); $tbl = format_class_members ($ns, $cl, $dups); + # format class title if (empty ($tbl)) { - # place-holder class (maybe collect at bottom??) echo '

 '.$ns.'

'.NL; } else if (isset ($classlist[$ns]['free'])) { @@ -453,21 +546,15 @@ foreach ($classlist as $ns => $cl) { echo '

C‡: '.htmlentities ($cl['decl']).'

'.NL; } + # print class inheritance $inherited = array (); - if (isset ($classlist[$ns]['luaparent'])) { - $parents = array_unique ($classlist[$ns]['luaparent']); - asort ($parents); - echo '

is-a: '; - $first = true; - foreach ($parents as $p) { - if (!$first) { echo ', '; }; $first = false; - echo typelink ($p); - $inherited[$p] = $classlist[$p]; - } - echo '

'.NL; + $isa = traverse_parent ($ns, $inherited); + if (!empty ($isa)) { + echo '

is-a: '.$isa.'

'.NL; } echo '
'.NL; + # member documentation if (empty ($tbl)) { echo '

This class object is only used indirectly as return-value and function-parameter.

'.NL; } else { @@ -476,7 +563,7 @@ foreach ($classlist as $ns => $cl) { echo ' '.NL; } - // traverse all parent classes.. + # traverse parent classes (inherited members) foreach ($inherited as $pns => $pcl) { $tbl = format_class_members ($pns, $pcl, $dups); if (!empty ($tbl)) { @@ -499,14 +586,12 @@ foreach ($constlist as $ns => $cs) { } echo '

Class Index

'.NL; -echo '