feat(view): M8 遮蔽呈现 — 描述为正文、实现为代码片、桩有徽章;并修复 view 解析模式回归
一、先修回归(用户看到"没渲染"的真因)
view 多处直接用 crate::parse::parse_source 重新解析文件,而 per-file markup:
是在 load 层生效的(M7)。于是任何带 markup: occlusion 的文档在结构区报
"parse/load error: expected ')' after link-index collection",退化成源码视图。
→ 新增 load::parse_source_auto(source):先读 frontmatter 的 markup:,用
with_markup 包住解析;view 的 4 处解析点全部改用。
二、遮蔽呈现
浏览视图(document.rs / /file):
<div class="doc-line doc-occl">
<span class="occl-pre">留存 =</span> ← 变量名 灰 等宽
<span class="occl-label">客户留存率,模拟数据</span> ← 描述 正文
<code class="occl-code">0.42</code> ← 实现 代码片
</div>
空载荷换成 <span class="occl-stub">桩</span> 琥珀徽章(title 说明未接通/待补返回值);
前缀的反引号与 ** 都剥掉,与其它行的 mq-anchor 一致。
卡片视图(render.rs / /debug):按 AST 匹配 Expr::Occluded(Assign/Expr/Return),
渲染 card occl-card:徽章「遮蔽」+ 变量名 + 描述 + 代码片/桩。
样式刻意不加虚线下划线(易读成链接):描述即正文,靠代码片边框区分。
验证:
- /file 页面 0 处 parse/load error;7 个遮蔽行全部渲染
(6 代码片 + 1 桩),文本抽取为「留存 = 客户留存率,模拟数据 [0.42]」
- 4 个单测(裸赋值/粗体赋值/空载荷+嵌套/非遮蔽不误判)
- 全量 cargo test --release 613 passed / 0 failed
未能截图:本机无任何浏览器,puppeteer 的 Chromium 下载被网络阻断;
改为 DOM 断言 + /.preview/occlusion.html 方案对照页由作者目视确认。
文档:doc/design/change-m8-view-occlusion.md
This commit is contained in:
1 parent
8c24d96626
commit
9015de26e5
7 files changed
+387
-4
No files matched your search
@@ -412,6 +412,49 @@ li.doc-list-meta {
|
||||
.doc-prose > :first-child { margin-top: 0; }
|
||||
.doc-prose > :last-child { margin-bottom: 0; }
|
||||
.doc-line { margin: 0.15rem 0; }
|
||||
/* `<TAB>` M8: occlusion statement — description reads as prose, payload as code.
|
||||
Stubs (empty payload) get a badge so "未接通" is visible at a glance. */
|
||||
.doc-occl {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
margin: 0.3rem 0;
|
||||
}
|
||||
.occl-pre {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.86em;
|
||||
color: var(--muted);
|
||||
}
|
||||
.occl-label {
|
||||
color: var(--ink);
|
||||
}
|
||||
.occl-code {
|
||||
font-family: var(--mono);
|
||||
font-size: 0.84em;
|
||||
color: var(--ink);
|
||||
background: var(--fill);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 6px;
|
||||
padding: 0.02rem 0.38rem;
|
||||
}
|
||||
.occl-card {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.occl-card .occl-label { font-weight: 500; }
|
||||
.occl-card .occl-code { font-size: 0.9em; }
|
||||
.occl-stub {
|
||||
font-size: 0.72em;
|
||||
line-height: 1.5;
|
||||
padding: 0.02rem 0.42rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 159, 10, 0.18);
|
||||
color: #9a5b00;
|
||||
border: 1px solid rgba(255, 159, 10, 0.35);
|
||||
}
|
||||
.doc-prose-line { white-space: pre-wrap; }
|
||||
.doc-stmt, .doc-call, .doc-cond {
|
||||
font-family: var(--mono);
|
||||
|
||||
Reference in new issue
Block a user