packages feed

diagrams-builder 0.2.1.0 → 0.3

raw patch · 4 files changed

+117/−23 lines, 4 filesdep +diagrams-postscriptdep ~basenew-component:exe:diagrams-builder-psPVP ok

version bump matches the API change (PVP)

Dependencies added: diagrams-postscript

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGES.markdown view
@@ -1,3 +1,9 @@+0.3: 3 Feburary 2013+--------------------+++ new `diagrams-builder-postscript` tool++ miscellaneous improvements to `diagrams-latex.sty`+ 0.2.1.0: 11 December 2012 ------------------------- 
diagrams-builder.cabal view
@@ -1,5 +1,5 @@ name:                diagrams-builder-version:             0.2.1.0+version:             0.3 synopsis:            hint-based build service for the diagrams graphics EDSL.  description:         @diagrams-builder@ provides backend-agnostic tools for@@ -14,23 +14,19 @@                      plugin for @BlogLiterately@) to compile diagrams                      embedded in Markdown-formatted blog posts.                      .-                     Executables specific to the cairo and SVG+                     Executables specific to the cairo, SVG, and postscript                      backends are included (more executables specific                      to other backends may be included in the future).-                     Both take an input file and an expression to-                     render, and outputs an image file.  If you want+                     All take an input file and an expression to+                     render, and output an image file.  If you want                      these executables you must explicitly enable the-                     @-fcairo@ and/or @-fsvg@ flags.+                     @-fcairo@, @-fsvg@, or @-fps@ flags.                      .                      A LaTeX package, @diagrams-latex.sty@, is also                      provided in the @latex/@ directory of the source                      distribution, which renders diagrams code found-                     within @diagram@ environments.  It makes use of-                     the @diagrams-builder-cairo@ executable, so if-                     you want to use @diagrams-latex.sty@ you should-                     install @diagrams-builder@ with the @-fcairo@-                     option.  Note that @diagrams-latex.sty@ is-                     licensed under the GPL.+                     within @diagram@ environments. Note that +                     @diagrams-latex.sty@ is licensed under the GPL. homepage:            http://projects.haskell.org/diagrams license:             BSD3 license-file:        LICENSE@@ -77,6 +73,11 @@   default:     False   manual:      True +flag ps+  description: install postscript-specific builder tool+  default:     False+  manual:      True+ executable diagrams-builder-cairo   main-is:             diagrams-builder-cairo.hs   hs-source-dirs:      src/tools@@ -115,4 +116,23 @@                        diagrams-svg >= 0.6 && < 0.7,                        blaze-svg >= 0.3.3 && < 0.4,                        bytestring >= 0.9.2 && < 0.11,+                       cmdargs >= 0.6 && < 0.11++executable diagrams-builder-ps+  main-is:             diagrams-builder-ps.hs+  hs-source-dirs:      src/tools+  default-language:    Haskell2010+  other-extensions:    DeriveDataTypeable+                       RecordWildCards+  +  if !flag(ps)+    buildable: False++  if flag(ps)+    build-depends:     base >= 4 && < 5,+                       filepath,+                       directory,+                       diagrams-builder,+                       diagrams-lib >= 0.6 && < 0.7,+                       diagrams-postscript >= 0.6 && < 0.7,                        cmdargs >= 0.6 && < 0.11
latex/diagrams-latex.sty view
@@ -83,6 +83,12 @@  \newcommand\setoutputdir[1]{\def\dtt@outputdir{#1}} +% Options for setting backend+\DeclareOptionX{backend}[]{\def\dtt@backend{#1}}+\def\dtt@backend{cairo}  % use cairo as the default backend+\DeclareOptionX{extension}[]{\def\dtt@extension{#1}}+\def\dtt@extension{pdf}  % default output extension of .pdf+ \ExecuteOptionsX{shell}  \ProcessOptionsX\relax@@ -132,7 +138,7 @@         You'll need to compile the diagrams yourself.} \fi \newcounter{dtt@fignum}-\def\dtt@figname{\dtt@outputdir\jobname-diagrams-latex-fig\thedtt@fignum}+\def\dtt@figname{\dtt@outputdir/\jobname-diagrams-latex-fig\thedtt@fignum}   %%%%%%%%%%%%%%%%% diagrams-latex code@@ -150,8 +156,14 @@     \def\dtt@outputdir{#1} } \define@key{dtt}{file}[]{%-    \def\dtt@figname{\dtt@outputdir#1}+    \def\dtt@figname{\dtt@outputdir/#1} }+\define@key{dtt}{backend}[]{%+    \def\dtt@backend{#1}+}+\define@key{dtt}{extension}[]{%+    \def\dtt@extension{#1}+}  \define@key{dtt}{shell}[]{\dtt@ShellEscapetrue} \define@key{dtt}{noshell}[]{\dtt@ShellEscapefalse}@@ -161,7 +173,8 @@ \newwrite\verbatim@out \def\diagramslatexverbatimwrite#1{%     \def\BeforeStream{-        \message{Opening diagrams-latex stream #1}%+        \message{Opening diagrams-latex stream #1+        }%     }%     \@bsphack     \immediate\openout \verbatim@out #1@@ -195,30 +208,31 @@     \ifdtt@ForceShellEscape         \dtt@ShellEscapetrue     \fi-    \xdef\diagramslatexCutFile{\dtt@figname.txt}+    \immediate\write18{mkdir -p \dtt@outputdir}+    \xdef\diagramslatexCutFile{\dtt@figname.hs}     \diagramslatexverbatimwrite{\diagramslatexCutFile}}     {\enddiagramslatexverbatimwrite%     \diagramslatexgraphicsinclude}  \long\gdef\diagramslatexgraphicsprocess{%     \ifdtt@ShellEscape-        \IfFileExists{\dtt@figname.txt}{%-            \immediate\write18{diagrams-builder-cairo -o \dtt@figname.pdf\space+        \IfFileExists{\dtt@figname.hs}{%+            \immediate\write18{diagrams-builder-\dtt@backend\space -o \dtt@figname.\dtt@extension\space                 \dtt@width\space                 \dtt@height\space-                \dtt@figname.txt\space }%-            \IfFileExists{\dtt@figname.pdf}{%-                \PackageInfo{diagrams-latex}{\dtt@figname.txt converted}+                \dtt@figname.hs\space }%+            \IfFileExists{\dtt@figname.\dtt@extension}{%+                \PackageInfo{diagrams-latex}{\dtt@figname.hs converted}             }             {\PackageWarningNoLine{diagrams-latex}-                {Conversion of \dtt@figname.txt failed}}}{}+                {Conversion of \dtt@figname.hs failed}}}{}             \fi }  \long\gdef\diagramslatexgraphicsinclude{\diagramslatexgraphicsprocess%-    \IfFileExists{\dtt@figname.pdf}{{\includegraphics{\dtt@figname.pdf}}}+    \IfFileExists{\dtt@figname.\dtt@extension}{{\includegraphics{\dtt@figname.\dtt@extension}}}     {\PackageWarningNoLine{diagrams-latex}-            {Please convert \dtt@figname.txt manually}}+            {Please convert \dtt@figname.hs manually}} }  \endinput
+ src/tools/diagrams-builder-ps.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE RecordWildCards #-}++module Main where++import System.Directory (createDirectoryIfMissing, copyFile)+import qualified System.FilePath as FP++import System.Console.CmdArgs++import Diagrams.Prelude hiding (width, height)+import Diagrams.Backend.Postscript+import Diagrams.Builder++compileExample :: Build -> IO ()+compileExample (Build{..}) = do+  f   <- readFile srcFile++  createDirectoryIfMissing True dir++  res <- buildDiagram+           Postscript+           zeroV+           (PostscriptOptions outFile (mkSizeSpec width height) EPS)+           [f]+           expr+           []+           [ "Diagrams.Backend.Postscript" ]+           (hashedRegenerate+             (\hash opts -> opts { psfileName = mkFile hash })+             dir+           )++  case res of+    ParseErr err    -> putStrLn ("Parse error in " ++ srcFile) >> putStrLn err+    InterpErr ierr  -> putStrLn ("Error while compiling " ++ srcFile) >>+                       putStrLn (ppInterpError ierr)+    Skipped hash    -> copyFile (mkFile hash) outFile+    OK hash act     -> do act >> copyFile (mkFile hash) outFile+ where+   mkFile base = dir FP.</> base FP.<.> "eps"++build :: Build+build =+  defaultBuildOpts+  { outFile = "out.eps" &= typFile &= help "Output file (default: \"out.eps\")"+  }+  &= summary "The diagrams-builder-ps program, for dynamically rendering diagrams using the native postscript backend.  Give it a source file and an expression to render (which may refer to things declared in the source file), and it outputs an image, using hashing to avoid rerendering images unnecessarily."+  &= program "diagrams-builder-ps"++main :: IO ()+main = do+  opts <- cmdArgs build+  compileExample opts