Skip to content

Commit

Permalink
Exposing version information
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Jul 13, 2020
1 parent 94e7651 commit e7894b6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fig = px.scatter_ternary(df, a="Joly", b="Coderre", c="Bergeron")
* Added a new toolkit, [`bokeh`](https://bokeh.org/). This toolkit can take advantage of the new HTML interactive output.
* Added a new toolkit, [`plotsjl`](http://docs.juliaplots.org/latest/).
* Separated the detailed information from `README.md` and into a proper `MANUAL.md`. This is now the information which will be shown with `pandoc-plot --manual`.
* Exposed the `pandoc-plot` version via `Text.Pandoc.Filter.Plot.pandocPlotVersion`.

Release 0.7.2.1
---------------
Expand Down
40 changes: 24 additions & 16 deletions executable/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE CPP #-}

module Main where

Expand All @@ -26,7 +28,8 @@ import System.IO (hPutStrLn, stderr)
import Text.Pandoc.Filter.Plot (availableToolkits,
plotTransform,
defaultConfiguration,
configuration, Configuration(..))
configuration, Configuration(..),
pandocPlotVersion)
import Text.Pandoc.Filter.Plot.Internal (cls, supportedSaveFormats,
toolkits, readDoc,
cleanOutputDirs,
Expand All @@ -42,7 +45,6 @@ import Text.ParserCombinators.ReadP (readP_to_S)
import OpenFile (openFile)

import qualified Data.Version as V
import Paths_pandoc_plot (version)

import ManPage (embedManualHtml)
import ExampleConfig (embedExampleConfig)
Expand All @@ -65,10 +67,13 @@ main = join $ execParser opts
where
opts = info (optparse <**> helper)
(fullDesc
<> progDesc "This pandoc filter generates plots from code blocks using a multitude of \
\possible renderers. This allows to keep documentation and figures in \
\perfect synchronicity."
<> header (mconcat ["pandoc-plot ", V.showVersion version, " - generate figures directly in documents"])
<> progDesc (unlines
["This pandoc filter generates plots from code blocks using a multitude of "
, "possible renderers. This allows to keep documentation and figures in"
, "perfect synchronicity."
]
)
<> header (mconcat ["pandoc-plot ", V.showVersion pandocPlotVersion, " - generate figures directly in documents"])
<> footerDoc (Just footer')
)

Expand All @@ -82,7 +87,7 @@ main = join $ execParser opts
return $ go flag_ command_ input

go :: Maybe Flag -> Maybe Command -> Maybe String -> IO ()
go (Just Version) _ _ = putStrLn (V.showVersion version)
go (Just Version) _ _ = putStrLn (V.showVersion pandocPlotVersion)
go (Just FullVersion) _ _ = showFullVersion
go (Just Manual) _ _ = showManPage
go _ (Just (Toolkits mfp)) _ = showAvailableToolkits mfp
Expand Down Expand Up @@ -117,10 +122,13 @@ commandParser = optional $ subparser $ mconcat
)
, command "clean" (
info (cleanP <**> helper) (
progDesc "Clean output directories where figures from FILE and log files might be stored.\
\ WARNING: All files in those directories will be deleted."
)
progDesc (unlines
[ "Clean output directories where figures from FILE and log files might be stored."
, "WARNING: All files in those directories will be deleted."
]
)
)
)
, command "write-example-config" (
info (writeConfigP <**> helper) (progDesc "Write example configuration to a file and exit.")
)
Expand Down Expand Up @@ -196,13 +204,13 @@ localConfig = do

showFullVersion :: IO ()
showFullVersion = do
putStrLn $ "pandoc-plot " <> (V.showVersion version)
putStrLn $ "pandoc-plot " <> (V.showVersion pandocPlotVersion)
putStrLn $ "Git revision " <> gitrev
putStrLn $ mconcat [ "Compiled with pandoc "
, (unpack pandocVersion)
, " and pandoc-types "
, V.showVersion pandocTypesVersion
]
putStrLn $ mconcat
[ "Compiled with pandoc " , (unpack pandocVersion)
, " and pandoc-types " , V.showVersion pandocTypesVersion
, " using GHC ", TOOL_VERSION_ghc -- Constant defined by CPP
]
where
-- In certain environments (e.g. Hackage when building documentation),
-- there is no git information.
Expand Down
17 changes: 15 additions & 2 deletions src/Text/Pandoc/Filter/Plot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ attribute will trigger the filter:
* @octaveplot@ for GNU Octave plots;
* @ggplot2@ for ggplot2-based R plots;
* @gnuplot@ for gnuplot plots;
* @graphviz@ for Graphviz graphs.
* @graphviz@ for Graphviz graphs;
* @bokeh@ for Bokeh-based Python plots;
* @plotsjl@ for Plots.jl-based Julia plots;
For example, in Markdown:
Expand Down Expand Up @@ -82,6 +84,8 @@ module Text.Pandoc.Filter.Plot (
-- * Determining available plotting toolkits
, availableToolkits
, unavailableToolkits
-- * Version information
, pandocPlotVersion
-- * For testing and internal purposes ONLY
, make
, makeEither
Expand All @@ -91,13 +95,15 @@ module Text.Pandoc.Filter.Plot (

import Control.Concurrent.Async.Lifted (mapConcurrently)
import Data.Text (Text, unpack)
import Data.Version (Version)

import Paths_pandoc_plot (version)

import Text.Pandoc.Definition (Pandoc(..), Block)
import Text.Pandoc.Walk (walkM, Walkable)

import Text.Pandoc.Filter.Plot.Internal


-- | Walk over an entire Pandoc document, transforming appropriate code blocks
-- into figures. This function will operate on blocks in parallel if possible.
--
Expand Down Expand Up @@ -129,6 +135,13 @@ makePlot :: Walkable Block a
makePlot conf = runPlotM conf . walkM make


-- | The version of the pandoc-plot package.
--
-- @since 0.8.0.0
pandocPlotVersion :: Version
pandocPlotVersion = version


-- | Try to process the block with `pandoc-plot`. If a failure happens (or the block)
-- was not meant to become a figure, return the block as-is.
make :: Block -> PlotM Block
Expand Down

0 comments on commit e7894b6

Please sign in to comment.