Skip to content

DirectiveContext

type DirectiveContext =
    {
        Ancestors: obj list
        SiblingIndex: int
        Nesting: int
        Report: FaultSeverity * string -> unit
    }
AssemblyPartas.Nacara.Plugins.Directives

What a directive can find out about where it sits.

Markdig's block tree holds the nesting but not a parent's decoded arguments, so those are carried here instead. Lookup is by type, following Registry.extras: the type is the contract, and a directive that wants its parent asks for the parent's argument type rather than matching on a name.

Fields

Ancestors: obj list

Decoded arguments of enclosing directives, nearest first.

SiblingIndex: int

Position among siblings of the same name under one parent, from zero.

Nesting: int

How many directives enclose this one.

Report: FaultSeverity * string -> unit

Says something went wrong, in whatever way the build wants it said.

Properties

member Depth: int

How many directives enclose this one.

member Index: int

Position among siblings of the same name under one parent, from zero.

Methods

member Error (message: string) : unit

Report that the directive could not do what was asked of it.

This does not fail the build and cannot: nothing wires a diagnostic sink through to a Registry-scoped IMarkdownExtension, so there is nowhere for a fatal error to be raised to. What happens is that the message is written to stderr under an error: label, naming the directive it came from. What the page shows is whatever the render function went on to return.

member TryAncestor<'T> () : 'T option

The nearest enclosing directive whose arguments are the given type.

member TryParent<'T> () : 'T option

The immediately enclosing directive's arguments, if they are the given type.

member Warn (message: string) : unit

Report something worth saying that did not stop the directive.

The same channel as Error, under a warning: label instead.