# DirectiveContext

<pre class="nacara-api__signature"><code><span class="tok-keyword">type</span> <span class="tok-type">DirectiveContext</span> <span class="tok-operator">=</span>
    <span class="tok-punctuation">{</span>
        <a class="tok-property" href="#ancestors">Ancestors</a><span class="tok-punctuation">:</span> <span class="tok-type">obj</span> <span class="tok-type">list</span>
        <a class="tok-property" href="#siblingindex">SiblingIndex</a><span class="tok-punctuation">:</span> <span class="tok-type">int</span>
        <a class="tok-property" href="#nesting">Nesting</a><span class="tok-punctuation">:</span> <span class="tok-type">int</span>
        <a class="tok-property" href="#report">Report</a><span class="tok-punctuation">:</span> <span class="tok-type">FaultSeverity</span> <span class="tok-operator">*</span> <span class="tok-type">string</span> <span class="tok-operator">-&gt;</span> <span class="tok-type">unit</span>
    <span class="tok-punctuation">}</span></code></pre>

| | |
|---|---|
| Assembly | `Partas.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

<div class="nacara-api__entry" id="ancestors">
<a class="nacara-api__anchor"
                           href="#ancestors"
                           aria-label="Link to Ancestors"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-property">Ancestors</span><span class="tok-punctuation">:</span> <span class="tok-type">obj</span> <span class="tok-type">list</span></code></pre>
</summary>
<div class="nacara-api__body">

Decoded arguments of enclosing directives, nearest first.


</div>
</details>
</div>

<div class="nacara-api__entry" id="siblingindex">
<a class="nacara-api__anchor"
                           href="#siblingindex"
                           aria-label="Link to SiblingIndex"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-property">SiblingIndex</span><span class="tok-punctuation">:</span> <span class="tok-type">int</span></code></pre>
</summary>
<div class="nacara-api__body">

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


</div>
</details>
</div>

<div class="nacara-api__entry" id="nesting">
<a class="nacara-api__anchor"
                           href="#nesting"
                           aria-label="Link to Nesting"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-property">Nesting</span><span class="tok-punctuation">:</span> <span class="tok-type">int</span></code></pre>
</summary>
<div class="nacara-api__body">

How many directives enclose this one.


</div>
</details>
</div>

<div class="nacara-api__entry" id="report">
<a class="nacara-api__anchor"
                           href="#report"
                           aria-label="Link to Report"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-property">Report</span><span class="tok-punctuation">:</span> <span class="tok-type">FaultSeverity</span> <span class="tok-operator">*</span> <span class="tok-type">string</span> <span class="tok-operator">-&gt;</span> <span class="tok-type">unit</span></code></pre>
</summary>
<div class="nacara-api__body">

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


</div>
</details>
</div>

## Properties

<div class="nacara-api__entry" id="depth">
<a class="nacara-api__anchor"
                           href="#depth"
                           aria-label="Link to Depth"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-property">Depth</span><span class="tok-punctuation">:</span> <span class="tok-type">int</span></code></pre>
</summary>
<div class="nacara-api__body">

How many directives enclose this one.


</div>
</details>
</div>

<div class="nacara-api__entry" id="index">
<a class="nacara-api__anchor"
                           href="#index"
                           aria-label="Link to Index"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-property">Index</span><span class="tok-punctuation">:</span> <span class="tok-type">int</span></code></pre>
</summary>
<div class="nacara-api__body">

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


</div>
</details>
</div>

## Methods

<div class="nacara-api__entry" id="error">
<a class="nacara-api__anchor"
                           href="#error"
                           aria-label="Link to Error"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-function">Error</span> <span class="tok-punctuation">(</span><span class="tok-parameter">message</span><span class="tok-punctuation">:</span> <span class="tok-type">string</span><span class="tok-punctuation">)</span> <span class="tok-punctuation">:</span> <span class="tok-type">unit</span></code></pre>
</summary>
<div class="nacara-api__body">

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.


</div>
</details>
</div>

<div class="nacara-api__entry" id="tryancestor">
<a class="nacara-api__anchor"
                           href="#tryancestor"
                           aria-label="Link to TryAncestor"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-function">TryAncestor</span><span class="tok-operator">&lt;'</span><span class="tok-parameter">T</span><span class="tok-operator">&gt;</span> <span class="tok-punctuation">()</span> <span class="tok-punctuation">:</span> <span class="tok-punctuation">'</span><span class="tok-parameter">T</span> <span class="tok-type">option</span></code></pre>
</summary>
<div class="nacara-api__body">

The nearest enclosing directive whose arguments are the given type.


</div>
</details>
</div>

<div class="nacara-api__entry" id="tryparent">
<a class="nacara-api__anchor"
                           href="#tryparent"
                           aria-label="Link to TryParent"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-function">TryParent</span><span class="tok-operator">&lt;'</span><span class="tok-parameter">T</span><span class="tok-operator">&gt;</span> <span class="tok-punctuation">()</span> <span class="tok-punctuation">:</span> <span class="tok-punctuation">'</span><span class="tok-parameter">T</span> <span class="tok-type">option</span></code></pre>
</summary>
<div class="nacara-api__body">

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


</div>
</details>
</div>

<div class="nacara-api__entry" id="warn">
<a class="nacara-api__anchor"
                           href="#warn"
                           aria-label="Link to Warn"
                           data-pagefind-ignore></a>
<details class="nacara-api__member">
<summary>
<pre class="nacara-api__signature nacara-api__signature--hanging"><code><span class="tok-keyword">member</span> <span class="tok-function">Warn</span> <span class="tok-punctuation">(</span><span class="tok-parameter">message</span><span class="tok-punctuation">:</span> <span class="tok-type">string</span><span class="tok-punctuation">)</span> <span class="tok-punctuation">:</span> <span class="tok-type">unit</span></code></pre>
</summary>
<div class="nacara-api__body">

Report something worth saying that did not stop the directive.

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


</div>
</details>
</div>
