Vim Tips Wiki
(Added category, clean up)
m (STL (Standard Template Library/C PLUS PLUS ) help via tags. moved to STL help using tags - Cpp Standard Template Library: Page moved by JohnBot to improve title)

Revision as of 10:07, 18 October 2007

Previous TipNext Tip

Tip: #931 - STL help using tags - C++ Standard Template Library

Created: May 18, 2005 13:35 Complexity: basic Author: http://mixedvolume.blogspot.com Version: 5.7 Karma: 19/8 Imported from: Tip#931

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 the 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 opera6,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 

Mohsin.


# 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, http://www.cs.albany.edu/~mosh

# 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,&gt;,>,g; s,&lt;,<,g; s,&amp;,&,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,^<tt>(.+?)</tt>, ){ 
        $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;

Comments

Tok, haven't tried this yet, but this is almost exactly what I've been looking for - thanks alot...

Out of curiosity, any way to extend the perl script to generically use doxygen docs, that is, so I can tag "my_project/doxygen" html files.... (I'm sure it can be done, but like I said, I haven't looked around)...

aaronmgriffin--AT--gmail.com , May 19, 2005 9:44