Skip to content

@returns and variant-field @param doc comments never reach code generators #809

Description

@bernardnormier

In the Compiler module, operation parameters, operation return fields, and variant enum fields are all represented as Field, which holds an EntityInfo, which in turn holds a comment: DocComment? field.

In Slice, doc comments cannot be written on these fields directly — they are written as @param/@returns tags on the enclosing operation or variant. slice_file_converter.rs bridges this for operation parameters: get_doc_comment_for_parameter finds the matching @param tag on the enclosing operation and synthesizes the parameter's entityInfo.comment from the tag's message, so code generators see parameter documentation without dealing with tag mechanics.

The other two Field contexts never get their entityInfo.comment filled:

  • Return fields: convert_operation converts the fields of returnType with the same convert_parameter used for parameters, but get_doc_comment_for_parameter searches only comment.paramscomment.returns is never consulted, so the comment stays unset and @returns messages are parsed, validated, and then dropped. Note ReturnsTag.identifier is optional: an unnamed @returns documents the operation's single return field.

  • Variant enum fields: the comment validator accepts @param on enumerators (only_operations_have_parameters allows Entities::Enumerator), but convert_field reads only the field's own comment, which inline variant fields never have — the variant's @param tags are dropped, so the positional record parameters generated for these fields have no documentation.

Both need the same treatment as operation parameters: synthesize the field's entityInfo.comment from the enclosing entity's tags. No change to the Compiler Slice definitions is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    slicecRelated to the 'slicec' crate

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions