Skip to content

Support doc comments on function parameters #1353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/loader/cmti.ml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ let rec read_core_type env container ctyp =
read_core_type env container t
#endif

let read_params env container ctyp =
let rec aux ctyp acc =
match ctyp.ctyp_desc with
| Ttyp_arrow (_, _, return_type) ->
let param_doc = Doc_attr.attached_no_tag ~warnings_tag:env.warnings_tag container
ctyp.ctyp_attributes
in
aux return_type ( param_doc.elements :: acc)
| _ -> List.rev acc
in
aux ctyp []

let read_value_description env parent vd =
let open Signature in
let id = Env.find_value_identifier env.ident_env vd.val_id in
Expand All @@ -166,12 +178,20 @@ let read_value_description env parent vd =
in
let doc = Doc_attr.attached_no_tag ~warnings_tag:env.warnings_tag container vd.val_attributes in
let type_ = read_core_type env container vd.val_desc in
let params_docs = read_params env container vd.val_desc in
let value =
match vd.val_prim with
| [] -> Value.Abstract
| primitives -> External primitives
in
Value { Value.id; source_loc; doc; type_; value }
Value
{
Value.id;
source_loc;
doc = { doc with elements = List.flatten (doc.elements :: params_docs) };
type_;
value
}

let read_type_parameter (ctyp, var_and_injectivity) =
let open TypeDecl in
Expand Down
Loading