[Gambas-user] another reason I love Gambas

Benoit Minisini gambas at ...2...
Sat Jun 7 11:28:17 CEST 2003


Le Vendredi 6 Juin 2003 19:35, Rob a écrit :
> I just added all the documentation for all of the component class members
> to the wiki in about 10 minutes by hacking the Gambas IDE source to do most
> of the work for me ;)
>
> In the FExplorer class I added
>
> PUBLIC avc AS File
>
> to the beginning and
>
> TRY KILL "/tmp/gambasdoc/" & aKey[1] & "." & akey[2] & ".txt"
> TRY OPEN "/tmp/gambasdoc/" & aKey[1] & "." & akey[2] & ".txt" FOR CREATE AS
> #avc
> TRY PRINT #avc, "<TABLE CELLPADDING=4 CELLSPACING=0 BORDER=0
> BGCOLOR=#C0C0C0 WIDTH=100%><TR><TD>" & sTitle & "</TD></TR></TABLE><BR>" &
> sDesc
> TRY CLOSE #avc
>
> to the end of the RefreshInfo sub in that class.  Then I hit F5, loaded a
> random project I had laying around, hit F2, and cursored through the entire
> list of component classes while it dumped HTML files for each class member
> to a directory in /tmp.  I paused after each component to move them into a
> subdirectory and when I was done, ran the following Perl script to
> integrate them with the class documentation I'd already extracted and
> wikify the lot (I would have used Gambas again but I don't know how to do
> regular expressions in Gambas ;) ):

Why not making a gambas perl regular expression component ? :-)

>
> #!/usr/bin/perl
> for $f (`find`) {
>     next if $f =~ m|/children/|;
>     next if $f =~ m|/classes/|;
>     next unless $f =~ /\.txt$/;
>     chomp $f;
>     $g = `cat $f`;
>     $basename = $f;
>     $basename =~ s/.txt$//;
>
>     # convert filenames to wiki words
>     $f =~ s/\//-/g;
>     $f =~ s/^\.-//;
>     $f =~ s/\[\]/Array/;
>     $f =~ s/^gb-/GambasComponentGb/;
>     $f =~ s/^gb.eval-/GambasComponentEval/;
>     $f =~ s/^gb.db-/GambasComponentDb/;
>     $f =~ s/^gb.qt-/GambasComponentQt/;
>     $f =~ s/^gb.qt.ext-/GambasComponentQtExt/;
>     $f =~ s/^gb.qt.kde-/GambasComponentQtKde/;
>     $f =~ s/^gb.qt.editor-/GambasComponentQtEditor/;
>     $f =~ s/\.//g;
>     $f =~ s/txt$/.txt/;
>
>     # convert HTML content to wiki text
>     $g .= `cat children/$basename* 2>/dev/null`;
>     $g =~ s/<i>\s*(.+?)\s*<\/i>/ _$1\_ /gi;
>     $g =~ s/<b>\s*(.+?)\s*<\/b>/ \*$1\* /gi;
>     $g =~ s/<h1>\s*(.+?)\s*<\/h1>/\n---+$1/is;
>     $g =~ s/<h1>\s*(.+?)\s*<\/h1>/\n---++<nop>$1/gis;
>     $g =~ s/<h2>\s*(.+?)\s*<\/h2>/\n---++<nop>$1/gsi;
>     $g =~ s/<br>/\n/gsi;
>     $g =~ s|/usr/lib/control|/gambas-wiki/images|gis;
>     $g =~ s|<IMG SRC="img/16/finger.png">|\n   * |gis;
>     $g =~ s/<\/?table.*?>/\n/gis;
>     $g =~ s/<\/?font.*?>//gis;
>     $g =~ s/<\/?tr.*?>/\n/gis;
>     $g =~ s/<\/?td.*?>/\n/gis;
>     $g =~ s/<p.*?>/\n\n/gis;
>     $g =~ s/<h3>\n/\n/gis;
>     $g =~ s/<h3>\s*(.+?)\s*<\/h3>/\n---+++<nop>$1/gi;
>     $g =~ s/\n\n+/\n\n/gis;
>     $g =~ s/^\n+//gis;
>     $g =~ s/<\/h3>//gis;
>
>     open OUT, ">fixed/$f";
>     print OUT $g;
>     close OUT;
>     print "$f\n";
> }
>
> And finally I scp'ed the whole thing up to the wiki.  So now we have a
> searchable, easily updated reference to all the component class members in
> the same format as the rest of the language.
>
> Try doing that in VB!
>
> Rob
>

Now I understand why I didn't see the symbol help in the wiki...

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list