lentil 1.2.0.0 → 1.2.1.0
raw patch · 9 files changed
+37/−26 lines, 9 files
Files
- changes.txt +6/−0
- lentil.cabal +1/−1
- src/Lentil/Helpers.hs +6/−5
- src/Lentil/Parse/Issue.hs +9/−8
- src/Lentil/Parse/Run.hs +5/−6
- src/Lentil/Parse/Source.hs +2/−4
- src/Main.hs +1/−1
- test/Lentil/HelpersSpec.hs +1/−1
- test/Lentil/Parse/IssueSpec.hs +6/−0
changes.txt view
@@ -1,3 +1,9 @@+1.2.1.0+-------++- Released Sat 11 May 2019 04:54:36 CEST+- Fixed mixed incipit (TODO/FIXME) bug.+ 1.2.0.0 -------
lentil.cabal view
@@ -1,5 +1,5 @@ name: lentil-version: 1.2.0.0+version: 1.2.1.0 synopsis: frugal issue tracker description: minumum effort, cohesive issue tracker based on ubiquitous @TODO@s and @FIXME@s conventions.
src/Lentil/Helpers.hs view
@@ -15,9 +15,10 @@ import qualified Text.Megaparsec as P import qualified Text.Megaparsec.Char as PC import qualified Control.Monad.State as S+import qualified Data.Void as V -type StateParser i s a = P.ParsecT String i (S.State s) a+type StateParser s a = P.ParsecT V.Void String (S.State s) a -- output errors (to stderr) perr :: String -> IO ()@@ -33,9 +34,9 @@ -- PARSING -- ------------- -type StateParserError i = P.ParseErrorBundle i String-runStateParser :: StateParser i s a -> s -> FilePath -> i ->- Either (StateParserError i) a+type StateParserError = P.ParseErrorBundle String V.Void+runStateParser :: StateParser s a -> s -> FilePath -> String ->+ Either StateParserError a runStateParser p s fp i = let eps = P.runParserT p fp i@@ -46,7 +47,7 @@ aliasp :: String -> Maybe Alias aliasp s = either (const Nothing) Just (runStateParser p () "" s) where- p :: StateParser String s (String, String)+ p :: StateParser s (String, String) p = P.someTill P.anySingle (PC.string aliasSign) >>= \a -> P.many P.anySingle >>= \b -> return ('.':a, '.':b)
src/Lentil/Parse/Issue.hs view
@@ -24,7 +24,7 @@ -- TYPES -- ----------- -type ParIssue a = StateParser String [FlagWord] a+type ParIssue a = StateParser [FlagWord] a -- standard flagwords stdFlagwords :: [FlagWord]@@ -91,7 +91,7 @@ optional (char ':') >> notFollowedBy nonSpace >> -- real todo, not todoodle return (normaliseFlagword fw)- <?> "incipit"+ <?> "incipit" where fwpar = flagWords >>= \fw -> choice (map (try . ciString) fw)@@ -100,7 +100,7 @@ -- issues (bar the first one) should only appear at beginning of line incipitv :: ParIssue FlagWord-incipitv = char '\n' *> space *> incipit+incipitv = eol *> space *> incipit <?> "incipit stopper" ------------@@ -149,7 +149,6 @@ -- parses a number of issues from a given line-of-text-data IF = I Issue | FT issues :: ParIssue [Issue] issues = space *> -- first issue can have preceding ws (M.catMaybes <$> ifs)@@ -157,11 +156,13 @@ where -- unissue text -- remember to consume what you find before a will-formed incipit- t :: ParIssue ()+ t :: ParIssue (Maybe Issue) t = try (manyTill anySingle (lookAhead $ try incipitv)) *>- char '\n' *> space+ char '\n' *> space *> pure Nothing + i :: ParIssue (Maybe Issue)+ i = Just <$> try issue+ ifs :: ParIssue [Maybe Issue]- ifs = many (Just <$> issue <|>- Nothing <$ t)+ ifs = many (i <|> t)
src/Lentil/Parse/Run.hs view
@@ -117,14 +117,13 @@ -- generic parsing -- -runParPipe :: (Show i, Show (Token i)) =>- StateParser i s o ->- FilePath -> s -> i ->+runParPipe :: StateParser s o ->+ FilePath -> s -> String -> Pipe ip o IO () runParPipe p fp s i = case runStateParser p s fp i of Left l -> liftIO (perr $ fp ++ " : parse error " ++- show l)+ errorBundlePretty l) Right r -> yield r -- issue parsing --@@ -133,8 +132,8 @@ setRow :: Row -> ParIssue () setRow r = updateParserState (\(State i o (PosState pix po (SourcePos n _ cx) tw lp)) ->- let l' = mkPos $ r in- (State i o (PosState pix po (SourcePos n l' cx) tw lp)))+ let l' = mkPos r in+ State i o (PosState pix po (SourcePos n l' cx) tw lp)) safeRead :: FilePath -> IO String safeRead fp = E.try (TI.readFile fp) >>= \case
src/Lentil/Parse/Source.hs view
@@ -26,7 +26,7 @@ ----------- -- from source to comment strings-type ParSource a = StateParser String () a+type ParSource a = StateParser () a data ParSyntax = -- 'standard' language (with single line and/or multiline -- markers, etc.@@ -189,10 +189,8 @@ rstTodoIncipit = fmap (unPos . sourceColumn) getSourcePos >>= \c -> if c == 1 then () <$ string ".. todo::"- else parserFail "rst todo incipit: not at begin-of-line"+ else fail "rst todo incipit: not at begin-of-line" <?> "rst todo incipit"- where- parserFail s = customFailure s --------------------- -- ORG-MODE SYNTAX --
src/Main.hs view
@@ -32,7 +32,7 @@ short 'v' S.<> help "show version and copyright info" ) where- versionCopy = "\nlentil - frugal issue tracker, version 1.2.0.0\n\+ versionCopy = "\nlentil - frugal issue tracker, version 1.2.1.0\n\ \(C) 2015-2019 Francesco Ariis - http://www.ariis.it\n\ \released under the GNU General Public License v3\n"
test/Lentil/HelpersSpec.hs view
@@ -12,7 +12,7 @@ -- Parsing tests -- simple parser (choosable if we are at begin of line or else)-sp :: StateParser String () a -> String -> Maybe a+sp :: StateParser () a -> String -> Maybe a sp p cs = either (const Nothing) Just (runStateParser p () fp cs) where fp = "<f>"
test/Lentil/Parse/IssueSpec.hs view
@@ -152,6 +152,9 @@ it "does parse tags before description" $ sp [] issue "todo [alfa] beta\n" `shouldBe` (Just $ Issue "<f>" 1 (Just "beta") [Tag "alfa"])+ it "works without newline too" $+ sp [] issue "fixme "+ `shouldBe` (Just $ Issue "<f>" 1 Nothing [Tag "fixme"]) describe "issues" $ do it "parses multiple issues" $@@ -175,4 +178,7 @@ Issue "<f>" 2 (Just "hey") [Tag "t"]] it "doesn't pick issues in the middle of a sentence" $ sp [] issues "\nthis is not a todo as you can see" `shouldBe` Just []+ it "does not choke on quasi-incipit" $+ sp [] issues "TODO/HACK, we \n TODO this is it\n"+ `shouldBe` Just [Issue "<f>" 2 (Just "this is it") []]