Changeset 38
- Timestamp:
- 06/03/06 13:11:55 (7 years ago)
- Files:
-
- branches/mk/cheesecake/cheesecake_index.py (modified) (8 diffs)
- branches/mk/cheesecake/codeparser.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/mk/cheesecake/cheesecake_index.py
r30 r38 222 222 self.INDEX_DIR_EMPTY = 5 223 223 self.MAX_INDEX_DOCSTRINGS = 100 # max. percentage of modules/classes/methods/functions with docstrings 224 self.MAX_INDEX_DOCFORMAT = 100 # max. percentage of modules/classes/methods/functions with formatted docstrings 224 225 self.MAX_INDEX_UNITTESTS = 100 # max. percentage of methods/functions that are unit tested 225 226 self.MAX_INDEX_PYLINT = 100 # max. pylint score … … 337 338 self.INDEX_INSTALL 338 339 self.max_cheesecake_index_documentation = self.INDEX_REQUIRED_FILES + \ 339 self.MAX_INDEX_DOCSTRINGS 340 self.MAX_INDEX_DOCSTRINGS + \ 341 self.MAX_INDEX_DOCFORMAT 340 342 self.max_cheesecake_index_codekwalitee = self.MAX_INDEX_PYLINT 341 343 # self.MAX_INDEX_UNITTESTS … … 346 348 for index_type in ["pypi_download", "url_download", 347 349 "unpack_dir", "unpack", "install", 348 "docstrings", " unittests", "pylint"]:350 "docstrings", "doc_format", "unittests", "pylint"]: 349 351 self.index[index_type] = Index(index_type) 350 352 … … 379 381 self.object_cnt = 0 # Number of modules/functions/classes/methods in .py files found 380 382 self.docstring_cnt = 0 383 self.docformat_cnt = 0 381 384 self.functions = [] # List of methods/functions found in .py files 382 385 … … 663 666 self.object_cnt += code.object_count() 664 667 self.docstring_cnt += code.docstring_count() 668 self.docformat_cnt += code.formatted_docstrings_count 665 669 self.functions += code.functions 666 670 elif self.is_test_file(file, dirs_in_rootdir): … … 801 805 # index["unpack"] is already set in unpack_pkg() 802 806 return self.index["unpack"] 803 804 807 805 808 def index_unpack_dir(self): … … 851 854 self.index[index_type].details = details 852 855 return self.index[index_type] 856 857 def index_doc_format(self): 858 percent = float(self.docformat_cnt)/float(self.object_cnt) 859 index_value = int(ceil(percent*100)) 860 details = "found %d/%d=%.2f%% modules/classes/methods/functions with formatted docstrings" %\ 861 (self.docformat_cnt, self.object_cnt, percent*100) 862 self.index["doc_format"].value = index_value 863 self.index["doc_format"].details = details 864 return self.index["doc_format"] 853 865 854 866 def index_unittests(self): … … 965 977 index_types, self.max_cheesecake_index_installability) 966 978 967 index_types = ["file", "dir", "doc strings"]979 index_types = ["file", "dir", "doc_format", "docstrings"] 968 980 self.cheesecake_index_documentation = self.process_partial_index("DOCUMENTATION",\ 969 981 index_types, self.max_cheesecake_index_documentation) branches/mk/cheesecake/codeparser.py
r37 r38 110 110 self.docstrings = [] # objects that have docstrings 111 111 self.docstrings_by_format = {} 112 self.formatted_docstrings_count = 0 112 113 113 114 # Initialize lists of format docstrings. … … 136 137 self.docstrings.append(fullname) 137 138 # Check docstring for known documenation formats. 139 formatted = False 138 140 for format in supported_formats: 139 141 if use_format(obj.docstring, format): 140 142 self.docstrings_by_format[format].append(fullname) 143 formatted = True 144 if formatted: 145 self.formatted_docstrings_count += 1 141 146 142 147 for method_or_func in self.method_func: … … 177 182 178 183 def docstring_count_by_type(self, type): 179 """Return number of reST docstringsfound in this module184 """Return number of docstrings of given type found in this module 180 185 """ 181 186 return len(self.docstrings_by_format[type])
