Skip to content

#78 feat: extract doc comments for OpenAPI descriptions#86

Closed
RAprogramm wants to merge 1 commit into77-http-handlersfrom
78-doc-comments
Closed

#78 feat: extract doc comments for OpenAPI descriptions#86
RAprogramm wants to merge 1 commit into77-http-handlersfrom
78-doc-comments

Conversation

@RAprogramm
Copy link
Owner

Summary

  • Add utils/docs.rs module for extracting doc comments from Rust attributes
  • Parse /// comments from entity structs and fields
  • Use entity doc comment as fallback for OpenAPI tag description

Usage

/// User account in the system.
///
/// Represents registered users with authentication info.
#[derive(Entity)]
#[entity(table = "users", api(tag = "Users"))]
pub struct User {
    #[id]
    pub id: Uuid,
    
    /// User's email address for authentication.
    #[field(create, update, response)]
    pub email: String,
}

In OpenAPI:

  • Tag description: "User account in the system.\n\nRepresents registered users..."
  • Field description: "User's email address for authentication."

Extracted Functions

  • extract_doc_comments(attrs) - Get full doc comment as string
  • extract_doc_summary(attrs) - Get first line only (for summaries)

Test plan

  • 6 unit tests for doc extraction
  • clippy clean
  • Format check
  • All 79 tests pass

Closes #78
Depends on #85

@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 90.82569% with 10 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ates/entity-derive-impl/src/entity/parse/entity.rs 50.00% 3 Missing ⚠️
...rates/entity-derive-impl/src/entity/parse/field.rs 50.00% 3 Missing ⚠️
crates/entity-derive-impl/src/utils/docs.rs 96.87% 3 Missing ⚠️
...rates/entity-derive-impl/src/entity/api/openapi.rs 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

- Add utils/docs.rs module for doc comment extraction
- Extract /// comments from entity struct for tag descriptions
- Extract /// comments from fields for schema descriptions
- Use entity doc as fallback for tag_description in OpenAPI
- 6 unit tests for doc extraction functions
@RAprogramm RAprogramm deleted the branch 77-http-handlers January 7, 2026 04:18
@RAprogramm RAprogramm closed this Jan 7, 2026
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.

1 participant