Skip to content

Commit e7894b6

Browse files
committed
Exposing version information
1 parent 94e7651 commit e7894b6

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fig = px.scatter_ternary(df, a="Joly", b="Coderre", c="Bergeron")
2020
* Added a new toolkit, [`bokeh`](https://bokeh.org/). This toolkit can take advantage of the new HTML interactive output.
2121
* Added a new toolkit, [`plotsjl`](http://docs.juliaplots.org/latest/).
2222
* 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`.
23+
* Exposed the `pandoc-plot` version via `Text.Pandoc.Filter.Plot.pandocPlotVersion`.
2324

2425
Release 0.7.2.1
2526
---------------

executable/Main.hs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{-# LANGUAGE ApplicativeDo #-}
22
{-# LANGUAGE LambdaCase #-}
3+
{-# LANGUAGE OverloadedStrings #-}
34
{-# LANGUAGE TemplateHaskell #-}
45
{-# LANGUAGE RecordWildCards #-}
6+
{-# LANGUAGE CPP #-}
57

68
module Main where
79

@@ -26,7 +28,8 @@ import System.IO (hPutStrLn, stderr)
2628
import Text.Pandoc.Filter.Plot (availableToolkits,
2729
plotTransform,
2830
defaultConfiguration,
29-
configuration, Configuration(..))
31+
configuration, Configuration(..),
32+
pandocPlotVersion)
3033
import Text.Pandoc.Filter.Plot.Internal (cls, supportedSaveFormats,
3134
toolkits, readDoc,
3235
cleanOutputDirs,
@@ -42,7 +45,6 @@ import Text.ParserCombinators.ReadP (readP_to_S)
4245
import OpenFile (openFile)
4346

4447
import qualified Data.Version as V
45-
import Paths_pandoc_plot (version)
4648

4749
import ManPage (embedManualHtml)
4850
import ExampleConfig (embedExampleConfig)
@@ -65,10 +67,13 @@ main = join $ execParser opts
6567
where
6668
opts = info (optparse <**> helper)
6769
(fullDesc
68-
<> progDesc "This pandoc filter generates plots from code blocks using a multitude of \
69-
\possible renderers. This allows to keep documentation and figures in \
70-
\perfect synchronicity."
71-
<> header (mconcat ["pandoc-plot ", V.showVersion version, " - generate figures directly in documents"])
70+
<> progDesc (unlines
71+
["This pandoc filter generates plots from code blocks using a multitude of "
72+
, "possible renderers. This allows to keep documentation and figures in"
73+
, "perfect synchronicity."
74+
]
75+
)
76+
<> header (mconcat ["pandoc-plot ", V.showVersion pandocPlotVersion, " - generate figures directly in documents"])
7277
<> footerDoc (Just footer')
7378
)
7479

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

8489
go :: Maybe Flag -> Maybe Command -> Maybe String -> IO ()
85-
go (Just Version) _ _ = putStrLn (V.showVersion version)
90+
go (Just Version) _ _ = putStrLn (V.showVersion pandocPlotVersion)
8691
go (Just FullVersion) _ _ = showFullVersion
8792
go (Just Manual) _ _ = showManPage
8893
go _ (Just (Toolkits mfp)) _ = showAvailableToolkits mfp
@@ -117,10 +122,13 @@ commandParser = optional $ subparser $ mconcat
117122
)
118123
, command "clean" (
119124
info (cleanP <**> helper) (
120-
progDesc "Clean output directories where figures from FILE and log files might be stored.\
121-
\ WARNING: All files in those directories will be deleted."
122-
)
125+
progDesc (unlines
126+
[ "Clean output directories where figures from FILE and log files might be stored."
127+
, "WARNING: All files in those directories will be deleted."
128+
]
129+
)
123130
)
131+
)
124132
, command "write-example-config" (
125133
info (writeConfigP <**> helper) (progDesc "Write example configuration to a file and exit.")
126134
)
@@ -196,13 +204,13 @@ localConfig = do
196204

197205
showFullVersion :: IO ()
198206
showFullVersion = do
199-
putStrLn $ "pandoc-plot " <> (V.showVersion version)
207+
putStrLn $ "pandoc-plot " <> (V.showVersion pandocPlotVersion)
200208
putStrLn $ "Git revision " <> gitrev
201-
putStrLn $ mconcat [ "Compiled with pandoc "
202-
, (unpack pandocVersion)
203-
, " and pandoc-types "
204-
, V.showVersion pandocTypesVersion
205-
]
209+
putStrLn $ mconcat
210+
[ "Compiled with pandoc " , (unpack pandocVersion)
211+
, " and pandoc-types " , V.showVersion pandocTypesVersion
212+
, " using GHC ", TOOL_VERSION_ghc -- Constant defined by CPP
213+
]
206214
where
207215
-- In certain environments (e.g. Hackage when building documentation),
208216
-- there is no git information.

src/Text/Pandoc/Filter/Plot.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ attribute will trigger the filter:
2525
* @octaveplot@ for GNU Octave plots;
2626
* @ggplot2@ for ggplot2-based R plots;
2727
* @gnuplot@ for gnuplot plots;
28-
* @graphviz@ for Graphviz graphs.
28+
* @graphviz@ for Graphviz graphs;
29+
* @bokeh@ for Bokeh-based Python plots;
30+
* @plotsjl@ for Plots.jl-based Julia plots;
2931
3032
For example, in Markdown:
3133
@@ -82,6 +84,8 @@ module Text.Pandoc.Filter.Plot (
8284
-- * Determining available plotting toolkits
8385
, availableToolkits
8486
, unavailableToolkits
87+
-- * Version information
88+
, pandocPlotVersion
8589
-- * For testing and internal purposes ONLY
8690
, make
8791
, makeEither
@@ -91,13 +95,15 @@ module Text.Pandoc.Filter.Plot (
9195

9296
import Control.Concurrent.Async.Lifted (mapConcurrently)
9397
import Data.Text (Text, unpack)
98+
import Data.Version (Version)
99+
100+
import Paths_pandoc_plot (version)
94101

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

98105
import Text.Pandoc.Filter.Plot.Internal
99106

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

131137

138+
-- | The version of the pandoc-plot package.
139+
--
140+
-- @since 0.8.0.0
141+
pandocPlotVersion :: Version
142+
pandocPlotVersion = version
143+
144+
132145
-- | Try to process the block with `pandoc-plot`. If a failure happens (or the block)
133146
-- was not meant to become a figure, return the block as-is.
134147
make :: Block -> PlotM Block

0 commit comments

Comments
 (0)