From 71580571175bf876dda7ffc9471dff24d8475d56 Mon Sep 17 00:00:00 2001 From: Giorgio Garofalo Date: Sun, 11 Aug 2024 18:34:34 +0200 Subject: [PATCH] Use LibraryExporter.exportAll in pipeline initialization --- .../eu/iamgio/quarkdown/cli/PipelineInitialization.kt | 4 +++- .../iamgio/quarkdown/function/library/LibraryExporter.kt | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cli/src/main/kotlin/eu/iamgio/quarkdown/cli/PipelineInitialization.kt b/cli/src/main/kotlin/eu/iamgio/quarkdown/cli/PipelineInitialization.kt index 0fe2ca2d..370c9ede 100644 --- a/cli/src/main/kotlin/eu/iamgio/quarkdown/cli/PipelineInitialization.kt +++ b/cli/src/main/kotlin/eu/iamgio/quarkdown/cli/PipelineInitialization.kt @@ -2,6 +2,8 @@ package eu.iamgio.quarkdown.cli import eu.iamgio.quarkdown.context.MutableContext import eu.iamgio.quarkdown.flavor.MarkdownFlavor +import eu.iamgio.quarkdown.function.library.Library +import eu.iamgio.quarkdown.function.library.LibraryExporter import eu.iamgio.quarkdown.log.DebugFormatter import eu.iamgio.quarkdown.log.Log import eu.iamgio.quarkdown.pipeline.Pipeline @@ -23,7 +25,7 @@ object PipelineInitialization { options: PipelineOptions, ): Pipeline { // Libraries to load. - val libraries = setOf(Stdlib.library) + val libraries: Set = LibraryExporter.exportAll(Stdlib) // Actions run after each stage of the pipeline. val hooks = diff --git a/core/src/main/kotlin/eu/iamgio/quarkdown/function/library/LibraryExporter.kt b/core/src/main/kotlin/eu/iamgio/quarkdown/function/library/LibraryExporter.kt index c9bd7f10..8a5fea83 100644 --- a/core/src/main/kotlin/eu/iamgio/quarkdown/function/library/LibraryExporter.kt +++ b/core/src/main/kotlin/eu/iamgio/quarkdown/function/library/LibraryExporter.kt @@ -9,4 +9,13 @@ interface LibraryExporter { * The library to export and hand to the pipeline. */ val library: Library + + companion object { + /** + * Loads libraries from the given exporters. + * @param exporters library exporters + * @return set of exported libraries from the given exporters + */ + fun exportAll(vararg exporters: LibraryExporter): Set = exporters.map { it.library }.toSet() + } }