Proposal: Comment Attribution Rules for Symbol Declarations
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 15/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- documentation, tooling
調査の方向性
This is a design proposal, and the payload names no source files, tests, or entry points. Start by reading the six comments to see which rules (blank-line break, leading/inline/trailing priority, macro handling) are contested or already decided. Done means the maintainers have accepted or amended the rules, not that a patch exists; a newcomer should ask on the thread before doing anything else.
索引モデルが issue の本文から書いたものです。
説明
Summary
This proposal defines how llcppg decides which comment belongs to a C/C++ symbol declaration (type, func, var, field, enum, macro, etc.). It introduces three comment positions (leading, inline on the same line, and trailing on the following line), a strict blank-line rule that prevents misattribution, and a fixed priority order for picking the comment that ends up in the generated Go code. The same rules apply to every symbol kind, macros included.
Motivation
C/C++ headers document symbols in many different styles. Some put the comment above the declaration, some at the end of the same line, and some on the line below. Without a precise rule, a generator can:
- attach a comment to the wrong symbol (for example, the comment that actually documents the next declaration),
- drop comments that were clearly intended for a symbol, or
- behave inconsistently between symbol kinds.
A single, simple, predictable rule set makes the generated bindings' documentation reliable and makes the behavior easy to explain and test.
Terminology
Three comment positions are recognized relative to a declaration. The examples use gzgetc, but the rules apply to every symbol kind.
Leading comment — a comment immediately before the declaration:
// Read one byte, falling back to the real function.
int gzgetc(gzFile file);
Inline comment — a comment on the same line, after the declaration:
int gzgetc(gzFile file); // Read one byte, falling back to the real function.
Trailing comment — a comment on the line immediately after the declaration:
int gzgetc(gzFile file);
// Read one byte, falling back to the real function.
The three positions apply to macros in the same way:
#define Z_OK 0 // Operation succeeded.
Rule 1: A blank line breaks attribution
To avoid attributing a comment to the wrong symbol, a comment is associated with a declaration only if there is no blank line between them. If a blank line separates the comment from the declaration, the comment is not considered to belong to that declaration.
Both of the following declarations are treated as having no comment:
// Read one byte, falling back to the real function.
int gzgetc(gzFile file);
int gzgetc(gzFile file);
// Read one byte, falling back to the real function.
Rule 2: Resolution order
To obtain the comment for a symbol declaration:
- If a leading comment exists, use it.
- Otherwise, if an inline comment exists, use it.
- Otherwise, use the trailing comment, if any.
- If none of the above exist, the symbol has no comment.
| Symbol kind | Priority (highest first) |
|---|---|
| All symbols (including macros) | leading → inline → trailing |
Only one comment is chosen per symbol; lower-priority comments are ignored when a higher-priority one exists. For example, in:
// Leading doc.
int gzgetc(gzFile file); // Inline doc.
// Trailing doc.
the comment used for gzgetc is Leading doc..
Scope
The rules apply uniformly to all symbol kinds that llcppg converts, including:
- types (struct, union, typedef, class, and so on)
- functions and methods
- variables
- struct/class fields
- enums and enum members
- macros
Compatibility
Declarations that already use a leading comment with no blank line keep working exactly as before. Declarations whose comments are separated from them by a blank line will no longer pick up that comment, which is intentional: the blank line is the signal that the comment is not about this symbol.
Testing
Test cases should cover, for each applicable symbol kind (macros included):
- leading only, inline only, and trailing only
- each pairwise and the three-way combination, verifying the priority order
- a blank line between a comment and the declaration, on either side, resulting in no comment
- 主要言語
- Go
- スター
- 39
- フォーク
- 13
- 平均マージ
- 1時間 38分
- マージ済み PR(30日)
- 250
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goplus/llcppg のほかの issue
-
feature proposal
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
Proposal: `MethodPrefix` in llcppg.cfg対応中かも @luoliwoshang が今日担当しました。 オープンconfiguration
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
goplus/llcppg#1061 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
feature proposal
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:session-state issue-rating: 🦞 diamond lobster no-stale P2
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
openclaw/wacli#503 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 81/100
apache/rocketmq-dashboard#6895 ·
メンテナーはふだん 3 日以内に返信
-
agent-butler-finding chore
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jordansmall/spindrift#5466 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
open-telemetry/opentelemetry-go-compile-instrumentation#1507 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 87/100
777genius/agent-notifications#490 ·
メンテナーはふだん 1 日以内に返信