Next / Previous / Contents / Shipman's homepage

23.6. MonthCell.__pageTOC(): Generate page table of contents

This method generates the table of contents for one monthly page. For the XHTML generated, see Section 4.2, “XHTML for the month page”.

noteweb
# - - -   M o n t h C e l l . _ _ p a g e T O C

    def __pageTOC ( self, parent ):
        '''Generate the monthly page's table of contents.

          [ parent is an et.Element ->
              parent  +:=  a 'ul' containing the page table
                           of contents
              return a dictionary whose keys are the DayNotes
              instances in self.birdNoteSet, and each
              corresponding value is the anchor name used for
              that instance in the generated TOC ]
        '''

At the top level, a ul (bullet list) wraps the table of contents. Also, create the anchorSet and anchorMap structures discussed under Section 23.5, “MonthCell.__renderPage(): Add the notes content”.

noteweb
        #-- 1 --
        # [ parent  :=  parent with a new 'ul' child element added
        #   ul  :=  that child
        #   anchorSet  :=  a new, empty set
        #   anchorMap  :=  a new, empty dictionary ]
        ul  =  et.SubElement ( parent, 'ul' )
        anchorSet  =  set()
        anchorMap  =  {}

For the logic that generates each TOC entry, see Section 23.7, “MonthCell.__dayTOC(): Month table of contents entry for one day”.

noteweb
        #-- 2 --
        # [ ul  +:=  'li' elements representing the days in
        #            self.birdNoteSet
        #   anchorSet  +:=  anchors used in the table of contents
        #   anchorMap  +:=  entries mapping the DayNotes
        #       instances in self.birdNoteSet onto the corresponding
        #       anchors ]
        for dayNotes in self.birdNoteSet.genDays():
            #-- 2 body --
            # [ ul  +:=  an 'li' element representing dayNotes ]
            self.__dayTOC ( ul, dayNotes, anchorSet, anchorMap )

The finished anchorMap is returned to the caller.

noteweb
        #-- 3 --
        return anchorMap