From 5e5408422bd2a69c7bd9f8e1414bb9eb29497a3b Mon Sep 17 00:00:00 2001 From: hasufell Date: Wed, 1 Oct 2014 23:02:43 +0200 Subject: [PATCH] Improve haddock documentation --- Diagram.hs | 1 + Gtk.hs | 7 +++++++ Util.hs | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Diagram.hs b/Diagram.hs index 60a6fd1..4ee6c33 100644 --- a/Diagram.hs +++ b/Diagram.hs @@ -6,6 +6,7 @@ import Meshparser import Util +-- |Holds the properties for a Diagram, like thickness of 2d points etc. data DiagProp = MkProp { -- |Get the thickness of the dot. getThickness :: Double diff --git a/Gtk.hs b/Gtk.hs index ef73970..ee7b5d1 100644 --- a/Gtk.hs +++ b/Gtk.hs @@ -10,6 +10,7 @@ import Graphics.UI.Gtk.Windows.MessageDialog import System.Directory +-- |Handle the whole GTK gui. startGUI :: FilePath -> IO () startGUI startFile = do homedir <- getHomeDirectory @@ -84,6 +85,7 @@ startGUI startFile = do mainGUI +-- |Callback when the "Draw" Button is clicked. onClickedDrawButton :: (WidgetClass widget, RangeClass scale) => FileChooserButton -> widget @@ -98,6 +100,7 @@ onClickedDrawButton fcb da scale' = do showErrorDialog "No valid Mesh file!" +-- |Callback when the "Save" Button is clicked. onClickedSaveButton :: FileChooserButton -> IO () onClickedSaveButton fcb = do @@ -109,6 +112,7 @@ onClickedSaveButton fcb = do showErrorDialog "No valid Mesh file!" +-- |Pops up an error Dialog with the given String. showErrorDialog :: String -> IO () showErrorDialog str = do errorDialog <- messageDialogNew Nothing @@ -120,6 +124,8 @@ showErrorDialog str = do widgetDestroy errorDialog +-- |Draws a Diagram which is built from a given file to +-- the gtk DrawingArea. drawDiag' :: (WidgetClass widget, RangeClass scale) => FilePath -> widget @@ -136,6 +142,7 @@ drawDiag' fp da scale' = do renderWithDrawable dw r +-- |Saves a Diagram which is built from a given file as an SVG. saveDiag' :: FilePath -> IO () saveDiag' fp = do mesh <- readFile fp diff --git a/Util.hs b/Util.hs index 4ffe212..90bd88d 100644 --- a/Util.hs +++ b/Util.hs @@ -11,11 +11,13 @@ inRange min' max' (x, y) | otherwise = False +-- |Compare the extension of a file with the given String. cmpExt :: String -> FilePath -> Bool cmpExt _ [] = False cmpExt ext fp = ext == getExt fp +-- |Get the extension of a file. getExt :: FilePath -> String getExt = last . splitBy (== '.') . @@ -23,7 +25,10 @@ getExt = last . splitBy (== '/') -splitBy :: (a -> Bool) -> [a] -> [[a]] +-- |Split an array into subarrays depending on a given condition. +splitBy :: (a -> Bool) -- ^ condition + -> [a] -- ^ array to split + -> [[a]] -- ^ splitted array splitBy f s = case dropWhile f s of [] -> [] s' -> w : splitBy f s''