parameters: (self)
return_statement: return contents
docstring: Returns the `contents` dictionary with each node annotated with section lengths info
          from version_state.
docstring_summary: Returns the `contents` dictionary with each node annotated with section lengths info
          from version_state.
docstring_tokens: Returns the contents dictionary with each node annotated with section lengths info from version_state .
function: def contents_with_content_counts(self):
          """
          Returns the `contents` dictionary with each node annotated with section lengths info
          from version_state.
          """
          contents = self.contents(v2=True)
          vstate   = self.versionState()
  
          def simplify_version_state(vstate_node):
              return aggregate_available_texts(vstate_node["_all"]["availableTexts"])
  
          def aggregate_available_texts(available):
              """Returns a jagged arrary of ints that counts the number of segments in each section,
              (by throwing out the number of versions of each segment)"""
              if len(available) == 0 or type(available[0]) is int:
                  return len(available)
              else:
                  return [aggregate_available_texts(x) for x in available]
  
          def annotate_schema(schema, vstate):
              if "nodes" in schema:
                  for node in schema["nodes"]:
                      if "key" in node:
                          annotate_schema(node, vstate[node["key"]])
              else:
                  schema["content_counts"] = simplify_version_state(vstate)
  
          annotate_schema(contents["schema"], vstate.content)
          return contents
function_tokens: def contents_with_content_counts ( self ) : contents = self . contents ( v2 = True ) vstate = self . versionState ( ) def simplify_version_state ( vstate_node ) : return aggregate_available_texts ( vstate_node [ "_all" ] [ "availableTexts" ] ) def aggregate_available_texts ( available ) : """Returns a jagged arrary of ints that counts the number of segments in each section,
              (by throwing out the number of versions of each segment)""" if len ( available ) == 0 or type ( available [ 0 ] ) is int : return len ( available ) else : return [ aggregate_available_texts ( x ) for x in available ] def annotate_schema ( schema , vstate ) : if "nodes" in schema : for node in schema [ "nodes" ] : if "key" in node : annotate_schema ( node , vstate [ node [ "key" ] ] ) else : schema [ "content_counts" ] = simplify_version_state ( vstate ) annotate_schema ( contents [ "schema" ] , vstate . content ) return contents