Skip to content

Commit

Permalink
Remove PipelineHooks#beforeExpanding
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Sep 20, 2024
1 parent d1e5c46 commit 07eafb7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Pipeline(
* @see Library.hooks
*/
private fun invokeHooks(hook: (PipelineHooks) -> Unit) {
// Invoke the hook of this pipeline.
hooks?.let { hook(it) }
// Invoke the hook of all the registered libraries.
libraries.forEach { it.hooks?.let(hook) }
}

Expand Down Expand Up @@ -168,7 +170,6 @@ class Pipeline(
// The user can further force override the media storage options.
context.options.mergeMediaStorageOptions(options.mediaStorageOptionsOverrides)

invokeHooks { it.beforeExpanding(this, context) }
expandFunctionCalls(document)

visitTree(document)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.iamgio.quarkdown.pipeline

import eu.iamgio.quarkdown.ast.AstRoot
import eu.iamgio.quarkdown.context.Context
import eu.iamgio.quarkdown.function.library.Library
import eu.iamgio.quarkdown.lexer.Token

Expand All @@ -10,10 +9,6 @@ import eu.iamgio.quarkdown.lexer.Token
* @param afterRegisteringLibraries action to run after the libraries have been registered and are ready to be looked up (libraries as arguments)
* @param afterLexing action to run after the tokens have been produced (output tokens as arguments)
* @param afterParsing action to run after the AST has been generated (root as an argument)
* @param beforeExpanding action to run before function calls are evaluated (main context as an argument).
* The difference between this and [afterParsing] is that [afterParsing] might be called multiple times in case the parsing process is invoked internally,
* for example when including external files from a function. [beforeExpanding] is called only once, between the main parsing process and the function calls expansion.
* Also, at the time of this hook, [eu.iamgio.quarkdown.ast.AstAttributes.root] is set, while it is not at the time of [afterParsing]
* @param afterExpanding action to run after the queued function calls have been expanded (root as an argument)
* @param afterTreeVisiting action to run after the produced AST has been visited
* @param afterRendering action to run after the rendered output code has been generated (output code as an argument)
Expand All @@ -24,7 +19,6 @@ data class PipelineHooks(
val afterRegisteringLibraries: Pipeline.(Set<Library>) -> Unit = {},
val afterLexing: Pipeline.(List<Token>) -> Unit = {},
val afterParsing: Pipeline.(AstRoot) -> Unit = {},
val beforeExpanding: Pipeline.(Context) -> Unit = {},
val afterExpanding: Pipeline.(AstRoot) -> Unit = {},
val afterTreeVisiting: Pipeline.() -> Unit = {},
val afterRendering: Pipeline.(CharSequence) -> Unit = {},
Expand Down

0 comments on commit 07eafb7

Please sign in to comment.