Changeset 38

Show
Ignore:
Timestamp:
06/03/06 13:11:55 (7 years ago)
Author:
mk
Message:

Incorporate formatted docstrings count into documentation index.

Files:

Legend:

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

    r30 r38  
    222222        self.INDEX_DIR_EMPTY     = 5 
    223223        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 
    224225        self.MAX_INDEX_UNITTESTS  = 100 # max. percentage of methods/functions that are unit tested 
    225226        self.MAX_INDEX_PYLINT     = 100 # max. pylint score 
     
    337338                                            self.INDEX_INSTALL 
    338339        self.max_cheesecake_index_documentation = self.INDEX_REQUIRED_FILES + \ 
    339                                         self.MAX_INDEX_DOCSTRINGS 
     340                                        self.MAX_INDEX_DOCSTRINGS + \ 
     341                                        self.MAX_INDEX_DOCFORMAT 
    340342        self.max_cheesecake_index_codekwalitee = self.MAX_INDEX_PYLINT  
    341343#                                        self.MAX_INDEX_UNITTESTS 
     
    346348        for index_type in ["pypi_download", "url_download",  
    347349                           "unpack_dir", "unpack", "install", 
    348                            "docstrings", "unittests", "pylint"]: 
     350                           "docstrings", "doc_format", "unittests", "pylint"]: 
    349351            self.index[index_type] = Index(index_type) 
    350352 
     
    379381        self.object_cnt = 0  # Number of modules/functions/classes/methods in .py files found 
    380382        self.docstring_cnt = 0 
     383        self.docformat_cnt = 0 
    381384        self.functions = [] # List of methods/functions found in .py files 
    382385 
     
    663666                    self.object_cnt += code.object_count() 
    664667                    self.docstring_cnt += code.docstring_count() 
     668                    self.docformat_cnt += code.formatted_docstrings_count 
    665669                    self.functions += code.functions 
    666670                elif self.is_test_file(file, dirs_in_rootdir): 
     
    801805        # index["unpack"] is already set in unpack_pkg() 
    802806        return self.index["unpack"] 
    803  
    804807 
    805808    def index_unpack_dir(self): 
     
    851854        self.index[index_type].details = details 
    852855        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"] 
    853865 
    854866    def index_unittests(self): 
     
    965977                                         index_types, self.max_cheesecake_index_installability) 
    966978 
    967         index_types = ["file", "dir", "docstrings"] 
     979        index_types = ["file", "dir", "doc_format", "docstrings"] 
    968980        self.cheesecake_index_documentation = self.process_partial_index("DOCUMENTATION",\ 
    969981                                         index_types, self.max_cheesecake_index_documentation) 
  • branches/mk/cheesecake/codeparser.py

    r37 r38  
    110110        self.docstrings = [] # objects that have docstrings 
    111111        self.docstrings_by_format = {} 
     112        self.formatted_docstrings_count = 0 
    112113 
    113114        # Initialize lists of format docstrings. 
     
    136137                self.docstrings.append(fullname) 
    137138                # Check docstring for known documenation formats. 
     139                formatted = False 
    138140                for format in supported_formats: 
    139141                    if use_format(obj.docstring, format): 
    140142                        self.docstrings_by_format[format].append(fullname) 
     143                        formatted = True 
     144                if formatted: 
     145                    self.formatted_docstrings_count += 1 
    141146 
    142147        for method_or_func in self.method_func: 
     
    177182 
    178183    def docstring_count_by_type(self, type): 
    179         """Return number of reST docstrings found in this module 
     184        """Return number of docstrings of given type found in this module 
    180185        """ 
    181186        return len(self.docstrings_by_format[type])