Copyright | (c) Laurent P René de Cotret 2019 |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | laurent.decotret@outlook.com |
Stability | internal |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module re-exports internal pandoc-pyplot functionality.
Synopsis
- configuration :: FilePath -> IO Configuration
- writeConfig :: FilePath -> Configuration -> IO ()
- inclusionKeys :: [Text]
- directoryKey :: Text
- captionKey :: Text
- dpiKey :: Text
- includePathKey :: Text
- saveFormatKey :: Text
- withLinksKey :: Text
- isTightBboxKey :: Text
- isTransparentKey :: Text
- data FigureSpec = FigureSpec {
- caption :: Text
- withLinks :: Bool
- script :: PythonScript
- saveFormat :: SaveFormat
- directory :: FilePath
- dpi :: Int
- renderingLib :: RenderingLibrary
- tightBbox :: Bool
- transparent :: Bool
- blockAttrs :: Attr
- data SaveFormat
- toImage :: FigureSpec -> Block
- sourceCodePath :: FigureSpec -> FilePath
- figurePath :: FigureSpec -> FilePath
- addPlotCapture :: FigureSpec -> PythonScript
- parseFigureSpec :: Block -> PyplotM (Maybe FigureSpec)
- extension :: SaveFormat -> String
- runTempPythonScript :: PythonScript -> PyplotM ScriptResult
- runScriptIfNecessary :: FigureSpec -> PyplotM ScriptResult
- directoryKey :: Text
- captionKey :: Text
- dpiKey :: Text
- includePathKey :: Text
- saveFormatKey :: Text
- withLinksKey :: Text
- isTightBboxKey :: Text
- isTransparentKey :: Text
- inclusionKeys :: [Text]
- type PyplotM a = ReaderT Configuration IO a
- type PythonScript = Text
- data RenderingLibrary
- = Matplotlib
- | Plotly
- data ScriptResult
- data CheckResult
- data PandocPyplotError
- data SaveFormat
- extension :: SaveFormat -> String
- defaultPlatformInterpreter :: String
- data Configuration = Configuration {}
- data FigureSpec = FigureSpec {
- caption :: Text
- withLinks :: Bool
- script :: PythonScript
- saveFormat :: SaveFormat
- directory :: FilePath
- dpi :: Int
- renderingLib :: RenderingLibrary
- tightBbox :: Bool
- transparent :: Bool
- blockAttrs :: Attr
Documentation
configuration :: FilePath -> IO Configuration Source #
Building configuration from a YAML file. The keys are exactly the same as for Markdown code blocks.
If a key is either not present or unreadable, its value will be set to the default value.
Since: 2.1.0.0
For testing and internal purposes only
writeConfig :: FilePath -> Configuration -> IO () Source #
Write a configuration to file. An exception will be raised in case the file would be overwritten.
Since: 2.1.3.0
inclusionKeys :: [Text] Source #
list of all keys related to pandoc-pyplot that can be specified in source material.
directoryKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
captionKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
includePathKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
saveFormatKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
withLinksKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
isTightBboxKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
isTransparentKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
data FigureSpec Source #
Datatype containing all parameters required to run pandoc-pyplot.
It is assumed that once a FigureSpec
has been created, no configuration
can overload it; hence, a FigureSpec
completely encodes a particular figure.
FigureSpec | |
|
Instances
data SaveFormat Source #
Generated figure file format supported by pandoc-pyplot. Note: all formats are supported by Matplotlib, but not all formats are supported by Plotly
Instances
toImage :: FigureSpec -> Block Source #
Convert a FigureSpec
to a Pandoc block component.
Note that the script to generate figure files must still
be run in another function.
sourceCodePath :: FigureSpec -> FilePath Source #
Determine the path to the source code that generated the figure.
figurePath :: FigureSpec -> FilePath Source #
Determine the path a figure should have.
:: FigureSpec | Path where to save the figure |
-> PythonScript | Code block with added capture |
Modify a Python plotting script to save the figure to a filename. An additional file will also be captured.
parseFigureSpec :: Block -> PyplotM (Maybe FigureSpec) Source #
Determine inclusion specifications from Block
attributes.
Note that the ".pyplot"
OR .plotly
class is required, but all other
parameters are optional.
extension :: SaveFormat -> String Source #
Save format file extension
:: PythonScript | Content of the script |
-> PyplotM ScriptResult | Result. |
Take a python script in string form, write it in a temporary directory, then execute it.
runScriptIfNecessary :: FigureSpec -> PyplotM ScriptResult Source #
Run the Python script. In case the file already exists, we can safely assume there is no need to re-run it.
directoryKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
captionKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
includePathKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
saveFormatKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
withLinksKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
isTightBboxKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
isTransparentKey :: Text Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
inclusionKeys :: [Text] Source #
list of all keys related to pandoc-pyplot that can be specified in source material.
type PyplotM a = ReaderT Configuration IO a Source #
Monad in which to run pandoc-pyplot computations
type PythonScript = Text Source #
String representation of a Python script
data RenderingLibrary Source #
Rendering library
Since: 2.2.0.0
Matplotlib | Rendering via the Matplotlib library. This library has the most features. |
Plotly | Rendering via the Plotly library. |
Instances
Eq RenderingLibrary Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: RenderingLibrary -> RenderingLibrary -> Bool # (/=) :: RenderingLibrary -> RenderingLibrary -> Bool # | |
Show RenderingLibrary Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types showsPrec :: Int -> RenderingLibrary -> ShowS # show :: RenderingLibrary -> String # showList :: [RenderingLibrary] -> ShowS # | |
Generic RenderingLibrary Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types type Rep RenderingLibrary :: Type -> Type # from :: RenderingLibrary -> Rep RenderingLibrary x # to :: Rep RenderingLibrary x -> RenderingLibrary # | |
Hashable RenderingLibrary Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types hashWithSalt :: Int -> RenderingLibrary -> Int # hash :: RenderingLibrary -> Int # | |
type Rep RenderingLibrary Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types |
data ScriptResult Source #
Possible result of running a Python script
data CheckResult Source #
Result of checking scripts for problems
Instances
Eq CheckResult Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: CheckResult -> CheckResult -> Bool # (/=) :: CheckResult -> CheckResult -> Bool # | |
Semigroup CheckResult Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (<>) :: CheckResult -> CheckResult -> CheckResult # sconcat :: NonEmpty CheckResult -> CheckResult # stimes :: Integral b => b -> CheckResult -> CheckResult # | |
Monoid CheckResult Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types mempty :: CheckResult # mappend :: CheckResult -> CheckResult -> CheckResult # mconcat :: [CheckResult] -> CheckResult # |
data PandocPyplotError Source #
Possible errors returned by the filter
ScriptError Int | Running Python script has yielded an error |
ScriptChecksFailedError String | Python script did not pass all checks |
Instances
Eq PandocPyplotError Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: PandocPyplotError -> PandocPyplotError -> Bool # (/=) :: PandocPyplotError -> PandocPyplotError -> Bool # | |
Show PandocPyplotError Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types showsPrec :: Int -> PandocPyplotError -> ShowS # show :: PandocPyplotError -> String # showList :: [PandocPyplotError] -> ShowS # |
data SaveFormat Source #
Generated figure file format supported by pandoc-pyplot. Note: all formats are supported by Matplotlib, but not all formats are supported by Plotly
Instances
extension :: SaveFormat -> String Source #
Save format file extension
defaultPlatformInterpreter :: String Source #
Default interpreter should be Python 3, which has a different name on Windows ("python") vs Unix ("python3")
Since: 2.1.2.0
data Configuration Source #
Configuration of pandoc-pyplot, describing the default behavior of the filter.
A Configuration is useful when dealing with lots of figures; it avoids repeating the same values.sta
Since: 2.1.0.0
Configuration | |
|
Instances
Eq Configuration Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: Configuration -> Configuration -> Bool # (/=) :: Configuration -> Configuration -> Bool # | |
Show Configuration Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types showsPrec :: Int -> Configuration -> ShowS # show :: Configuration -> String # showList :: [Configuration] -> ShowS # | |
ToJSON Configuration Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types toJSON :: Configuration -> Value # toEncoding :: Configuration -> Encoding # toJSONList :: [Configuration] -> Value # toEncodingList :: [Configuration] -> Encoding # | |
Default Configuration Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types def :: Configuration # |
data FigureSpec Source #
Datatype containing all parameters required to run pandoc-pyplot.
It is assumed that once a FigureSpec
has been created, no configuration
can overload it; hence, a FigureSpec
completely encodes a particular figure.
FigureSpec | |
|