topmark.presentation.shared.config¶
topmark / presentation / shared / config
Shared data preparation for config CLI emitters.
This module contains Click-free helpers that prepare domain data for human-facing emitters (TEXT / MARKDOWN).
It intentionally sits between:
- configuration I/O helpers in
topmark.config.io, and - renderers in
topmark.presentation.text.config(ANSI) andtopmark.presentation.markdown.config(Markdown).
Notes
These helpers may perform light serialization work and may load bundled
template resources. They do not print to stdout/stderr; user-facing
warnings should be handled by the caller or the emitters.
Where human-facing config diagnostics are prepared, this module flattens
staged config-validation logs at the presentation boundary.
TEXT renderers may use verbosity_level and styled; Markdown renderers
treat Markdown as document-oriented output and ignore TEXT-only verbosity
and quiet controls.
ConfigInitHumanReport
dataclass
¶
Prepared payload for topmark config init (human formats).
Attributes:
| Name | Type | Description |
|---|---|---|
toml_text |
str
|
Starter configuration TOML text (annotated template). |
error |
Exception | None
|
Optional exception raised while reading the bundled template. When set, callers may render a warning and still proceed with the returned TOML text (which may be a synthesized fallback). |
verbosity_level |
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
styled |
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
ConfigDefaultsHumanReport
dataclass
¶
Prepared TOML payload for topmark config defaults.
This is the cleaned default configuration (copy/paste friendly).
Attributes:
| Name | Type | Description |
|---|---|---|
toml_text |
str
|
Cleaned TOML text. When prepared with |
verbosity_level |
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
styled |
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
ConfigCheckHumanReport
dataclass
¶
ConfigCheckHumanReport(
*,
config_files,
ok,
strict,
merged_toml,
counts,
diagnostics,
verbosity_level,
styled,
)
Prepared human-facing data for topmark config check.
Attributes:
| Name | Type | Description |
|---|---|---|
config_files |
list[str]
|
Config files contributing to the effective config (stringified paths). |
ok |
bool
|
Whether the configuration passed validation. |
strict |
bool
|
Whether strict checking was enabled. |
merged_toml |
str | None
|
Effective merged configuration as TOML, or None when not requested (typically only included at verbosity >= 2). |
counts |
HumanDiagnosticCounts
|
Human diagnostic counts. |
diagnostics |
list[HumanDiagnosticLine]
|
Human diagnostic lines (ordered). |
verbosity_level |
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
styled |
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
ConfigDumpHumanReport
dataclass
¶
ConfigDumpHumanReport(
*,
config_files,
merged_toml,
provenance_toml,
show_config_layers,
verbosity_level,
styled,
)
Prepared human-facing data for topmark config dump.
Attributes:
| Name | Type | Description |
|---|---|---|
config_files |
list[str]
|
Config files contributing to the effective config, rendered as stringified paths. |
merged_toml |
str
|
Final flattened effective configuration rendered as TOML. |
provenance_toml |
str | None
|
Optional layered TOML provenance export rendered as
TOML. When present, this is an inspection-oriented document whose
|
show_config_layers |
bool
|
Whether layered provenance output was requested. |
verbosity_level |
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
styled |
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
build_config_init_human_report ¶
Prepare human-facing data for topmark config init.
The annotated template is authored in plain topmark.toml shape. Template
edits therefore happen in that plain shape first:
- load the annotated template (or generated fallback)
- optionally set
[config].root = truein the plain template text - if
for_pyproject=True, nest the whole document under[tool.topmark] - validate the final output shape as a defensive backstop
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
for_pyproject
|
bool
|
If |
required |
root
|
bool
|
If |
required |
verbosity_level
|
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
required |
styled
|
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
required |
Returns:
| Type | Description |
|---|---|
ConfigInitHumanReport
|
Prepared TOML text plus optional template read error. |
Source code in src/topmark/presentation/shared/config.py
build_config_defaults_human_report ¶
Prepare human-facing data for topmark config defaults.
Renders the centralized default TopMark TOML document, optionally nests it under
[tool.topmark], then cleans it for copy/paste.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
for_pyproject
|
bool
|
If True, nest the TOML under |
required |
root
|
bool
|
If True, set |
required |
verbosity_level
|
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
required |
styled
|
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
required |
Returns:
| Type | Description |
|---|---|
ConfigDefaultsHumanReport
|
Prepared cleaned TOML text. |
Source code in src/topmark/presentation/shared/config.py
render_effective_config_toml ¶
Render the effective configuration plus runtime writer options as TOML.
FrozenConfig intentionally models the
layered TopMark configuration, while writer options are resolved from TOML
into runtime-facing state outside the immutable
FrozenConfig model.
Human-facing config reports still need to show the full effective TOML surface
authored by users, including the [writer] section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Effective runtime configuration to serialize. |
required |
writer_options
|
WriterOptions | None
|
Resolved runtime writer options to merge into the
exported TOML document, or |
required |
include_files
|
bool
|
Whether to include file-listing fields from |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Rendered TOML text containing the effective config-originating entries |
str
|
and, when present, the resolved |
Source code in src/topmark/presentation/shared/config.py
build_config_check_human_report ¶
build_config_check_human_report(
*,
config,
resolved_sources,
ok,
strict,
verbosity_level,
styled,
)
Prepare human-facing data for topmark config check.
This helper is Click-free and may perform light computation (counts, string normalization). It does not print.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Effective runtime configuration. |
required |
resolved_sources
|
ResolvedTopmarkTomlSources
|
Resolved sources (includes runtime options such as write options). |
required |
ok
|
bool
|
Whether the configuration passed validation. |
required |
strict
|
bool
|
Whether strict checking was enabled. |
required |
verbosity_level
|
int
|
Effective verbosity (used for gating heavy/verbose sections). |
required |
styled
|
bool
|
Whether to style text output (OutputFormat.TEXT) |
required |
Returns:
| Type | Description |
|---|---|
ConfigCheckHumanReport
|
Prepared config file list, optional merged TOML (verbosity > 1), plus |
ConfigCheckHumanReport
|
human diagnostic counts and lines derived from the flattened |
ConfigCheckHumanReport
|
compatibility view of staged config-validation logs. |
Source code in src/topmark/presentation/shared/config.py
build_config_dump_human_report ¶
build_config_dump_human_report(
*,
config,
resolved_toml,
show_config_layers,
verbosity_level,
styled,
)
Prepare human-facing data for topmark config dump.
This helper is Click-free: it performs TOML serialization for the flattened effective config and, when requested, also prepares a layered TOML provenance export.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FrozenConfig
|
Effective runtime configuration. |
required |
resolved_toml
|
ResolvedTopmarkTomlSources
|
Resolved TOML sources used to build the optional layered provenance export. |
required |
show_config_layers
|
bool
|
If |
required |
verbosity_level
|
int
|
Effective TEXT verbosity; Markdown renderers ignore it. |
required |
styled
|
bool
|
Whether TEXT renderers should apply styling; Markdown renderers ignore it. |
required |
Returns:
| Type | Description |
|---|---|
ConfigDumpHumanReport
|
Prepared config file list, flattened TOML text, and optional layered |
ConfigDumpHumanReport
|
TOML provenance export. |