Skip to content

Commit

Permalink
doc declarations for records
Browse files Browse the repository at this point in the history
Summary: as per title

Reviewed By: alanz

Differential Revision: D55917572

fbshipit-source-id: 1682bbc1f596f9c495764db42193f623828d3738
  • Loading branch information
perehonchuk authored and facebook-github-bot committed Apr 10, 2024
1 parent 96b5118 commit f3ae74c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions crates/elp/src/bin/glean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,14 +1032,27 @@ impl GleanIndexer {

for (rec, def) in def_map.get_records() {
let range = def.source(db).syntax().text_range();
let span = range.into();
declarations.push(Declaration::RecordDeclaration(
let text = &db.file_text(file_id)[range];
let text = format!("```erlang\n{}\n```", text);
let span: Location = range.into();

let decl = Declaration::RecordDeclaration(
RecordDecl {
name: rec.to_string(),
span: span.clone(),
}
.into(),
);

declarations.push(Declaration::DocDeclaration(
DocDecl {
target: Box::new(decl.clone()),
span,
text,
}
.into(),
));
declarations.push(decl);
}

if let Some((name, Some("hrl"))) = path.name_and_extension() {
Expand Down Expand Up @@ -1765,6 +1778,7 @@ mod tests {
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type/person/1/exported
-record(user, {name = "" :: string(), notes :: person(pos_integer())}).
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rec/user
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doc/-record(user, {name = "" :: string(), notes :: person(pos_integer())}).
foo() -> 1.
%% ^^^^^^^^^^^ func/foo/0/not_deprecated/exported
Expand Down

0 comments on commit f3ae74c

Please sign in to comment.