Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:user_advanced:using_expand_macros_script [2014/04/14 11:52] (current)
Line 1: Line 1:
 +====== Using the expand_macros.pl script ======
  
 +  * The ''​expand_macros.pl''​ script allows you to get a list of all macros and where they are defined (in order to have macros defined in the c++ source included as well, you may specify the path to your Greenstone source directory; see the usage information of the script for details):
 +<​code>​
 +  expand_macros.pl -s '​.*'​
 +</​code>​
 +  * get definition of _query:​pagescriptextra_
 +<​code>​
 +  expand_macros.pl _query:​pagescriptextra_
 +</​code>​
 +output:
 +<​code>​*** macro: query:​pagescriptextra ***
 +
 + * query:​pagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 68)
 +   { _If_("​_cgiargqt_"​ eq "​1",​ _formpagescriptextra_,​ _selectpagescriptextra_) _If_("​_cgiarghd_"​ ne "​0",​_historypagescriptextra_) } }
 + </​code>​
 +
 +  * get macros that are used by _query:​pagescriptextra_ ('​-s'​ for short output, omit for display of definitions;​ '​-d'​ for depth, increase to see more levels):
 +<​code>​
 +  expand_macros.pl -s -d 2 _query:​pagescriptextra_
 +</​code>​
 +output:
 +<​code>​*** macro: query:​pagescriptextra ***
 +
 + * query:​pagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 68)
 +   * query:​formpagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 76)
 +     * query:​formfunctions [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 178)
 +     * query:​searchfunctions [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 478)
 +     * preferences:​standardfunctions [v=0] (/​usr/​local/​gsdl/​stable/​macros/​pref.dm,​ line 82)
 +     * query:​standardfunctions [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 143)
 +   * query:​historypagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 101)
 +   * query:​selectpagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 71)
 +     * query:​dummypagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 72)
 +     * query:​formpagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 76)
 +</​code>​
 +
 +  * get macros that use "​any"​ _pagescriptextra_ ('​-r'​ for reverse search):
 +<​code>​
 +  expand_macros.pl -r _pagescriptextra_
 +</​code>​
 +output:
 +<​code>​*** macro: pagescriptextra (reverse) ***
 +
 + * Style:​globalscripts [v=0] (/​usr/​local/​gsdl/​stable/​macros/​style.dm,​ line 142)
 +   { <​script>​ <!-- _imagescript_ _pagescriptextra_ // --> </​script>​ } }
 +
 + * homepref:​pagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​home.dm,​ line 198)
 +   { _preferences:​pagescriptextra_} }</​code>​
 +
 +  * get macros whose definitions contain "​blank.gif"​ (a search in the definition contents will be performed if the argument doesn'​t start, and end, with an underscore (actually, it's a bit more complicated,​ but that should suffice for the moment); is actually treated as full perl regular expression):​
 +<​code>​
 +  expand_macros.pl "​blank.gif"​
 +</​code>​
 +output:
 +<​code>​*** query: blank.gif ***
 +
 + * collector:​iconblank [v=0] (/​usr/​local/​gsdl/​stable/​macros/​collect.dm,​ line 42)
 +   { <img src="​_httpimg_/​blank.gif">​} }</​code>​
 +
 +  * get a macro that is defined in the c++ code (you need to extract a greenstone source archive and point to its base location, either via the '​--source'​ parameter or via a GSDLSOURCE environment variable): ​
 +<​code>​
 +  expand_macros.pl --source=/​usr/​local/​gsdl/​src/​stable/​ _collector:​pagescriptextra_
 +</​code>​
 +output:
 +<​code>​*** macro: collector:​pagescriptextra ***
 +
 + * collector:​pagescriptextra [v=0] (SERVER: /​usr/​local/​gsdl/​src/​stable/​src/​src/​recpt/​collectoraction.cpp,​ line 1058)
 +   { "​_"​ + collector_page + "​scriptextra_"​ }
 +</​code>​
 +
 +  * additionally,​ you can use expand_macros.pl to explore macros interactively ('​-i'​ or '​-b'​ for "​interactive",​ or "​browse",​ mode)
 +<​code>​
 +  expand_macros.pl -i
 +</code
 +output:
 +  <​code>​
 +   ​entered '​expand_macros.pl'​ in ***interactive browse mode*** (v0.22)
 + [you can get help at any time by typing '​.h',​ '​.?',​ or '​.help'​]
 +
 + enter macro name (without package specification) [leave empty to quit]
 + > pagescriptextra
 +   
 + ​select package for macro '​pagescriptextra'​ [leave empty to return]
 +   ​[1] ​   Style
 +   ​[2] ​   browse
 +   ​[3] ​   collector
 +   ​[4] ​   homepref
 +   ​[5] ​   preferences
 +   ​[6] ​   query
 + > 6
 +
 + * query:​pagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 68)
 + { _If_("​_cgiargqt_"​ eq "​1",​ _formpagescriptextra_,​ _selectpagescriptextra_)
 + ​_If_("​_cgiarghd_"​ ne "​0",​_historypagescriptextra_) } }
 +
 + ​[press key to continue]
 +
 + ​select macro [leave empty to return]
 +   ​[1] ​   formpagescriptextra
 +   ​[2] ​   historypagescriptextra
 +   ​[3] ​   selectpagescriptextra
 + > 1
 +
 + ​select package for macro '​formpagescriptextra'​ [leave empty to return]
 +  [1]    query 
 + > 1
 +
 + * query:​formpagescriptextra [v=0] (/​usr/​local/​gsdl/​stable/​macros/​query.dm,​ line 76)
 + { // query scripts generated by \_query:​pagescriptextra\_
 + ​_standardfunctions_
 + ​_formfunctions_
 + ​_searchfunctions_
 + ​function getsearchargs () \{
 +   var args="";​
 +   args = "&​fqa=0&​fqv="​+argfqv+"&​fqf="​+argfqf;​
 +  _If_(_cgiargqf_,​args += "&​fqk="​+argfqk+"&​fqs="​+argfqs+"&​fqc="​+argfqc;​)
 + ​return args;
 + \}
 + ​function getqueryargs () \{
 +   ​return "&​fqa=1"​+"&​q="​+argq+"&​fqv="​+argfqv+"&​fqf="​+argfqf+
 +     "&​fqk="​+argfqk+"&​fqs="​+argfqs+"&​fqc="​+argfqc ;
 + \}
 + } }
 +
 + ​[press key to continue]
 +
 + ​select macro [leave empty to return]
 +  [1]    formfunctions
 +  [2]    searchfunctions
 +  [3]    standardfunctions
 + >
 +
 + ​select package for macro '​formpagescriptextra'​ [leave empty to return]
 +  [1]    query
 + >
 +
 + ​select macro [leave empty to return]
 +  [1]    formpagescriptextra
 +  [2]    historypagescriptextra
 +  [3]    selectpagescriptextra
 + >
 +
 + ​select package for macro '​pagescriptextra'​ [leave empty to return]
 +  [1]    Style
 +  [2]    browse
 +  [3]    collector
 +  [4]    homepref
 +  [5]    preferences
 +  [6]    query
 + >
 +
 + enter macro name (without package specification) [leave empty to quit]
 + >
 +</​code>​
 +
 +//Thanks to Jens Wille//