Next / Previous / Contents / Shipman's homepage

16. indexTable(): Build the table of monthly links

For an overview of the structure of the index table, see Section 4.1, “XHTML for the index page”.

# - - -   i n d e x T a b l e

def indexTable ( parent, yearCollection ):
    '''Build the table of yearly rows and monthly link cells.

      [ (parent is an et.Element) and
        (yearCollection is a YearCollection instance) ->
          parent  +:=  the index table made from yearCollection ]

The table element, and everything in it down to but not including the tbody element, are built by Section 17, “indexTableFrame(): Set up the table structure”.

    #-- 1 --
    # [ parent  +:=  a new table element containing column
    #       definitions, column headings, and an empty tbody
    #       element
    #   tbody  :=  that tbody element ]
    tbody  =  indexTableFrame ( parent )

All that remains is to fill in the rows of the table, one per year. The method described in Section 21.4, “YearCollection.genYearsRev(): Generate years in reverse chronological order” generates the years in reverse chronological order as a sequence of YearRow instances; each one results in one row of the table. See Section 18, “buildRow(): Build one row of the index table”.

    #-- 2 -
    # [ tbody  +:=  table rows made from the YearRow instances
    #       in YearCollection, in reverse chronological order ]
    for yearRow in yearCollection.genYearsRev():
        #-- 2 body --
        # [ yearRow is a YearRow instance ->
        #     tbody  +:=  a tr element made from yearRow ]
        buildRow ( tbody, yearRow )