📝 clarify formatter export docs

This commit is contained in:
Nanaloveyuki
2026-06-14 01:45:18 +08:00
parent 323d58059b
commit e53555edb2
2 changed files with 15 additions and 0 deletions
@@ -40,6 +40,7 @@ Detailed rules explaining key parameters and behaviors
- `pretty=false` returns compact JSON.
- `pretty=true` returns indented JSON for humans.
- This helper is built on top of `text_formatter_config_to_json(...)`.
- Internally it serializes the `JsonValue` result with `@json_parser.stringify(...)` or `@json_parser.stringify_pretty(value, 2)`, so the text form stays aligned with the structured formatter export helper.
- The output preserves the supported formatter config schema instead of any runtime-only formatter instance details.
### How to Use
@@ -73,3 +74,9 @@ e.g.:
- If `style_tags` is empty, the serialized text omits that field rather than forcing an empty object.
### Notes
1. Use this helper when the next consumer expects JSON text instead of `JsonValue`.
2. Use `text_formatter_config_to_json(...)` when you still need to embed formatter config inside a larger JSON object before final stringification.
@@ -36,6 +36,8 @@ Detailed rules explaining key parameters and behaviors
- The output includes visibility flags, separators, template, color settings, and markup settings.
- `style_tags` is exported only when the map is not empty.
- Enum-like formatter options are serialized using their stable label strings.
- `color_mode`, `color_support`, and the markup-mode fields are emitted through their label helpers, so the exported strings stay aligned with the parser-facing formatter config vocabulary.
- Nested `style_tags` entries are exported as plain JSON objects keyed by tag name, with each `TextStyle` rendered as structured config data rather than runtime registry state.
- The JSON shape matches the formatter section accepted by config parsing.
### How to Use
@@ -69,3 +71,9 @@ e.g.:
- If callers need immediate text output rather than a JSON value, they should use `stringify_text_formatter_config(...)` instead.
### Notes
1. Use this helper when you need a reusable JSON value rather than a final JSON string.
2. `sink_config_to_json(...)` reuses this helper for the nested `text_formatter` field.