Improve TOML placeholder parser error messages
まだ誰も着手していません。
評価
調査の方向性
Start in hexdoc/utils/deserialize/toml.py, where the traceback shows placeholder expansion reaches _expand_placeholder and raises IndexError. Read the placeholder parsing and expansion flow, then check for related tests in the repository. Done means invalid placeholder references produce a clear parser error instead of this raw index error; no test file is named in the issue.
索引モデルが issue の本文から書いたものです。
説明
For example, when a placeholder key contains too many parent references, this is the current error message:
─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\cli\app.py:186 in build │
│ │
│ 183 │ For developers: returns the site path (eg. `/v/latest/main`). │
│ 184 │ """ │
│ 185 │ │
│ ❱ 186 │ props, pm, book_plugin, plugin = load_common_data(props_file, branch) │
│ 187 │ │
│ 188 │ if props.env.hexdoc_subdirectory: │
│ 189 │ │ output_dir /= props.env.hexdoc_subdirectory │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\cli\utils\load.py:55 in load_common_data │
│ │
│ 52 │ *, │
│ 53 │ book: bool = False, │
│ 54 ) -> tuple[Properties, PluginManager, BookPlugin[Any], ModPlugin]: │
│ ❱ 55 │ props = Properties.load(props_file) │
│ 56 │ pm = PluginManager(branch, props) │
│ 57 │ │
│ 58 │ book_plugin = pm.book_plugin(props.book_type) │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\core\properties.py:175 in load │
│ │
│ 172 │ def load(cls, path: Path) -> Self: │
│ 173 │ │ return cls.load_data( │
│ 174 │ │ │ props_dir=path.parent, │
│ ❱ 175 │ │ │ data=load_toml_with_placeholders(path), │
│ 176 │ │ ) │
│ 177 │ │
│ 178 │ @classmethod │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\utils\deserialize\toml.py:135 in │
│ load_toml_with_placeholders │
│ │
│ 132 │
│ 133 def load_toml_with_placeholders(path: Path) -> TOMLDict: │
│ 134 │ data = tomllib.loads(path.read_text("utf-8")) │
│ ❱ 135 │ fill_placeholders(data) │
│ 136 │ return data │
│ 137 │
│ 138 │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\utils\deserialize\toml.py:34 in │
│ fill_placeholders │
│ │
│ 31 │
│ 32 │
│ 33 def fill_placeholders(data: TOMLDict): │
│ ❱ 34 │ _fill_placeholders(data, [data], set()) │
│ 35 │
│ 36 │
│ 37 def _expand_placeholder( │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\utils\deserialize\toml.py:130 in │
│ _fill_placeholders │
│ │
│ 127 ): │
│ 128 │ table = stack[-1] │
│ 129 │ for key, child in table.items(): │
│ ❱ 130 │ │ _handle_child(data, stack, expanded, key, child, table.__setitem__) │
│ 131 │
│ 132 │
│ 133 def load_toml_with_placeholders(path: Path) -> TOMLDict: │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\utils\deserialize\toml.py:113 in │
│ _handle_child │
│ │
│ 110 │ │ case list(): │
│ 111 │ │ │ # handle each item in the list without adding the list to the stack │
│ 112 │ │ │ for i, item in enumerate(value): │
│ ❱ 113 │ │ │ │ _handle_child(data, stack, expanded, i, item, value.__setitem__) │
│ 114 │ │ │
│ 115 │ │ case dict(): │
│ 116 │ │ │ # recursion! │
│ │
│ E:\Projects\Complex-Hex\.venv\Lib\site-packages\hexdoc\utils\deserialize\toml.py:89 in │
│ _handle_child │
│ │
│ 86 │ │ │ # fill the string's placeholders │
│ 87 │ │ │ for match in reversed(list(_PLACEHOLDER_RE.finditer(value))): │
│ 88 │ │ │ │ try: │
│ ❱ 89 │ │ │ │ │ v = _expand_placeholder( │
│ 90 │ │ │ │ │ │ data, │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range
- 主要言語
- Python
- スター
- 7
- フォーク
- 10
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hexdoc-dev/hexdoc のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
hexdoc-dev/hexdoc#109 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
hexdoc-dev/hexdoc#108 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hexdoc-dev/hexdoc#90 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
hexdoc-dev/hexdoc#107 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
hexdoc-dev/hexdoc#106 ·
hexdoc-dev/hexdoc の issue をすべて見る
似ている issue
-
comp/tools P2 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#142908 · コメント 1 件 ·
-
[oblt-aw][autodoc] Fix malformed headings in new Buildkite docs pages対応中かも @github-actions が今日担当しました。 オープンdocumentation
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: fileUploadMatrix.test.ts URL case does a real DNS lookup and fails offline対応中かも @r2jaff が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ComposioHQ/composio#5054 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pytorch/tensordict#3286 ·
メンテナーはふだん 1 日以内に返信