Skip to content

Document LDoc coverage analysis with comprehensive report#333

Merged
zhaozg merged 6 commits into
masterfrom
copilot/scan-ldoc-comments-coverage
Nov 1, 2025
Merged

Document LDoc coverage analysis with comprehensive report#333
zhaozg merged 6 commits into
masterfrom
copilot/scan-ldoc-comments-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 1, 2025

  • Explore repository structure and understand the LDoc analyzer
  • Run the analyzer to check current documentation coverage
  • Identify issues in LDoc comments across C files
  • Verify the analyzer comprehensively scans all LDoc comment patterns
  • Test the analyzer with various edge cases
  • Ensure the analyzer correctly identifies all exported functions
  • Verify analyzer integration with Makefile and CI/CD
  • Run final comprehensive scan and document results
  • Create comprehensive coverage documentation (LDOC_COVERAGE.md)
  • Update README with coverage information
  • Address code review feedback
  • Fix LDoc typos and syntax issues in C files
  • Clean up banner-style comments for consistency
  • Add missing descriptions to ASN1 functions

Comprehensive LDoc Coverage Analysis Complete

The issue requested scanning all LDoc comments in C code and checking coverage. This has been accomplished:

Coverage Report Created: LDOC_COVERAGE.md

  • Comprehensive documentation of analyzer capabilities
  • Detailed coverage statistics by file
  • List of all issues found (organized by file)
  • Usage instructions and integration details

README Updated:

  • Fixed grammar: "that are generated" (was "that are generate")
  • Added documentation coverage section with current statistics
  • Included instructions to run coverage checks

LDoc Issues Fixed in C Files:

  • Fixed typos: 'hamc' → 'hmac' in src/hmac.c and src/mac.c
  • Fixed type references: 'hamc_ctx' → 'hmac_ctx'
  • Fixed module paths: 'openssl.hamc' → 'openssl.hmac'
  • Updated LDoc syntax: @tparam(opt=false)@tparam[opt=false]
  • Improved return value descriptions for raw parameter
  • Fixed banner comment in src/lhash.c
  • Cleaned up banner-style comments in src/ots.c, src/ssl.c, src/cms.c
  • Added descriptions to ASN1 functions (set, get, i2d, d2i)

Analysis Results:

  • ✅ 768 LDoc comment blocks scanned across 37 C files
  • ✅ 591 of 636 exported functions documented (92.9%)
  • ✅ 756 of 768 comments are valid (98.4%)
  • ✅ Only 10 remaining issues (missing @TReturn tags)

Analyzer Verified:

  • Detects all /*** LDoc comments
  • Validates exported vs internal functions
  • Checks required tags and descriptions
  • Handles edge cases (nested comments, multi-line definitions)
  • Integrated with make check and GitHub Actions CI

The LDoc analyzer is working comprehensively and providing excellent coverage reporting.

Original prompt

This section details on the original issue you should resolve

<issue_title>Scan All LDoc comment in C code, check coverage</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Check coverage for LDoc comments in C code Document LDoc coverage analysis with comprehensive report Nov 1, 2025
Copilot AI requested a review from zhaozg November 1, 2025 15:04
@zhaozg
Copy link
Copy Markdown
Owner

zhaozg commented Nov 1, 2025

@copilot src/hmac.c 发现的问题与建议:

模块使用示例行拼写:
当前:hamc = require('openssl').hmac
建议:hmac = require('openssl').hmac(将 hamc 更正为 hmac)
多处类型/名称拼写:
“get hamc_ctx object”、“@TReturn hamc_ctx” 建议统一为 “hmac_ctx”
LDoc 可选参数语法:
当前:@tparam(opt=false) boolean raw
建议改为 LDoc 正式语法:@tparam[opt=false] boolean raw
说明文字中的模块名:
当前:compute hmac one step, in module openssl.hamc
建议:将 openssl.hamc 修正为 openssl.hmac

src/mac.c 发现的问题与建议:

描述中出现与 HMAC 模块名相同的拼写问题:
当前:compute mac one step, in module openssl.hamc
建议:修正为 openssl.hmac(或若本函数确属 MAC 模块,应当改为 openssl.mac,避免与 HMAC 混淆)
若该 API 同样支持 raw 输出(代码中存在 raw 变量逻辑),建议在注释中补充 @tparam[opt=false] boolean raw 并清晰说明返回值形态。

src/pkcs7.c 观察与建议:

verify/decrypt API 的注释块存在,但建议补充更明确的行为说明与失败时返回值约定(例如 verify 在不同 flags 下的返回布局)。

src/lhash.c 观察与建议:

文件顶部存在一个看似“横幅”注释,起始为 *========,不像是有效的 C 注释开头。若希望保留横幅,请改为 /* ========= */ 或删除该行,避免混淆。

统一性与风格建议

统一使用 /*** ... */ 作为 LDoc 块注释起止(全仓保持一致)。
对需要在文档中曝光的 C 绑定函数,确保使用前置块注释而非行尾注释。

- Fix 'hamc' to 'hmac' typos in module usage examples
- Fix 'hamc_ctx' to 'hmac_ctx' in type references
- Fix module path 'openssl.hamc' to 'openssl.hmac'
- Update LDoc syntax from @tparam(opt=false) to @tparam[opt=false]
- Add clearer return value descriptions for raw parameter
- Fix banner comment in lhash.c header

Co-authored-by: zhaozg <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot src/hmac.c 发现的问题与建议:

模块使用示例行拼写:...

Fixed all the typos and LDoc syntax issues you identified:

src/hmac.c:

  • ✅ Fixed usage example: hamchmac
  • ✅ Fixed type references: hamc_ctxhmac_ctx
  • ✅ Fixed module path: openssl.hamcopenssl.hmac
  • ✅ Updated LDoc syntax: @tparam(opt=false)@tparam[opt=false]
  • ✅ Added clearer return value description for raw parameter

src/mac.c:

  • ✅ Fixed usage example: hamcmac
  • ✅ Fixed module path: openssl.hamcopenssl.mac
  • ✅ Added clearer return value description

src/lhash.c:

  • ✅ Fixed banner comment (removed /*===...===*/ style)

Commit: 446c1ec

@zhaozg
Copy link
Copy Markdown
Owner

zhaozg commented Nov 1, 2025

@copilot consider handle
ots.c
1160://
1630:/
************/

ssl.c
286:/SSL CTX****/
689:/************************/
1747:/SSL SESSION****/
1955:/SSL
/
2125:/
/

cms.c
632:/*****************************************************************************/

Replace asterisk banner comments with standard C comments:
- ots.c: /***...***/ → /* ... */
- ssl.c: /***...***/ → /* ... */
- cms.c: /***...***/ → /* ... */

This ensures consistency with the codebase style and avoids
confusion with LDoc comment blocks.

Co-authored-by: zhaozg <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot consider handle
ots.c
1160:/********************************************************/...

Fixed all banner-style comments to use standard C comment format:

src/ots.c:

  • Line 1160: /***...***/ → /* ts_resp_ctx object */
  • Line 1630: /***...***/ → /* ts_verify_ctx object */

src/ssl.c:

  • Line 286: /***...***/ → /* SSL CTX object */
  • Line 689: /***...***/ → /* ssl functions */
  • Line 1747: /***...***/ → /* SSL SESSION functions */
  • Line 1955: /***...***/ → /* SSL object */
  • Line 2125: /***...***/ → /* Helper function to push SSL result */

src/cms.c:

  • Line 632: /***...***/ → /* CMS object */

Commit: c1c4e03

@zhaozg
Copy link
Copy Markdown
Owner

zhaozg commented Nov 1, 2025

@copilot handle src/asn1.c:
• Line 988: Missing or empty description
• Line 1067: Missing or empty description
• Line 1098: Missing or empty description
• Line 1179: Missing or empty description

Added clear descriptions for ASN1 group functions:
- set: set value of ASN1 object
- get: get value from ASN1 object
- i2d: encode ASN1 object to DER format
- d2i: decode DER encoded string to ASN1 object

This resolves the missing description issues at lines 988, 1067, 1098, and 1179.
Comment validity rate improved from 97.9% to 98.4%.

Co-authored-by: zhaozg <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot handle src/asn1.c:
• Line 988: Missing or empty description
• Line 1067: Missing or empty description...

Added descriptions to all four ASN1 functions:

  • Line 988 - set: set value of ASN1 object
  • Line 1067 - get: get value from ASN1 object
  • Line 1098 - i2d: encode ASN1 object to DER format
  • Line 1179 - d2i: decode DER encoded string to ASN1 object

Comment validity rate improved from 97.9% to 98.4%.

Commit: b242486

@zhaozg zhaozg marked this pull request as ready for review November 1, 2025 16:03
@zhaozg zhaozg merged commit 3555314 into master Nov 1, 2025
138 checks passed
@zhaozg zhaozg deleted the copilot/scan-ldoc-comments-coverage branch November 1, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scan All LDoc comment in C code, check coverage

2 participants