From f131e49033be01a131234ea12a0864d6e719a520 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 14 Jun 2014 21:40:34 -0400 Subject: [PATCH] Add some docs for AutoRacingResults, and fix others. --- src/TSN/Picklers.hs | 25 +++++++++++++++---------- src/TSN/XML/AutoRacingResults.hs | 25 +++++++++++++++++++++---- src/TSN/XML/AutoRacingSchedule.hs | 3 +-- src/TSN/XML/GameInfo.hs | 2 +- src/TSN/XML/Scores.hs | 10 ++++++---- src/TSN/XML/SportInfo.hs | 2 +- 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/TSN/Picklers.hs b/src/TSN/Picklers.hs index bc13bad..be4caa6 100644 --- a/src/TSN/Picklers.hs +++ b/src/TSN/Picklers.hs @@ -35,8 +35,9 @@ import TSN.Parse ( -- | The format string for a base date in m/d/yyyy format. The -- day/month are not padded at all. This will match for example, -- --- * 2/15/1983 --- * 1/1/0000 +-- * 2\/15\/1983 +-- +-- * 1\/1\/0000 -- date_format :: String date_format = "%-m/%-d/%Y" @@ -46,8 +47,9 @@ date_format = "%-m/%-d/%Y" -- day/month are padded to two characters with zeros. This will -- match for example, -- --- * 02/15/1983 --- * 01/01/0000 +-- * 02\/15\/1983 +-- +-- * 01\/01\/0000 -- date_format_padded :: String date_format_padded = "%0m/%0d/%Y" @@ -108,9 +110,11 @@ format_commas x = -- | Parse \ from an 'AutoRaceResultsListing'. These are -- essentially 'Int's, but they look like, -- --- * 336,826 --- * 1,000,191 --- * TBA +-- * \336,826\ +-- +-- * \1,000,191\ +-- +-- * \TBA\ -- xp_earnings :: PU (Maybe Int) xp_earnings = @@ -132,10 +136,11 @@ xp_earnings = -- | (Un)pickle a 'UTCTime' from a \ element in an -- 'AutoRaceResults' message. -- --- Example: +-- Examples: +-- +-- * \6/1/2014 1:00:00 PM\ -- --- 6/1/2014 1:00:00 PM --- 5/24/2014 2:45:00 PM +-- * \5/24/2014 2:45:00 PM\ -- xp_racedate :: PU UTCTime xp_racedate = diff --git a/src/TSN/XML/AutoRacingResults.hs b/src/TSN/XML/AutoRacingResults.hs index 596b0bd..96433ee 100644 --- a/src/TSN/XML/AutoRacingResults.hs +++ b/src/TSN/XML/AutoRacingResults.hs @@ -82,7 +82,9 @@ dtd = "AutoRacingResultsXML.dtd" -- * AutoRacingResults/Message --- | Database representation of a 'Message'. +-- | Database representation of a 'Message'. Comparatively, it lacks +-- the listings and race information since they are linked via a +-- foreign key. -- data AutoRacingResults = AutoRacingResults { @@ -101,7 +103,9 @@ data AutoRacingResults = --- | XML Representation of an 'AutoRacingResults'. +-- | XML Representation of an 'AutoRacingResults'. It has the same +-- fields, but in addition contains the 'xml_listings' and +-- 'xml_race_information'. -- data Message = Message { @@ -177,6 +181,7 @@ data AutoRacingResultsListing = db_nc :: Maybe Bool, db_earnings :: Maybe Int } + -- | XML representation of a \ contained within a -- \. -- @@ -204,6 +209,7 @@ instance ToDb AutoRacingResultsListingXml where -- type Db AutoRacingResultsListingXml = AutoRacingResultsListing + instance FromXmlFk AutoRacingResultsListingXml where -- | Each 'AutoRacingResultsListingXml' is contained in (i.e. has a -- foreign key to) a 'AutoRacingResults'. @@ -396,8 +402,10 @@ mkPersist tsn_codegen_config [groundhog| onDelete: cascade - name: db_most_laps_leading embeddedType: - - {name: most_laps_leading_driver_id, dbName: most_laps_leading_driver_id} - - {name: most_laps_leading_driver, dbName: most_laps_leading_driver} + - {name: most_laps_leading_driver_id, + dbName: most_laps_leading_driver_id} + - {name: most_laps_leading_driver, + dbName: most_laps_leading_driver} - embedded: MostLapsLeading fields: @@ -414,6 +422,8 @@ mkPersist tsn_codegen_config [groundhog| --- Pickling --- +-- | Pickler for the \s contained within \s. +-- pickle_listing :: PU AutoRacingResultsListingXml pickle_listing = xpElem "Listing" $ @@ -449,6 +459,7 @@ pickle_listing = -- | Pickler for the top-level 'Message'. +-- pickle_message :: PU Message pickle_message = xpElem "message" $ @@ -483,6 +494,9 @@ pickle_message = xml_time_stamp m) +-- | Pickler for the \ child of a +-- \. +-- pickle_most_laps_leading :: PU MostLapsLeading pickle_most_laps_leading = xpElem "Most_Laps_Leading" $ @@ -496,6 +510,9 @@ pickle_most_laps_leading = db_most_laps_leading_driver m, db_most_laps_leading_number_of_laps m) + +-- | Pickler for the \ child of \. +-- pickle_race_information :: PU AutoRacingResultsRaceInformationXml pickle_race_information = xpElem "Race_Information" $ diff --git a/src/TSN/XML/AutoRacingSchedule.hs b/src/TSN/XML/AutoRacingSchedule.hs index 1f45986..5a0344c 100644 --- a/src/TSN/XML/AutoRacingSchedule.hs +++ b/src/TSN/XML/AutoRacingSchedule.hs @@ -244,8 +244,7 @@ newtype AutoRacingScheduleListingRaceResult = deriving (Eq, Show) --- * AutoRacingScheduleListingRaceResultRaceResultListing / --- AutoRacingScheduleListingRaceResultRaceResultListingXml +-- * AutoRacingScheduleListingRaceResultRaceResultListing / AutoRacingScheduleListingRaceResultRaceResultListingXml -- -- Sorry about the names yo. -- diff --git a/src/TSN/XML/GameInfo.hs b/src/TSN/XML/GameInfo.hs index 43c7cca..421d286 100644 --- a/src/TSN/XML/GameInfo.hs +++ b/src/TSN/XML/GameInfo.hs @@ -54,7 +54,7 @@ import Xml ( unsafe_read_document ) --- | The DTDs for everything that we consider "Game Info." +-- | The DTDs for everything that we consider \"Game Info.\" -- -- TODO: This is the list from the old implementation. We need to -- make sure that we are really receiving XML for these DTDs diff --git a/src/TSN/XML/Scores.hs b/src/TSN/XML/Scores.hs index 571f6b3..ef2330c 100644 --- a/src/TSN/XML/Scores.hs +++ b/src/TSN/XML/Scores.hs @@ -253,13 +253,15 @@ newtype ScoreGameHTeam = -- * ScoreGame_ScoreGameTeam -- | Join a 'ScoreGame' with its home/away teams. Database-only. We --- use a join table because the teams are kept unique. +-- use a join table because the teams are kept unique. The first +-- argument is the game id, the second argument is the visiting team +-- (vteam) id, and the last argument is the home team (hteam) id. -- data ScoreGame_ScoreGameTeam = ScoreGame_ScoreGameTeam - (DefaultKey ScoreGame) -- ^ game id - (DefaultKey ScoreGameTeam) -- ^ vteam id - (DefaultKey ScoreGameTeam) -- ^ hteam id + (DefaultKey ScoreGame) -- game id + (DefaultKey ScoreGameTeam) -- vteam id + (DefaultKey ScoreGameTeam) -- hteam id -- * ScoreLocation diff --git a/src/TSN/XML/SportInfo.hs b/src/TSN/XML/SportInfo.hs index 6dc1bbb..d47f1c1 100644 --- a/src/TSN/XML/SportInfo.hs +++ b/src/TSN/XML/SportInfo.hs @@ -58,7 +58,7 @@ import Xml ( unsafe_read_document ) --- | The DTDs for everything that we consider "Sport Info." +-- | The DTDs for everything that we consider \"Sport Info.\" -- -- TODO: This is the list from the old implementation. We need to -- make sure that we are really receiving XML for these DTDs -- 2.43.2