mikaeljorhult / brackets-todo

Brackets/Edge Code extension that displays all TODO comments in current document or project.
144 stars 37 forks source link

Not detecting todo in /** comments #57

Closed dynamicdan closed 10 years ago

dynamicdan commented 10 years ago

How do I match something like this?

  /**
   * Handles all link triggers including:
   * - #internal-links
   * - /ajax-pages
   * - http://foreign.links.com
   * - mailto:links@site.com
   *
   * !DD TODO : it is possible to restore page AND position on page from the URL, enable this
   *
   * Fires from URL to onload
   *
   * @param path (String)
   */

The default regex failed to pick it up. I need the default PLUS this flexible comment style. Note that although consistent commenting would be nice, it's not always possible in big/strange projects.

I tried to modify the default but it failed... ( |* )

"prefix": "(?:\\/\\*|\\/\\/|#|\*) *@?(",

Perhaps this is not possible?

BTW, the "jsDoc / phpDoc Syntax" example failed to do anything useful for me. PS: I updated tags to include "!DD". !DD is a marker used in coda for a similar todo feature.

mikaeljorhult commented 10 years ago

I believe that the problem you're experiencing is because of the single backslash in "*". Since the JSON file is read by JavaScript as a string the two backslashes is required as the first one is escaped.

Try using the following in your .todo file.

{
    "regex": {
        "prefix": "(?:\\/\\*|\\/\\/|#|\\*) *(?:!DD)* *@?("
    }
}
mikaeljorhult commented 10 years ago

Were you able to get this to work @dynamicdan?

dynamicdan commented 10 years ago

Thanks! That did work. Ah, regex is wonderful when you can understand how it works.

mikaeljorhult commented 10 years ago

It can be a bit tricky but quite powerful once you get it.

I'm looking into making these kind of tweaks easier but keeping it as flexible at the same time makes it a bit hard.

dynamicdan commented 10 years ago

You might have enough data now to provide some presets or templates to turn on/off? You could still keep the regex as a fallback for the pros. If all else fails then a simple wiki page where devs can add their regex solutions would probably work quite well as a reference. The readme could link to a reference wiki page for various regex tips.

mikaeljorhult commented 10 years ago

There will probably be a dropdown with some presets and then a custom setting where you can enter the reg exp you wish to use.