packages feed

master-plan 0.2.0.0 → 0.3.0

raw patch · 5 files changed

+69/−13 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ MasterPlan.Backend.Graph: renderText :: FilePath -> RenderOptions -> [String] -> IO ()

Files

+ CHANGELOG.md view
@@ -0,0 +1,24 @@+# Changelog++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)+and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).++## [Unreleased]++## [0.3.0] - 2017-08-17++New option flag: `--render-parse-error` which will render the image with the+parsing error text, instead of printing to standard output. Also, the exit code+will be normal.++## [0.2.0] - 2017-08-15++Changed completely the language syntax. This change breaks compatibility with+all existing `.plan` file, but I'm releasing as a minor version because this+project's API is still experimental (under version 1.x.x).++## [0.1.0] - 2017-08-13++Initial release.
README.md view
@@ -48,10 +48,10 @@ ``` master-plan - project management tool for hackers -Usage: master-plan  [FILENAME] [-o|--output FILENAME] [--progress-below N]-                    [-c|--color] [-w|--width NUMBER] [--height NUMBER]-                    [-r|--root NAME]-                    [--hide title|description|url|owner|cost|trust|progress]+Usage: master-plan [FILENAME] [-o|--output FILENAME] [--progress-below N]+                   [--render-parse-error] [-c|--color] [-w|--width NUMBER]+                   [--height NUMBER] [-r|--root NAME]+                   [--hide title|description|url|owner|cost|trust|progress]   See documentation on how to write project plan files  Available options:@@ -59,6 +59,8 @@   -o,--output FILENAME     output file name (.png, .tif, .bmp, .jpg and .pdf                            supported)   --progress-below N       only display projects which progress is < N%+  --render-parse-error     instead of printing parsing errors, render as an+                           image   -c,--color               color each project by progress   -w,--width NUMBER        width of the output image   --height NUMBER          height of the output image
app/Main.hs view
@@ -24,10 +24,11 @@ import           System.IO                (stdin)  -- |Type output from the command line parser-data Opts = Opts { inputPath     :: Maybe FilePath-                 , outputPath    :: Maybe FilePath-                 , projFilter    :: ProjFilter -- ^ filter to consider-                 , renderOptions :: RenderOptions }+data Opts = Opts { inputPath          :: Maybe FilePath+                 , outputPath         :: Maybe FilePath+                 , projFilter         :: ProjFilter -- ^ filter to consider+                 , renderParsingError :: Bool -- ^ will render the parsing error instead of printing+                 , renderOptions      :: RenderOptions }   deriving (Show)  newtype ProjFilter = ProjFilter (ProjectSystem → ProjectExpr → Bool)@@ -50,6 +51,8 @@                                          <> help "output file name (.png, .tif, .bmp, .jpg and .pdf supported)"                                          <> metavar "FILENAME" ))                  <*> (filterParser <|> pure noFilter)+                 <*> switch ( long "render-parse-error"+                            <> help "instead of printing parsing errors, render as an image")                  <*> renderOptionsParser   where     renderOptionsParser ∷ Parser RenderOptions@@ -111,10 +114,12 @@ masterPlan ∷ Opts → IO () masterPlan opts =     do contents <- maybe (TIO.hGetContents stdin) TIO.readFile $ inputPath opts+       let outfile = fromMaybe (fromMaybe "output" (outputPath opts) ++ ".pdf") $ outputPath opts        case P.runParser (fromMaybe "stdin" $ inputPath opts) contents of-          Left e    -> die e+          Left e    -> if renderParsingError opts+                        then renderText outfile (renderOptions opts) (lines e)+                        else die e           Right sys@(ProjectSystem b) ->             do let sys' = prioritizeSys $ ProjectSystem $ M.mapMaybe                                                     (filterBinding sys $ projFilter opts) b-               let outfile = fromMaybe (fromMaybe "output" (outputPath opts) ++ ".pdf") $ outputPath opts                render outfile (renderOptions opts) sys'
master-plan.cabal view
@@ -1,5 +1,5 @@ name:                master-plan-version:             0.2.0.0+version:             0.3.0 synopsis:            The project management tool for hackers description:         Master Plan is a tool that parses files that describes                      projects using a simple and powerful syntax in which@@ -23,6 +23,7 @@ build-type:          Simple cabal-version:       >=1.10 extra-source-files:  README.md+                   , CHANGELOG.md  source-repository head   type:     git@@ -50,7 +51,7 @@                        , diagrams                        , diagrams-lib                        , diagrams-rasterific-                       , megaparsec+                       , megaparsec >= 6.0.0                        , mtl                        , text                        , syb
src/MasterPlan/Backend/Graph.hs view
@@ -12,7 +12,9 @@ {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE TypeFamilies              #-} {-# LANGUAGE UnicodeSyntax             #-}-module MasterPlan.Backend.Graph (render, RenderOptions(..)) where+module MasterPlan.Backend.Graph ( render+                                , renderText+                                , RenderOptions(..)) where  import           Control.Applicative         ((<|>)) import           Control.Monad.State@@ -36,6 +38,22 @@ rightText :: (TypeableFloat n, Renderable (Text n) b) => String -> QDiagram b V2 n Any rightText = alignedText 1 0.5 +-- |Render multiline text+multilineText' :: (TypeableFloat n, Renderable (Text n) b)+               => FontSlant+               -> FontWeight+               -> n -- ^line spacing+               -> [String] -- ^the lines of text to render+               -> QDiagram b V2 n Any+multilineText' fs fw lineSpace = vsep lineSpace . map (texterific' fs fw)++-- |Render multiline text+multilineText :: (TypeableFloat n, Renderable (Text n) b)+              => n -- ^line spacing+              -> [String] -- ^the lines of text to render+              -> QDiagram b V2 n Any+multilineText = multilineText' FontSlantNormal FontWeightNormal+ -- |Render text with possible overflow by breaking lines and truncating with ... textOverflow' :: (TypeableFloat n, Renderable (Text n) b)               => FontSlant@@ -136,6 +154,12 @@ render fp (RenderOptions colorByP w h rootK props) sys =   let noRootEroor = texterific $ "no project named \"" ++ getProjectKey rootK ++ "\" found."       dia = fromMaybe noRootEroor $ renderTree colorByP props <$> evalState (toRenderModel sys rootK) []+  in renderRasterific fp (dims2D (fromInteger w) (fromInteger h)) $ bgFrame 1 white $ centerXY dia++-- |Render a multi-line text to file+renderText ∷ FilePath -> RenderOptions-> [String] → IO ()+renderText fp RenderOptions { renderWidth=w, renderHeight=h } ss =+  let dia = multilineText (0.1 :: Float) ss   in renderRasterific fp (dims2D (fromInteger w) (fromInteger h)) $ bgFrame 1 white $ centerXY dia  renderTree :: Bool -> [ProjAttribute] -> RenderModel -> QDiagram B V2 Double Any