Re: CComment
Stefan Seefeld <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Bernhard Fischer wrote:
> Attached is a revised patch to add CComment which handles the tiny
> testcase (http://members.aon.at/berny_f/synopsis/) proper for me.
I'v looked at your patch, and used it myself with the new C parser,
and as it seemed to work nicely I checked it in. Thanks !
>>>the usual 'Parameter' idiom used everywhere else in the synopsis
>>>frontend.
>>
>>Ok, i'll try to use that.
>
>
>>From a short glance, i don't quite see how i'd do that. Could you
> elaborate or point me to an example, please?
A class that derives from 'Parametrized' (such as the CommentParsers)
may declare class-scope variables of type 'Parameter' which will
be mapped to object-scope variables, for example:
class CComment(CommentParser):
skip_star_prefix = Parameter(True, "Skip leading '*' on all lines")
def process(self):
if self.skip_star_prefix:
# remove leading '*' when concatenating lines
...
This little metaprogramming magic is provided by the Parametrized
and Parameter classes in Synopsis.Processor. Using this technique
the newly defined parameter is reflected into the UI, i.e. all
processors can be queried for the parameters they support
(for example by 'synopsis -h ...')
Regards,
Stefan