# Feature tables in Peios documentation

_Peios Kernel / Administration / Tools_

> The feature parser and the data consumed by Peios's Trail renderer.

<a id="rst-documentation-features-parser-module"></a>

<!-- SPDX-License-Identifier: GPL-2.0 -->

Peios uses `feat.parse_features.ParseFeature` to read the architecture support
tables in `Documentation/features/`. The `kernel-feat` Trail plugin turns the
parsed records into Markdown. These tables describe support in the source tree;
they do not report which features are enabled in a particular Peios build.

The parser lives in `tools/lib/python/feat/parse_features.py`. The plugin entry
point and its renderer are `tools/docs/trail-kernel-doc/trail-kernel-feat` and
`feat_markdown.py` in the same directory. The entry point adds
`tools/lib/python/` to Python's module search path.

## Writing a feature table

To show the complete matrix, write this in a Trail article:

````markdown
```{kernel-feat} Documentation/features
```
````

To show one architecture, add `:arch: x86` inside the fence. The directory is
relative to the kernel source root configured for the plugin. The plugin rejects
unknown architecture names and directories with no feature records.

## Parser interface

```python
ParseFeature(prefix, debug=0, enable_fname=False)
```

`prefix` names the directory to scan. `debug` controls parser diagnostics;
`enable_fname` is used by the inherited text-output helpers. Peios constructs
the parser with debugging and filename output disabled, then calls `parse()`.

| Method | Behaviour |
|---|---|
| `parse()` | Recursively scans the directory, parses feature files and returns `self.data`. The root `arch-support.txt` template is excluded. |
| `parse_feat_file(fname)` | Reads one `arch-support.txt` file and adds its feature record to `self.data`. Directories and other filenames are skipped. |
| `parse_error(fname, ln, msg, data=None)` | Reports malformed input with its source location. Missing required fields prevent that record from being added. |

The returned dictionary is keyed by feature name. Each record contains:

| Key | Meaning |
|---|---|
| `where` | Source filename, also used for dependency tracking. |
| `subsys` | Subsystem name derived from the feature's directory path. |
| `kconfig` | Kconfig expression recorded by the source. |
| `description` | Short feature description. |
| `comments` | Additional source comments collected by the parser. |
| `table` | Architecture name to status string. The source marker `..` becomes `---`. |

Peios's renderer sorts and presents these records itself. The parser's
`output_arch_table()`, `output_feature()`, `output_matrix()` and related ReST
formatting helpers are not part of the Trail rendering path.

## Maintaining the integration

The plugin parses a given directory once per request and reuses its records
across matrix and architecture views. Its dependency response includes the
directory, the files represented by the records, and the parser and renderer
code. Tracking the directory lets Trail notice new feature files too.

When updating the parser, check the record keys above and both rendered views.
Changes to the architecture tables are documentation input changes; they do
not by themselves change Peios's kernel configuration.
