Changeset 37

Show
Ignore:
Timestamp:
06/01/06 16:46:02 (7 years ago)
Author:
mk
Message:

Check docstrings for use of javadoc (closes ticket #12).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mk/cheesecake/codeparser.py

    r36 r37  
    6161    ], 
    6262 
    63     'javadoc': [], 
     63    # javadoc reference: http://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/javadoc.html 
     64    'javadoc': [ 
     65        re.compile(r'<[a-zA-z]+[^>]*>'), # HTML elements 
     66        line_markup(r'@[a-z][a-zA-Z]*\s', r''), # normal tags 
     67        re.compile(r'{@  ((docRoot) | (inheritDoc) | (link) | (linkplain) |'\ 
     68                    ' (value))  [^}]*  }', re.VERBOSE), # special tags 
     69    ], 
    6470} 
    6571 
  • branches/mk/tests/data/module1.py

    r36 r37  
    88    """ 
    99    Docstring for Class1 
     10 
     11    @see how.Tests#are(performed) 
    1012    """ 
    1113 
     
    8991    """This is test function for the epytext parser. 
    9092 
    91     @param argument: Description of an argument. 
     93    @param argument: And you really can't say if this is 
     94        epytext or javadoc! We count both. 
    9295    """ 
    9396    pass 
  • branches/mk/tests/test_code_parser.py

    r36 r37  
    5050        assert self.code1.docstring_count_by_type('reST') == 2 
    5151        assert self.code1.docstring_count_by_type('epytext') == 3 
     52        assert self.code1.docstring_count_by_type('javadoc') == 2 
    5253 
    5354    def test_docstrings(self): 
     
    7071            "module1.func8", 
    7172        ] 
    72  
    7373        objects_with_rest_docstrings = [ 
    7474            "module1.Class1.method5", 
    7575            "module1.func7", 
    7676        ] 
    77  
    7877        objects_with_epytext_docstrings = [ 
    7978            "module1", 
    8079            "module1.Class3", 
    8180            "module1.func8", 
     81        ] 
     82        objects_with_javadoc_docstrings = [ 
     83            "module1.Class1", 
     84            "module1.func8", # intentional overlap with epytext 
    8285        ] 
    8386 
     
    8790        assert set(objects_with_rest_docstrings) == set(self.code1.docstrings_by_format['reST']) 
    8891        assert set(objects_with_epytext_docstrings) == set(self.code1.docstrings_by_format['epytext']) 
     92        assert set(objects_with_javadoc_docstrings) == set(self.code1.docstrings_by_format['javadoc']) 
    8993 
    9094 
     
    144148 
    145149        self._do_it('epytext', valid_test_strings, invalid_test_strings) 
     150 
     151    def test_javadoc(self): 
     152        valid_test_strings = [ 
     153            'Inline <a href="{@docRoot}/html/documents/">are ugly</a>!', 
     154            "Call {@link #test_javadoc(object) test_javadoc} method.", 
     155            '@see Why#java(sucks)', 
     156        ] 
     157        invalid_test_strings = [ 
     158            "Normal text.", 
     159            "mail.address@example.com", 
     160            "Mathematical: a < b < c while x > y.", 
     161            "@it: is not javadoc, but epytext!", 
     162        ] 
     163 
     164        self._do_it('javadoc', valid_test_strings, invalid_test_strings)