Copyright | (c) Laurent P René de Cotret 2019 |
---|---|
License | MIT |
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
- inclusionKeys :: [String]
- directoryKey :: String
- captionKey :: String
- dpiKey :: String
- includePathKey :: String
- saveFormatKey :: String
- data FigureSpec = FigureSpec {
- caption :: String
- script :: PythonScript
- saveFormat :: SaveFormat
- directory :: FilePath
- dpi :: Int
- blockAttrs :: Attr
- data SaveFormat
- saveFormatFromString :: String -> Maybe SaveFormat
- toImage :: FigureSpec -> Block
- sourceCodePath :: FigureSpec -> FilePath
- figurePath :: FigureSpec -> FilePath
- addPlotCapture :: FigureSpec -> PythonScript
- extension :: SaveFormat -> String
- runTempPythonScript :: String -> [String] -> PythonScript -> IO ScriptResult
- runScriptIfNecessary :: Configuration -> FigureSpec -> IO ScriptResult
- type PythonScript = Text
- data ScriptResult
- data CheckResult
- data PandocPyplotError
- data SaveFormat
- saveFormatFromString :: String -> Maybe SaveFormat
- extension :: SaveFormat -> String
- defaultPlatformInterpreter :: String
- data Configuration = Configuration {}
- data FigureSpec = FigureSpec {
- caption :: String
- script :: PythonScript
- saveFormat :: SaveFormat
- directory :: FilePath
- dpi :: Int
- 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
inclusionKeys :: [String] Source #
list of all keys related to pandoc-pyplot.
directoryKey :: String Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
captionKey :: String 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 :: String Source #
Keys that pandoc-pyplot will look for in code blocks. These are only exported for testing purposes.
saveFormatKey :: String 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
FigureSpec | |
|
Instances
Hashable FigureSpec Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types hashWithSalt :: Int -> FigureSpec -> Int # hash :: FigureSpec -> Int # |
data SaveFormat Source #
Generated figure file format supported by pandoc-pyplot.
Instances
Bounded SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types minBound :: SaveFormat # maxBound :: SaveFormat # | |
Enum SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types succ :: SaveFormat -> SaveFormat # pred :: SaveFormat -> SaveFormat # toEnum :: Int -> SaveFormat # fromEnum :: SaveFormat -> Int # enumFrom :: SaveFormat -> [SaveFormat] # enumFromThen :: SaveFormat -> SaveFormat -> [SaveFormat] # enumFromTo :: SaveFormat -> SaveFormat -> [SaveFormat] # enumFromThenTo :: SaveFormat -> SaveFormat -> SaveFormat -> [SaveFormat] # | |
Eq SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: SaveFormat -> SaveFormat -> Bool # (/=) :: SaveFormat -> SaveFormat -> Bool # | |
Show SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types showsPrec :: Int -> SaveFormat -> ShowS # show :: SaveFormat -> String # showList :: [SaveFormat] -> ShowS # |
saveFormatFromString :: String -> Maybe SaveFormat Source #
Parse an image save format string
>>>
saveFormatFromString ".png"
Just PNG
>>>
saveFormatFromString "jpeg"
Just JPEG
>>>
SaveFormatFromString "arbitrary"
Nothing
toImage :: FigureSpec -> Block Source #
Convert a FigureSpec to a Pandoc block component
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.
extension :: SaveFormat -> String Source #
Save format file extension
:: String | Interpreter (e.g. "python" or "python35") |
-> [String] | Command-line flags |
-> PythonScript | Content of the script |
-> IO ScriptResult | Result. |
Take a python script in string form, write it in a temporary directory, then execute it.
runScriptIfNecessary :: Configuration -> FigureSpec -> IO ScriptResult Source #
Run the Python script. In case the file already exists, we can safely assume there is no need to re-run it.
type PythonScript = Text Source #
String representation of a Python script
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.
Instances
Bounded SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types minBound :: SaveFormat # maxBound :: SaveFormat # | |
Enum SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types succ :: SaveFormat -> SaveFormat # pred :: SaveFormat -> SaveFormat # toEnum :: Int -> SaveFormat # fromEnum :: SaveFormat -> Int # enumFrom :: SaveFormat -> [SaveFormat] # enumFromThen :: SaveFormat -> SaveFormat -> [SaveFormat] # enumFromTo :: SaveFormat -> SaveFormat -> [SaveFormat] # enumFromThenTo :: SaveFormat -> SaveFormat -> SaveFormat -> [SaveFormat] # | |
Eq SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types (==) :: SaveFormat -> SaveFormat -> Bool # (/=) :: SaveFormat -> SaveFormat -> Bool # | |
Show SaveFormat Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types showsPrec :: Int -> SaveFormat -> ShowS # show :: SaveFormat -> String # showList :: [SaveFormat] -> ShowS # |
saveFormatFromString :: String -> Maybe SaveFormat Source #
Parse an image save format string
>>>
saveFormatFromString ".png"
Just PNG
>>>
saveFormatFromString "jpeg"
Just JPEG
>>>
SaveFormatFromString "arbitrary"
Nothing
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 # | |
Default Configuration Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types def :: Configuration # |
data FigureSpec Source #
Datatype containing all parameters required to run pandoc-pyplot
FigureSpec | |
|
Instances
Hashable FigureSpec Source # | |
Defined in Text.Pandoc.Filter.Pyplot.Types hashWithSalt :: Int -> FigureSpec -> Int # hash :: FigureSpec -> Int # |