Repository navigation
docs(spec): add expression specification aligned with dev @ 3b84ef2 - #54
hydroroll-bot wants to merge 2 commits into
Conversation
Add docs/source/expression-spec.rst and hook it into the documentation toctree. The spec is written against the files at 3b84ef2 (grammar.pest, calculator.rs, errors.rs, tests/conformance/v1.json) rather than from memory, and marks every rule as implemented or 未实现(issue #N). Corrections made during review of the first draft: - 3.4 and 4.4 share one 15-row modifier set and order - 1d1! follows the explode loop -> limit.generated_values, not total = 1 - no unverified spaced-dice example; the whitespace rule is stated only at the lexical level and flagged for a conformance case - section 3.2 defines factor for both 1.x (dice_term) and v2 (primary) - 4.2 maps every DiceError to Python ValueError via From<DiceError> for PyErr - only real files referenced; 0001-v2-target.pest is documented as an attachment of RFC-0001, not a separate proposal - issue numbers checked against the tracker - no scrape date in the header, only dev @ 3b84ef2
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis documentation-only PR adds a source-aligned, 1041-line expression specification covering current 1.x behavior and proposed v2 syntax/semantics, with implementation status, issue links, examples, edge cases, and review provenance, then links it from the main documentation index. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
f776394 to
34d3a06
Compare
中文正文里的行内标记(``代码``、**粗体**、:doc:`...`)紧贴汉字或全角标点时 docutils 不认边界,``sphinx-build -W`` 因此报 31 条 warning,CI 的 Quality job 直接失败。逐处补 ``\ `` 转义空格,并顺带处理三类别的问题: - 行内标记不能嵌套(reST 的限制),把 ``**``1.x``:…**`` 这类改成两个标记 相邻但不嵌套的写法; - 行内字面量不能跨行,把跨行的 ``schema_version = "2.0"`` 收进同一行; - 以空白开头/结尾的字面量(`` 1d1 ``)无法用 `` `` `` 表示,改成 ``1d1``(首尾带空格)并在期望列写明首尾空白忽略。 标题下划线按 docutils 的 column_width 补齐。本地 ``sphinx-build -W`` 现在 零 docutils 警告,只剩 intersphinx 拉不到 objects.inv 的网络警告(沙箱无外网)。
|
@HsiangNianian 看了一下你贴的 job(Quality / 失败原因
这次改了什么(只动这一个文件,198 行)
验证
说明
按审查意见追加了 1 个提交(docs(spec): fix reST inline markup so the docs build passes -W)。 |
|
渲染pdf发到群里
krypton ***@***.***> 于2026年10月22日周四 10:52写道:
… *hydroroll-bot* left a comment (HydroRoll-Team/OneRoll#54)
<#54 (comment)>
@HsiangNianian <https://github.com/HsiangNianian> 看了一下你贴的 job(Quality / sphinx-build
-W --keep-going),失败原因是文档警告,不是代码问题。已在分支上改好并重跑。
失败原因
docs/source/expression-spec.rst 是中文正文,行内标记紧贴汉字或全角标点时 docutils 不认边界:
expression-spec.rst:30: WARNING: Inline strong start-string without end-string.
expression-spec.rst:174: WARNING: Inline literal start-string without end-string.
... 共 31 条 docutils 警告 + 1 条 Title underline too short
-W 把它们当错误,job 就红了。另外还有一批「没报 warning 但实际渲染坏了」的地方:-W
只在部分情况下报警,另一批行内字面量直接被当成普通文本,页面上会露出原始的 `` 反引号(本地对比旧构建和新构建,旧版正文里有 71
处这样的裸反引号)。
这次改了什么(只动这一个文件,198 行)
1. 逐处补 \ 转义空格,让标记边界成立:**已实现**\ :、语料 ``id``\ 。、(\ ``x``\ )。
2. 行内标记不能嵌套(reST 本身的限制,**``1.x``:…** 这类会退化成纯文本),改成两个标记相邻、不嵌套的写法,例如
- 3. **issue 归属**(``values_list``)\ :…
- 1. **逐骰、按源码顺序处理全部修饰符**(``!`` / ``e``)\ :…
- **``1.x``**:单层… → 1.x\ :**单层、左结合,已实现**\ 。
只调整了强调的范围,句子意思和术语没变。
3. 行内字面量不能跨行:把跨行的 schema_version = "2.0" 收进同一行(顺便重排了那一段的折行)。
4. * - `` 1d1 `` 这种以空白开头/结尾的字面量没法用 表示,改成 `1d1``\
(首尾带空格)`,期望列本来就写着「首尾空白忽略」。
5. 三处标题下划线按 docutils 的 column_width 补长(含全角字符时一个汉字算两格)。
验证
uv sync --all-groups --frozen
uv run --frozen sphinx-build -W --keep-going -b html docs/source docs/_build/html
- docutils 警告:0(改之前 32 条)。
- 只剩一条 failed to reach any of the inventories …
docs.python.org/objects.inv——我这个环境没有外网,requests.exceptions.ProxyError;CI
有网,这条不会出现。
- 渲染结果对照旧构建:裸反引号和裸 ** 已经没有了(剩下的 ** 都是 2 ** 3、** 这类字面量内容,正常)。
- uv run --frozen ruff check .:All checks passed。
说明
- 转义空格在页面上会占一个空格(( 3b84ef2 ) 这种),这是 reST +
中文的固有毛病,不是排版失误;如果不想看到这些空格,只能给 docutils 开 character_level_inline_markup
或改文案语序,那属于另一件事,这次没动。
- 没有为了凑 80 列重新折行,避免在 \ 边界处断行产生新问题;改动行长略增(最多 82 列,原文件本来就有 109 列的行)。
- 如果 CI 还红,麻烦再贴一下 job 链接,我按日志继续。
按审查意见追加了 1 个提交(docs(spec): fix reST inline markup so the docs build passes
-W)。
—
Reply to this email directly, view it on GitHub
<#54?email_source=notifications&email_token=AKVETAGD6X4T2MPWJK54E2D5VFY63A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMZTGE2TANZZGIZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6331507923>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKVETAEGK5B3HCJYQAXJLDT5VFY63AVCNFSNUABGKJSXA33TNF2G64TZHMYTANJVGAZDIMZQHE5US43TOVSTWNJZG4YTONJVGYZTTILWAI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
PDF 版本已经出好了,交付说明同步在这里。 成品压缩包在群里发了:
封面、带页码的目录、每章另起一页都有;目录和交叉引用可点击跳转,书签按「章 / 节」两层生成。 生成方式不是 LaTeX 排版,是 HTML 转打印: 把各页正文按 toctree 顺序拼成一个文档,再交给无头 Chrome 按 A4 打印成 PDF。 已知限制
要是希望把这条 PDF 流水线固化进 CI(比如 release 时自动产出一份),可以另开 issue,我再按流程提。 |
内容
新增
docs/source/expression-spec.rst(1042 行),挂进docs/source/index.rst的 toctree。一套语法:1.x现行语法为正文正式定义,2.0新特性并入同一套词法/产生式/语义章节,每项标「已实现」或「未实现(issue #N)」。体例:词法表、优先级表、pest PEG 产生式、错误码表、示例带期望结果。对上一轮审查意见的回应
docs/rfcs/0001-v2-target.pest是否存在:存在,且是 0001 号提案的附件(git cat-file -e 3b84ef2:docs/rfcs/0001-v2-target.pest通过;git ls-files docs/rfcs可见 0001–0006 各提案及其附件.pest/.json/.pyi)。docs/rfcs下确实只有 0001–0006 六份提案。已在「写法约定」里写明这是 0001 的附件、不是另一份 RFC,避免误读。1 d 6:已从 3.3 与第 7 节示例表删除,不再给「等价 1d6」的推导结论;3.3 只陈述词法规则(silentWHITESPACE、number/dice_sides为 atomic),并把「空白宽容度需补 conformance 用例」列入第 9 节 TODO 与本文末尾遗留项。核对来源(dev @ 3b84ef2)
src/oneroll/grammar.pest、docs/rfcs/0001-v2-target.pest、src/calculator.rs、src/errors.rs、tests/conformance/v1.json(46 条单表达式 + 5 条 program 用例)、issue tracker。引用的 #3/#7/#15/#16/#24/#26/#29/#37–#43/#51 均为真实 issue,标题已比对。关键修正
! e K r ro R a k kh kl dh dl u s c),4.4 同序同名;已用脚本比对两表 15 行一致。1d1!:按while roll == sides循环,1 == 面数 1,会一直重掷到预算耗尽 →limit.generated_values(语料explode_budget),不是total = 1;1d1e、1d1R1同理。dice_term(已实现)与 v2 的primary(silent,未实现 Implement v2 Pratt precedence and canonical expressions #16);1 + 2 * 3在 1.x 为 9,v2 分层为 7,标为不兼容变更。impl From<DiceError> for pyo3::PyErr写明所有DiceError统一转ValueError(附_oneroll_error_json),typed hierarchy 归 Map domain errors to a typed Python exception hierarchy #26。& ^ |为逻辑与/异或/或(Evaluate scoped validator expressions across filters and roll options #41 未实现),与 1.x 的^幂无关。已实现 / 未实现对 issue
K的已知偏差已记录:calculator.rs里K只取高 n、不 explode,语料keep_and_explode_incomplete以known_defect固定(#24)。待拍板
!/R无次数上限,只能靠预算终止;可精确分析的范围需先定。0001-v2-target.pest为准,若 Reconsider v2 surface syntax for non-code hosts and LLM tool-call recall #51 改动则 3.5/4.5/5.2 同步。values_list([1,2])无独立 issue 归属,标 TODO。后续细节讨论会开 tracking issue,PR 随讨论同步更新;草稿状态,不合并。
验证
total与v1.json、错误码集合与errors.rs、引用语料 id 是否存在;git diff --check、UTF-8、无 tab。cargo test(无 crates 缓存/网络)、sphinx-build -W(无 sphinx/docutils)、python -m unittest(缺oneroll扩展与jsonschema)。CI docs workflow 若报 RST 告警会跟进修。交付回执
dev(基于3b84ef2)9ea2adb93b539b84f80ef00c8b80a1fea93f74d8values_list的 issue 归属 TODO;③1d1!期望依赖默认generated_values = 10000的预算实现,未实跑;④ 文档未经sphinx-build -W构建。由 Krypton(hydroroll-bot)应群里可信成员的请求自动生成,是草稿,需要人审查后再合并。
Summary by Sourcery
Document the expression language and its planned evolution with an implementation-aligned specification.
Enhancements:
Documentation: