Skip to content

Commit

Permalink
make sentences of synopsis and deprecated content: capitals and periods
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Oct 28, 2024
1 parent 00ff6ce commit e39433c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/lang/rascal/tutor/apidoc/ExtractInfo.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,33 @@ private Tree removeTags(Tree x) = visit(x) {
case Tags _ => (Tags) ``
};
@synopsis{Start synopsis' with capitals and end with periods.}
str sentenify(str synopsis:/^<head:[a-z]><tail:.*>/) = sentenify("<capitalize(head)><tail>");
str sentenify(str synopsis:/[^\.]$/) = sentenify("<synopsis>.");
default str sentenify(str x) = x;
str getSynopsis(rel[str, DocTag] tags) {
if (docTag(content=str docContents) <- tags["doc"]) {
if ([*_, /^.Synopsis\s+<rest:.*>$/, *str cont, /^.[A-Za-z].*$/, *str _] := split("\n", docContents)) {
return intercalate(" ", [rest, *cont]);
return sentenify(trim(intercalate(" ", [rest, *cont])));
}
else if ([*_, /^#+\s*Synopsis\s+<rest:.*>$/, *str cont, /^.[A-Za-z].*$/, *str _] := split("\n", docContents)) {
return intercalate(" ", [rest, *cont]);
return sentenify(trim(intercalate(" ", [rest, *cont])));
}
}
if (docTag(content=str docContents) <- tags["synopsis"]) {
if (docTag(content=str deprMessage) <- tags["deprecated"]) {
return "<trim(intercalate(" ", split("\n", docContents)))>
return "<sentenify(trim(intercalate(" ", split("\n", docContents))))>
'
':::warning
'**deprecated: marked for future deletion**
'<deprMessage>
'<sentenify(trim(deprMessage))>
':::
'";
}
else {
return trim(intercalate(" ", split("\n", docContents)));
return sentenify(trim(intercalate(" ", split("\n", docContents))));
}
}
Expand Down

0 comments on commit e39433c

Please sign in to comment.