diagrams / diagrams-haddock

Preprocessor for including inline diagrams in Haddock documentation
Other
10 stars 4 forks source link

Cabal mis-match puzzle #29

Closed idontgetoutmuch closed 8 years ago

idontgetoutmuch commented 8 years ago
modified   diagrams-haddock.cabal
@@ -68,7 +68,7 @@ Executable diagrams-haddock
                        filepath,
                        diagrams-haddock,
                        cmdargs >= 0.8 && < 0.11,
-                       Cabal >= 1.14 && < 1.25,
+                       Cabal == 1.25.0.0,
                        cpphs >= 1.15
   hs-source-dirs:      tools
   default-language:    Haskell2010
@@ -78,7 +78,7 @@ Test-suite diagrams-haddock-tests
   main-is:             Tests.hs
   build-depends:       base,
                        containers >= 0.4 && < 0.6,
-                       QuickCheck >= 2.4 && < 2.9,
+                       QuickCheck >= 2.4 && < 2.10,
                        tasty >= 0.8 && < 0.12,
                        tasty-quickcheck >= 0.8 && < 0.9,
                        parsec >= 3,

And also

~/Dropbox/Private/Libraries/Kalman $ ../diagrams-haddock/dist/build/diagrams-haddock/diagrams-haddock
diagrams-haddock: No appropriate setup-config found in ./dist
Either it does not exist or it is in the wrong format.
* You may need to run 'cabal configure' first.
* Make sure that the version of Cabal used to compile
  diagrams-haddock (1.25.0.0) matches the version used
  by the cabal tool.
* Use the -d option if you want diagrams-haddock to look in
  a different dist directory.

But

~/Dropbox/Private/Libraries/Kalman $ cabal --version
cabal-install version 1.25.0.0
compiled using version 1.25.0.0 of the Cabal library

Also if I try to create a diagram from one source file

~/Dropbox/Private/Libraries/Kalman $ ../diagrams-haddock/dist/build/diagrams-haddock/diagrams-haddock src/Numeric/Kalman.hs 
~/Dropbox/Private/Libraries/Kalman $

AFAICS no output is produced.

Here's the haddock that I hoped would produce a diagram

-- <<diagrams/src_Numeric_Kalman_diag.svg#diag=diag&height=600&width=500>>
--
-- > import Graphics.Rendering.Chart
-- > import Data.Colour
-- > import Data.Colour.Names
-- > import Data.Default.Class
-- > import Graphics.Rendering.Chart.Backend.Cairo
-- > import Control.Lens
-- >
-- > setLinesBlue :: PlotLines a b -> PlotLines a b
-- > setLinesBlue = plot_lines_style  . line_color .~ opaque blue
-- >
-- > chart = toRenderable layout
-- >   where
-- >     am :: Double -> Double
-- >     am x = (sin (x*3.14159/45) + 1) / 2 * (sin (x*3.14159/5))
-- >
-- >     sinusoid1 = plot_lines_values .~ [[ (x,(am x)) | x <- [0,(0.5)..400]]]
-- >               $ plot_lines_style  . line_color .~ opaque blue
-- >               $ plot_lines_title .~ "am"
-- >               $ def
-- >
-- >     sinusoid2 = plot_points_style .~ filledCircles 2 (opaque red)
-- >               $ plot_points_values .~ [ (x,(am x)) | x <- [0,7..400]]
-- >               $ plot_points_title .~ "am points"
-- >               $ def
-- >
-- >     layout = layout_title .~ "Amplitude Modulation"
-- >            $ layout_plots .~ [toPlot sinusoid1,
-- >                               toPlot sinusoid2]
-- >            $ def
-- >
-- > diag = do
-- >   denv <- defaultEnv vectorAlignmentFns 600 500
-- >   return $ fst $ runBackend denv (render chart (600, 500))
--
module Numeric.Kalman
...
idontgetoutmuch commented 8 years ago

I have removed Cabal 1.25 and installed 1.24

~/Dropbox/Private/Libraries/Kalman $ /Users/dom/Library/Haskell/ghc-8.0.1/lib/cabal-install-1.24.0.0/bin/cabal --version
cabal-install version 1.24.0.0
compiled using version 1.24.0.0 of the Cabal library 

I no longer get an error but neither do I get any output :(

~/Dropbox/Private/Libraries/Kalman $ /Users/dom/Library/Haskell/ghc-8.0.1/lib/diagrams-haddock-0.3.0.11/bin/diagrams-haddock 
~/Dropbox/Private/Libraries/Kalman $ 
byorgey commented 8 years ago

I think the Cabal version mismatch is a red herring. Cabal versions can definitely be a problem with diagrams-haddock, but if that were the problem you would get error messages about mismatched versions, instead of simply getting no output.

I think the real problem is in the line

-- <<diagrams/src_Numeric_Kalman_diag.svg#diag=diag&height=600&width=500>>

You have ...#diag=diag but you cannot abbreviate the diag on the LHS like that. So diagrams-haddock simply ignores this line since it does not parse. Instead you should write

-- <<diagrams/src_Numeric_Kalman_diag.svg#diagram=diag&height=600&width=500>>

does that work?

idontgetoutmuch commented 8 years ago

Perfect - thanks - sorry about the noise