Class Sealed
public sealed class BuildPipeline

Namespace: Moka.Docs.Engine

Orchestrates the execution of all build phases in order.

Constructors

NameDescription
BuildPipeline(IEnumerable<IBuildPhase> phases, BuildPipeline> logger) Orchestrates the execution of all build phases in order.

BuildPipeline(IEnumerable phases, BuildPipeline> logger)

BuildPipeline.BuildPipeline(IEnumerable<IBuildPhase> phases, ILogger<BuildPipeline> logger)

Orchestrates the execution of all build phases in order.

Properties

NameDescription
PluginHook Optional hook that runs after content phases (order < 50) and before rendering phases (order >= 50). Used for plugin execution.

PluginHook

Func<BuildContext, CancellationToken, Task>? BuildPipeline.PluginHook { get; set; }

Optional hook that runs after content phases (order < 50) and before rendering phases (order >= 50). Used for plugin execution.

Methods

NameDescription
ExecuteAsync(BuildContext context, CancellationToken ct) Execute all registered build phases in order, with plugin hook in between.

ExecuteAsync(BuildContext context, CancellationToken ct)

Task BuildPipeline.ExecuteAsync(BuildContext context, CancellationToken ct = null)

Execute all registered build phases in order, with plugin hook in between.

View Source
/// <summary>
///     Orchestrates the execution of all build phases in order.
/// </summary>
public sealed class BuildPipeline(IEnumerable<IBuildPhase> phases, ILogger<BuildPipeline> logger)
{
    /// <summary>
    ///     Optional hook that runs after content phases (order &lt; 50) and before
    ///     rendering phases (order &gt;= 50). Used for plugin execution.
    /// </summary>
    public Func<BuildContext, CancellationToken, Task>? PluginHook { get; set; }

    /// <summary>
    ///     Execute all registered build phases in order, with plugin hook in between.
    /// </summary>
    public async Task ExecuteAsync(BuildContext context, CancellationToken ct = default)
    {
        var orderedPhases = phases.OrderBy(p => p.Order).ToList();
        logger.LogInformation("Starting build pipeline with {PhaseCount} phases", orderedPhases.Count);
        bool pluginHookExecuted = false;
        foreach (IBuildPhase phase in orderedPhases)
        {
            ct.ThrowIfCancellationRequested();
            // Run plugin hook after content phases (<=400) and before nav/render phases (>=600)
            if (!pluginHookExecuted && phase.Order >= 500 && PluginHook is not null)
            {
                logger.LogInformation("Executing plugin hook");
                await PluginHook(context, ct);
                pluginHookExecuted = true;
            }

            logger.LogInformation("Executing phase: {PhaseName} (order {Order})", phase.Name, phase.Order);
            await phase.ExecuteAsync(context, ct);
        }

        logger.LogInformation("Build pipeline complete");
    }
}
Was this page helpful?