(Change to TipImported template + severe manual clean) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{TipImported |
{{TipImported |
||
|id=931 |
|id=931 |
||
− | |previous= |
+ | |previous=929 |
− | |next= |
+ | |next=933 |
− | |created= |
+ | |created=2005 |
|complexity=basic |
|complexity=basic |
||
|author=mixedvolume |
|author=mixedvolume |
||
|version=5.7 |
|version=5.7 |
||
|rating=19/8 |
|rating=19/8 |
||
+ | |category1=C++ |
||
+ | |category2= |
||
}} |
}} |
||
This tip builds on [[VimTip926]] (tagging QT help). With a different Perl parser given below for tagging STL documentation. |
This tip builds on [[VimTip926]] (tagging QT help). With a different Perl parser given below for tagging STL documentation. |
||
Line 17: | Line 19: | ||
</pre> |
</pre> |
||
− | Or press Control-T on < |
+ | Or press Control-T on <code>vector</code> to open stl/vector.html in your browser. |
− | Or do < |
+ | Or do <code>:ts /push</code> to find all tags names ~ push. |
How: |
How: |
||
Line 26: | Line 28: | ||
unzip STL_doc.zip |
unzip STL_doc.zip |
||
cd STL_doc |
cd STL_doc |
||
− | perl stl_tags.pl |
+ | perl stl_tags.pl > tags # script given below. |
</pre> |
</pre> |
||
Line 41: | Line 43: | ||
<pre> |
<pre> |
||
pos_type char_traits.html 133;" STL/Member |
pos_type char_traits.html 133;" STL/Member |
||
− | power power.html / |
+ | power power.html /<Title>/;" STL/Title |
− | prev_permutation prev_permutation.html / |
+ | prev_permutation prev_permutation.html /<Title>/;" STL/Title |
previous Slist.html 477;" STL/Member |
previous Slist.html 477;" STL/Member |
||
− | priority_queue priority_queue.html / |
+ | priority_queue priority_queue.html /<Title>/;" STL/Title |
priority_queue priority_queue.html 194;" STL/Member |
priority_queue priority_queue.html 194;" STL/Member |
||
priority_queue::empty priority_queue.html 290;" STL/Class::Member |
priority_queue::empty priority_queue.html 290;" STL/Class::Member |
||
Line 53: | Line 55: | ||
# What: tag stl documentation for use from gvim. |
# What: tag stl documentation for use from gvim. |
||
# How: wget http://www.sgi.com/tech/stl/STL_doc.zip; unzip stl_doc.zip |
# How: wget http://www.sgi.com/tech/stl/STL_doc.zip; unzip stl_doc.zip |
||
− | # cd stl_doc; perl stl_tags.pl |
+ | # cd stl_doc; perl stl_tags.pl > tags |
# In ~/.vimrc put this: |
# In ~/.vimrc put this: |
||
# :set tags^=stl_doc/tags |
# :set tags^=stl_doc/tags |
||
# au BufReadPost */stl/*.html :silent exe ":!c:/ opera/6*/opera.exe ".expand("%:p") | bd |
# au BufReadPost */stl/*.html :silent exe ":!c:/ opera/6*/opera.exe ".expand("%:p") | bd |
||
# Usage: vim file.cpp |
# Usage: vim file.cpp |
||
− | # :ta vector - |
+ | # :ta vector -> Opera will display stl_doc/vector.html |
# Author: Mohsin Ahmed |
# Author: Mohsin Ahmed |
||
Line 65: | Line 67: | ||
open(INDEX,"stl_index.html") or die "no stl_index.html?"; |
open(INDEX,"stl_index.html") or die "no stl_index.html?"; |
||
− | while( |
+ | while(<INDEX>){ $files{$1}++ if m/href="(\w+?.html)"/; } close INDEX; |
foreach $htmlf (keys %files){ |
foreach $htmlf (keys %files){ |
||
open(FILE,"$htmlf") or die "cannot read $htmlf"; |
open(FILE,"$htmlf") or die "cannot read $htmlf"; |
||
$lineno = $member=0; |
$lineno = $member=0; |
||
− | while( |
+ | while(<FILE>){ |
$lineno++; |
$lineno++; |
||
− | s,& |
+ | s,>,>,g; s,<,<,g; s,&,&,g; # html quadgraphs |
− | if( m,^ |
+ | if( m,^<Title>([\w\s]+), ){ $tag = $1; # tag single word titles |
next if $tag_seen{$tag}++ || $tag =~ m/\s/; |
next if $tag_seen{$tag}++ || $tag =~ m/\s/; |
||
− | push @mytaglist,"$tag\t$htmlf\t/ |
+ | push @mytaglist,"$tag\t$htmlf\t/<Title>/;\" STL/Title\n"; |
next; |
next; |
||
} |
} |
||
− | $members++ if m/ |
+ | $members++ if m/<h3>Members/i; # collect members in /Members/..eof() |
− | $members=0 if m, |
+ | $members=0 if m,</table>,i; |
− | if( $members & |
+ | if( $members && m,^<code>(.+?)</code>, ){ |
$tag=$1; |
$tag=$1; |
||
$tag = $1 if $tag =~ m/\b(\S+)\(/; # purge proto |
$tag = $1 if $tag =~ m/\b(\S+)\(/; # purge proto |
||
Line 98: | Line 100: | ||
==Comments== |
==Comments== |
||
− | |||
− | ---- |
||
− | [[Category:C plus plus]] |
Latest revision as of 05:57, 13 July 2012
Tip 931 Printable Monobook Previous Next
created 2005 · complexity basic · author mixedvolume · version 5.7
This tip builds on VimTip926 (tagging QT help). With a different Perl parser given below for tagging STL documentation.
In vim, you can now do
:ta vector
Or press Control-T on vector
to open stl/vector.html in your browser.
Or do :ts /push
to find all tags names ~ push.
How:
wget http://www.sgi.com/tech/stl/STL_doc.zip unzip STL_doc.zip cd STL_doc perl stl_tags.pl > tags # script given below.
In your vimrc put these two lines:
au BufReadPost */stl_doc/*.html :silent exe ":!c:/opera/6*/opera.exe ".expand("%:p") | bd set tags+=your_stl_dir/tags
I use Opera 6,7,8, but all browsers should work. The html files are opened in tabbed windows in Opera, so no clutter on desktop.
Feel free to hack the script, you can decide what tags you want from STL, here is an example of the tags you should get
pos_type char_traits.html 133;" STL/Member power power.html /<Title>/;" STL/Title prev_permutation prev_permutation.html /<Title>/;" STL/Title previous Slist.html 477;" STL/Member priority_queue priority_queue.html /<Title>/;" STL/Title priority_queue priority_queue.html 194;" STL/Member priority_queue::empty priority_queue.html 290;" STL/Class::Member priority_queue::pop priority_queue.html 334;" STL/Class::Member
# What: tag stl documentation for use from gvim. # How: wget http://www.sgi.com/tech/stl/STL_doc.zip; unzip stl_doc.zip # cd stl_doc; perl stl_tags.pl > tags # In ~/.vimrc put this: # :set tags^=stl_doc/tags # au BufReadPost */stl/*.html :silent exe ":!c:/ opera/6*/opera.exe ".expand("%:p") | bd # Usage: vim file.cpp # :ta vector -> Opera will display stl_doc/vector.html # Author: Mohsin Ahmed # make tags for html files listed stl_index.html open(INDEX,"stl_index.html") or die "no stl_index.html?"; while(<INDEX>){ $files{$1}++ if m/href="(\w+?.html)"/; } close INDEX; foreach $htmlf (keys %files){ open(FILE,"$htmlf") or die "cannot read $htmlf"; $lineno = $member=0; while(<FILE>){ $lineno++; s,>,>,g; s,<,<,g; s,&,&,g; # html quadgraphs if( m,^<Title>([\w\s]+), ){ $tag = $1; # tag single word titles next if $tag_seen{$tag}++ || $tag =~ m/\s/; push @mytaglist,"$tag\t$htmlf\t/<Title>/;\" STL/Title\n"; next; } $members++ if m/<h3>Members/i; # collect members in /Members/..eof() $members=0 if m,</table>,i; if( $members && m,^<code>(.+?)</code>, ){ $tag=$1; $tag = $1 if $tag =~ m/\b(\S+)\(/; # purge proto next if $tag =~ /href=/; # skip urls. $tag =~ s,^operator(\S+),$1,; # purge sugar my $file = $htmlf; $file =~ s,\..*,,; push @mytaglist,"$tag\t$htmlf\t$lineno;\" STL/Member\n" # member unless $seen{"$tag.$file"}++; $tag = "$file\::$tag"; # class::member push @mytaglist,"$tag\t$htmlf\t$lineno;\" STL/Class::Member\n" unless $tag_seen{$tag}++; } } close FILE; } print sort @mytaglist;