# directive

URL: /patitas/api/lexer/scanners/directive/
Section: scanners
Description: Directive mode scanner mixin.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/lexer/scanners/directive/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flexer%2Fscanners%2Fdirective%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flexer%2Fscanners%2Fdirective%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flexer%2Fscanners%2Fdirective%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flexer%2Fscanners%2Fdirective%2Findex.txt)

Module

#
`lexer.scanners.directive`

Directive mode scanner mixin.

1Class

## Classes

`DirectiveScannerMixin`

8

▼

Mixin providing directive mode scanning logic.

Scans content inside directive blocks, handling:
- …

Mixin providing directive mode scanning logic.

Scans content inside directive blocks, handling:

- Directive options (:key: value)

- Nested directives (higher colon count)

- Closing fence (matching or higher colon count)

- All block-level elements (lists, headings, code, quotes, etc.)

- Regular content (paragraph lines)

#### Attributes

Name
Type
Description

`_source`

`str`

—

`_pos`

`int`

—

#### Methods

Internal Methods
6

▼

`_save_location`

0

▼

Save current location for O(1) token location creation.

`def _save_location(self) -> None`

`_find_line_end`

0

`int`

▼

Find end of current line.

`def _find_line_end(self) -> int`

##### Returns

`int`

`_calc_indent`

1

`tuple[int, int]`

▼

Calculate indent level and content start position.

`def _calc_indent(self, line: str) -> tuple[int, int]`

##### Parameters

Name
Type
Description

`line`
`—`

##### Returns

`tuple[int, int]`

`_commit_to`

1

▼

Commit position to line_end.

`def _commit_to(self, line_end: int) -> None`

##### Parameters

Name
Type
Description

`line_end`
`—`

`_make_token`

6

`Token (/patitas/api/tokens/#Token)`

▼

Create token with raw coordinates. Implemented by Lexer.

`def _make_token(self, token_type: TokenType, value: str, start_pos: int, *, start_col: int | None = None, end_pos: int | None = None, line_indent: int = -1) -> Token`

##### Parameters

Name
Type
Description

`token_type`
`—`

`value`
`—`

`start_pos`
`—`

`start_col`
`—`

Default:`None`

`end_pos`
`—`

Default:`None`

`line_indent`
`—`

Default:`-1`

##### Returns

`Token (/patitas/api/tokens/#Token)`

`_scan_directive_content`

0

`Iterator[Token (/patitas/api/tokens/#Token)]`

▼

Scan content inside a directive block.

**Handles:**
- Directive options (:key:…

`def _scan_directive_content(self) -> Iterator[Token]`

Scan content inside a directive block.

Handles:

- Directive options (:key: value)

- Nested directives (higher colon count)

- Closing fence (matching or higher colon count)

- All block-level elements (lists, headings, code, quotes, etc.)

- Regular content (paragraph lines)

##### Returns

`Iterator[Token (/patitas/api/tokens/#Token)]`
