#40 parsing double-underscore attributes

v3.0
closed
Inspection (9)
5
2007-02-14
2006-10-02
Stargaming
No

I recommend extending the DocstringField class so that
e.g. DocstringField(['version'], 'Version',
multivalue=0) also parses the attribute __version__ (of
whatever: a module, a class, a function).

The parser could lookup hasattr(obj, '__%s__' % tag),
tag being every singe tag declared in
DocstringField(tags=[]).
For example `Deprecated` could be either __deprecated__
or __depreciated__ since they're both tags of
`Deprecated`: DocstringField(['deprecated',
'depreciated'], 'Deprecated', multivalue=0).
If multivalue is False (in a boolean context), the
content of __tag__ has to be str(..)-able (perhaps,
checking for isinstance(.., (int, str)) is better
because "Version: [2, 5, 0, 'alpha']" just looks ugly.
Could be worked-around with an "".join -- I hope you
get what I mean), and if multivalue is True it can be a
tuple or list or what-so-ever parsed as if you wrote
into your docstring:
"""@tag: first content
@tag: second content"""

I think this will improve inter-docparsing-ability
since epydoc would be parsing what is already in the
most cases given and not inventing a new scheme.

Thank you for reading.

Discussion

  • Daniele Varrazzo

    • milestone: --> v3.0
    • assigned_to: edloper --> dvarrazzo
     
  • Daniele Varrazzo

    Logged In: YES
    user_id=1053920
    Originator: NO

    I want to do something like this for 3.0 release, if not too hard.

     
  • Edward Loper

    Edward Loper - 2007-02-14

    Logged In: YES
    user_id=195958
    Originator: NO

    Added in rev1490. Field->varaible mappings must be explicitly specified via a new argument to the DocstringField constructor. (I prefer this because some fields don't seem to me to make sense to have var mappings, such as __see__).

    When introspecting, values can be str, unicode, int, float, bool, or None; or for multivalue fields, a list or tuple of those.

    When parsing, values can be str; or for multivalue fields, a list or tuple of str.

     
  • Edward Loper

    Edward Loper - 2007-02-14
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks