DocBlockr
for SublimeText2
lets you declare your custom variable type rules based on the name of the variable.
From the README:
"jsdocs_notation_map": [{
"regex": "tbl_?[Rr]ow", // any arbitrary regex to test against the var name
"type": "TableRow" // you can add your own types
}]
I want to catch variables that start with the $ character
example:
"jsdocs_notation_map": [{
"regex": "^[$].+", // any word that starts with $
"type": "HTMLElement" // That is its type
}]
So that the $header will be caught from the above regex.
Unfortunately the above does not work. The plugin won’t recognize my $header variable
as an “HTMLElement”.
I have tried the following regex strings:
$– It matches everything, even varnames with no$inside them.\\$\\\\$$$\\$$\\\\$$[$][\\$]
Sidenote: The editor won’t let me insert odd numbers of \.
All of them match nothing, except for the first that matches everything.
This is not a RegEx question. The RegExs that should work, (ex: ^[$].+) simply do not work because of the $ character. I think it has to do with the plugin settings mechanism and how the $ is used by the python parsing mechanism.
Sidenote: The "^[.].+" RegEx works as expected.
Any help is most welcome
PS: If anyone can be of help, i would like the “^” in the start of the regex string. I don’t think that it won’t work out of the box, but if not, please share the knowledge on that as well.
Oh hey… so what the plugin does is strip any leading
$or_from the variable/function name and then apply the regex. This was added so that_foo$fooandfoocould all be recognised with the same regex, since at the time, I didn’t think about those characters having special meaning. Looks like it’s actually a complete misfeature in the end. Looks like you’ve spent a bit of time hacking on it, sorry ’bout that.I’ve added it to the issue tracker now. In the future, that would be a good way to get my attention, too 🙂