wiki:CodeTagsPlugin

Version 17 (modified by giel, 6 years ago) (diff)

--

A plugin for displaying code tags (XXX, FIXME, TODO, etc.)

NOTE: The links below seem to be dead. A git repository is available instead.

Blog posting here, Demo here, SVN repository. Since I cannot find any documentation directly I just wanted to tell you people that you need a subdirectory named cache thats writeable by your trac to make this work. Oh and dont wonder that it takes so much time the first time used ;). Also don't forget to grant the CODETAGS_VIEW permission.

To enable in the trac.ini:

[components]
codetags.* = enabled

Additional configuration options in trac.ini:

[code-tags]
scan_files = *.html, *.py, *.c, *.h, *.hh, *.m, *.pch, *.hpp
scan_folders = trunk/*, branches/*
tags = XXX, TODO, FIXME, BUG

scan_files allows you to define specific file types to scan (default: *)
scan_folders specifies which directories within the repository to scan (default: *)
tags allows you to specify what tags to locate, though only the defaults are colored at all. (default: XXX, TODO, FIXME)

By default, this plugin doesn't ignore binary files. If you use svn/trac in a web-dev environment, this is a pain, since the tagger finds tags in files such as .gif.

User submitted patch seems to work: http://trac.pocoo.org/attachment/ticket/109/diff.txt

Given the configuration options, I feel that the above referenced patch is unneeded if you have configured properly. On the other hand, there are legitimate uses for long strings of XXX's without them being a code tag. A simple one line change in indexer.py would eliminate 99% of XXX tags that were unintentional by requiring them to end with a colon:

  • indexer.py

     
    2727         
    2828        p = [] 
    2929        for word in self.tags: 
    30             p.append(re.escape(word)) 
     30            p.append(re.escape(word + ':')) 
    3131        self.tag_re = re.compile(r'(%s)\:?\s*(.*?)\s*$' % '|'.join(p)) 
    3232 
    3333        cdir = os.path.join(os.path.abspath(env.path), 'cache', 'codetags') 

I Think This Approach is better the Regex Matches TAG: AND TAG[SPACE]. The Above Patch only Matches TAG:Word & TAG::Word and TAG:[SPACE]

  • indexer.py

     
    2828 
    2929     for word in self.tags: 
    3030            p.append(re.escape(word)) 
    31         self.tag_re = re.compile(r'(%s)\:?\s*(.*?)\s*$' % '|'.join(p)) 
     31        self.tag_re = re.compile(r'(%s)[\:\s]+(.*?)\s*$' % '|'.join(p)) 
    3232 

Word Boundaries Patch

If you don't want to match comment lines containing your tags as subwords (e.g. DEBUG contains BUG and would normally match), you can apply this patch to indexer.py:

30c30
<             p.append(re.escape(word))
---
>             p.append(r'\b' + re.escape(word) + r'\b')

Feature Request

Since the tracker has no CodeTags component I will put that here:

  • Having a huge code base makes the table with the tags so huge that even modern browsers can hardly display it. Maybe:
    • Split it up into multiple pages
    • Choose display for only specified tags
    • Chose display for only specified path in repository
  • Additionally allow for blacklisting and/or patterns. E.g. we have plenty of BUG_FOOBAR constants that we obviously dont want in the list, so a blacklist for BUG_ but then still using all other BUG things would be nice.

Attachments (2)

Download all attachments as: .zip