@@ -64,6 +64,7 @@ defaultConfiguration =
6464 plotsjlPreamble = mempty ,
6565 plantumlPreamble = mempty ,
6666 sagemathPreamble = mempty ,
67+ d2Preamble = mempty ,
6768 -- Executables
6869 matplotlibExe = python,
6970 matlabExe = " matlab" ,
@@ -78,6 +79,7 @@ defaultConfiguration =
7879 plotsjlExe = " julia" ,
7980 plantumlExe = " java" ,
8081 sagemathExe = " sage" ,
82+ d2Exe = " d2" ,
8183 -- Command line arguments
8284 matplotlibCmdArgs = mempty ,
8385 matlabCmdArgs = mempty ,
@@ -92,6 +94,7 @@ defaultConfiguration =
9294 plotsjlCmdArgs = mempty ,
9395 plantumlCmdArgs = " -jar plantuml.jar" ,
9496 sagemathCmdArgs = mempty ,
97+ d2CmdArgs = mempty ,
9598 -- Extras
9699 matplotlibTightBBox = False ,
97100 matplotlibTransparent = False
@@ -151,7 +154,8 @@ data ConfigPrecursor = ConfigPrecursor
151154 _bokehPrec :: ! BokehPrecursor ,
152155 _plotsjlPrec :: ! PlotsjlPrecursor ,
153156 _plantumlPrec :: ! PlantUMLPrecursor ,
154- _sagemathPrec :: ! SageMathPrecursor
157+ _sagemathPrec :: ! SageMathPrecursor ,
158+ _d2Prec :: ! D2Precursor
155159 }
156160
157161defaultConfigPrecursor :: ConfigPrecursor
@@ -178,7 +182,8 @@ defaultConfigPrecursor =
178182 _bokehPrec = BokehPrecursor Nothing (bokehExe defaultConfiguration) (bokehCmdArgs defaultConfiguration),
179183 _plotsjlPrec = PlotsjlPrecursor Nothing (plotsjlExe defaultConfiguration) (plotsjlCmdArgs defaultConfiguration),
180184 _plantumlPrec = PlantUMLPrecursor Nothing (plantumlExe defaultConfiguration) (plantumlCmdArgs defaultConfiguration),
181- _sagemathPrec = SageMathPrecursor Nothing (sagemathExe defaultConfiguration) (sagemathCmdArgs defaultConfiguration)
185+ _sagemathPrec = SageMathPrecursor Nothing (sagemathExe defaultConfiguration) (sagemathCmdArgs defaultConfiguration),
186+ _d2Prec = D2Precursor Nothing (d2Exe defaultConfiguration) (d2CmdArgs defaultConfiguration)
182187 }
183188
184189data LoggingPrecursor = LoggingPrecursor
@@ -219,6 +224,8 @@ data PlantUMLPrecursor = PlantUMLPrecursor {_plantumlPreamble :: !(Maybe FilePat
219224
220225data SageMathPrecursor = SageMathPrecursor { _sagemathPreamble :: ! (Maybe FilePath ), _sagemathExe :: ! FilePath , _sagemathCmdArgs :: ! Text }
221226
227+ data D2Precursor = D2Precursor { _d2Preamble :: ! (Maybe FilePath ), _d2Exe :: ! FilePath , _d2CmdArgs :: ! Text }
228+
222229instance FromJSON LoggingPrecursor where
223230 parseJSON (Object v) =
224231 LoggingPrecursor <$> v .:? " verbosity" .!= logVerbosity defaultConfiguration
@@ -286,6 +293,10 @@ instance FromJSON SageMathPrecursor where
286293 parseJSON (Object v) = SageMathPrecursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= sagemathExe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= sagemathCmdArgs defaultConfiguration
287294 parseJSON _ = fail $ mconcat [" Could not parse " , show SageMath , " configuration." ]
288295
296+ instance FromJSON D2Precursor where
297+ parseJSON (Object v) = D2Precursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= d2Exe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= d2CmdArgs defaultConfiguration
298+ parseJSON _ = fail $ mconcat [" Could not parse " , show SageMath , " configuration." ]
299+
289300toolkitAsKey :: Toolkit -> Key
290301toolkitAsKey = fromString . unpack . cls
291302
@@ -315,6 +326,7 @@ instance FromJSON ConfigPrecursor where
315326 _plotsjlPrec <- v .:? toolkitAsKey Plotsjl .!= _plotsjlPrec defaultConfigPrecursor
316327 _plantumlPrec <- v .:? toolkitAsKey PlantUML .!= _plantumlPrec defaultConfigPrecursor
317328 _sagemathPrec <- v .:? toolkitAsKey SageMath .!= _sagemathPrec defaultConfigPrecursor
329+ _d2Prec <- v .:? toolkitAsKey D2 .!= _d2Prec defaultConfigPrecursor
318330
319331 return $ ConfigPrecursor {.. }
320332 parseJSON _ = fail " Could not parse configuration."
@@ -349,6 +361,7 @@ renderConfig ConfigPrecursor {..} = do
349361 plotsjlExe = _plotsjlExe _plotsjlPrec
350362 plantumlExe = _plantumlExe _plantumlPrec
351363 sagemathExe = _sagemathExe _sagemathPrec
364+ d2Exe = _d2Exe _d2Prec
352365
353366 matplotlibCmdArgs = _matplotlibCmdArgs _matplotlibPrec
354367 matlabCmdArgs = _matlabCmdArgs _matlabPrec
@@ -363,6 +376,7 @@ renderConfig ConfigPrecursor {..} = do
363376 plotsjlCmdArgs = _plotsjlCmdArgs _plotsjlPrec
364377 plantumlCmdArgs = _plantumlCmdArgs _plantumlPrec
365378 sagemathCmdArgs = _sagemathCmdArgs _sagemathPrec
379+ d2CmdArgs = _d2CmdArgs _d2Prec
366380
367381 matplotlibPreamble <- readPreamble (_matplotlibPreamble _matplotlibPrec)
368382 matlabPreamble <- readPreamble (_matlabPreamble _matlabPrec)
@@ -377,6 +391,7 @@ renderConfig ConfigPrecursor {..} = do
377391 plotsjlPreamble <- readPreamble (_plotsjlPreamble _plotsjlPrec)
378392 plantumlPreamble <- readPreamble (_plantumlPreamble _plantumlPrec)
379393 sagemathPreamble <- readPreamble (_sagemathPreamble _sagemathPrec)
394+ d2Preamble <- readPreamble (_d2Preamble _d2Prec)
380395
381396 return Configuration {.. }
382397 where
0 commit comments