Commits

John Lenz committed f232af0

Several comment/haddock updates

Comments (0)

Files changed (4)

src/Text/LatexCandle/Options.hs

 import Control.Monad.Reader
 import System.Console.GetOpt
 
+-- | Process command line arguments, returning either an error or the options
+processArguments :: [String] -> Options -> Either String Options
+processArguments s o = case getOpt Permute getargOptions s of
+     (actions, [], []) -> Right $ foldl (flip (.)) id actions o
+     (_,_,err@(_:_))   -> Left $ concat err
+     (_,args,[])       -> Left $ "Extra arguments " ++ show args
+
+-- | Run a parser only if the given option is true.
+testOpt :: MonadReader Options m => (Options -> Bool) -> m () -> m ()
+testOpt f a = asks f >>= flip when a
+
 data Options = Options {
   -- OPTIONS START
 
       "The document starts with documentclass"
   ]
 
--- | Process command line arguments, returning either an error or the options
-processArguments :: [String] -> Options -> Either String Options
-processArguments s o = case getOpt Permute getargOptions s of
-     (actions, [], []) -> Right $ foldl (flip (.)) id actions o
-     (_,_,err@(_:_))   -> Left $ concat err
-     (_,args,[])       -> Left $ "Extra arguments " ++ show args
-
--- | Run a parser only if the given option is true.
-testOpt :: MonadReader Options m => (Options -> Bool) -> m () -> m ()
-testOpt f a = asks f >>= flip when a

src/Text/LatexCandle/Parser/Base.hs

                <|> void (char '%' >> manyTill anyChar newline))
 
 
--- | A parser which looks for something (usually end brace or bracket).  If it
--- is found on the current line, this parser consumes up to and including it
--- and logs a warning if there is text in the way using the provided message.
--- If the character is not found, the parser fails.
+-- | A parser which looks for something (usually end brace or bracket).
+--
+-- If it is found on the current line, this parser consumes up to and including
+-- it and logs a warning if there is text in the way using the provided
+-- message.  If the character is not found either at the current location or in
+-- the same line, the parser fails.
 lookFor :: LatexP () -- ^ what to look for
         -> String    -- ^ message if it is found on the current line
         -> LatexP ()

src/Text/LatexCandle/Parser/Commands.hs

 -- arguments together with a range representing the argument.  The parser will
 -- log an error if the close bracket is not found after a string of letters,
 -- digits, commas, and whitespace.  In this situation, the parser will still
--- accept and continue like there was a closing bracket.
+-- accept and continue like there was a closing bracket (see 'lookFor')
 optionalArgument :: LatexP [(Range,String)]
 optionalArgument = argList <|> return []
 
 -- * The given parser is used to parse the interior of the command.
 -- * Once the inner parser stops parsing, a closing brace is expected.
 --   If it is missing, the parser still succeeds, logs an error,
---   and continues assuming there existed a closing brace.
+--   and continues assuming there existed a closing brace (see 'lookFor')
 requiredArgumentInBrace :: LatexP a -> LatexP a
 requiredArgumentInBrace inner = do
     start <- mark

src/Text/LatexCandle/Parser/Header.hs

 checkValidClass _ _ _ = return ()
 
 -- | Check the header: everything between documentclass and \begin{document}
--- Currently this does no checking.
+-- Currently this does no checking and just skips until \begin{document}
 header :: LatexP ()
 header = void $ manyTill (anyChar >> whitespace) $ try (lookAhead $ string_ "\\begin{document}") <|> eof