Files
MeshTerm/meshterm/tools/about.py
T
Jean-Pierre MartineauandClaude Opus 5 0314ed7702 About pages: prose the app writes, not rows it composes
The three About pages were scaffolding built out of Text() calls, which
made writing them a Python edit and capped what they could ever say. They
are markdown now — meshterm/assets/pages/*.md, drawn by ui/markdown.py
into the app's own language rather than markdown's: # the page's name in
brand, ## a section in the body accent (with the muted · aside), ###
indented with its prose, paragraphs and lists hanging as blocks, quotes
and fences behind a rail that survives wrapping, tables through Rich, and
links that say where they go — nothing is clickable on a framebuffer
console. Two paragraphs are page frame rather than body and sit flush and
muted: the standfirst under the title, the colophon under the closing
rule, which is where the copyright lands.

The pages stay scaffolded on purpose — the placeholders are unchanged —
but filling one in is now editing its .md, and the live package facts
arrive as {version}/{author}/{copyright} so a page still can't drift from
the build it describes.

Being a document earns the screen two things a block never had: its ##
headings are landmarks, so a heading pins while its own prose scrolls
under it and ^PgUp/^PgDn step by them, and the console lane claims
Sect ↑/Sect ↓ on the free F1/F2 pair once a page has more than one
section — dimmed while the whole page fits, since the lane never
advertises a dead key.

Parsing is markdown-it-py (already under Rich, now declared): a real
CommonMark parser, so an author writes ordinary markdown. The md.* styles
are defined in both themes; the new test renders the whole vocabulary at
53 cells and asserts it stays inside the console font and the 16 slots.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 17:39:21 -04:00

132 lines
4.4 KiB
Python

"""The About MeshTerm tools: the three pages under the menu's last section.
*About MeshTerm*, *About the author*, *Support this project* — in that order, which is
the order a stranger asks the questions in: what is this, who made it, how do I help.
Each is a page rather than a feature: it reads nothing, transmits nothing, and needs no
device, so it opens straight to its screen (see :mod:`meshterm.ui.about`) instead of
prompting for anything first.
Each also keeps a CLI face — ``meshterm about``, ``meshterm about-author``,
``meshterm support`` — printing the same page to the terminal, so the answers are
reachable from a shell without launching the full-screen session.
The pages themselves are written in markdown under ``meshterm/assets/pages`` (see
:mod:`meshterm.ui.about`); nothing here knows what any of them say.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from ..context import AppContext
from .base import Tool, ToolResult, register
if TYPE_CHECKING:
from ..ui.markdown import MarkdownDoc
class _AboutTool(Tool):
"""Shared behaviour for the three About pages: open the screen, or print the page.
The pages differ only in their title, icon, and content, so everything else — the
menu-only screen open, the printing CLI face, the run row — lives here once. A
subclass supplies :meth:`page`, and nothing more.
"""
category = "About MeshTerm"
@staticmethod
def page() -> "MarkdownDoc":
"""Build this page's content.
Overridden by each page. Subclasses import their builder *inside* the override
rather than at module scope: the registry imports every tool module at startup
(see :func:`~meshterm.tools.load_all_tools`), and a page's content is only ever
wanted once someone actually opens it.
"""
raise NotImplementedError
async def prompt_params(self, ctx: AppContext) -> Optional[dict[str, Any]]:
"""Open the page; returning ``None`` completes the invocation with no run row.
The page transmits nothing and stores nothing, so — like the Trophy case and the
mesh walk — it lives here rather than in :meth:`run`, and logs no run of its own.
Args:
ctx: Shared application context.
Returns:
Always ``None``.
"""
from ..ui.about import open_about_page
await open_about_page(ctx, self.title, self.page())
return None
async def run(self, ctx: AppContext, params: dict[str, Any]) -> ToolResult:
"""Print the page — only reachable from the CLI (the menu opens the screen).
Args:
ctx: Shared application context.
params: Unused beyond the injected ``_run_id``.
Returns:
A :class:`ToolResult` naming the page that was shown.
"""
ctx.ui.show(self.page())
return ToolResult(summary={"page": self.name})
@register
class AboutMeshTermTool(_AboutTool):
"""What MeshTerm is, where it came from, and the terms it ships under."""
name = "about"
title = "About MeshTerm"
icon = "📖"
help = "What this is, where it came from, and the terms it ships under"
order = 10 # the question a stranger asks first
@staticmethod
def page() -> "MarkdownDoc":
"""The *About MeshTerm* page."""
from ..ui.about import about_meshterm
return about_meshterm()
@register
class AboutAuthorTool(_AboutTool):
"""The person behind MeshTerm, on the mesh and off it."""
name = "about-author"
title = "About the author"
icon = "👤"
help = "The person behind MeshTerm, on the mesh and off it"
order = 20 # who made the thing you just read about
@staticmethod
def page() -> "MarkdownDoc":
"""The *About the author* page."""
from ..ui.about import about_author
return about_author()
@register
class SupportProjectTool(_AboutTool):
"""What keeps MeshTerm going, and the ways — paid and unpaid — to help it along."""
name = "support"
title = "Support this project"
icon = "💰"
help = "What keeps MeshTerm going, and the ways to help it along"
order = 30 # the ask, and only once the first two have earned it
@staticmethod
def page() -> "MarkdownDoc":
"""The *Support this project* page."""
from ..ui.about import support_project
return support_project()