Skip to content

Commit ff0418a

Browse files
committed
itroduce brief section, use h3 headings for all section, remove rulers for highlighted commands
1 parent d77969f commit ff0418a

File tree

4 files changed

+34
-38
lines changed

4 files changed

+34
-38
lines changed

clang-tools-extra/clangd/Hover.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,12 @@ markup::Document HoverInfo::presentDoxygen() const {
15351535
SymbolDocCommentVisitor SymbolDoc(Documentation, CommentOpts);
15361536

15371537
if (SymbolDoc.hasBriefCommand()) {
1538+
if (Kind != index::SymbolKind::Parameter &&
1539+
Kind != index::SymbolKind::TemplateTypeParm)
1540+
// Only add a "Brief" heading if we are not documenting a parameter.
1541+
// Parameters only have a brief section and adding the brief header would
1542+
// be redundant.
1543+
Output.addHeading(3).appendText("Brief");
15381544
SymbolDoc.briefToMarkup(Output.addParagraph());
15391545
Output.addRuler();
15401546
}
@@ -1548,7 +1554,7 @@ markup::Document HoverInfo::presentDoxygen() const {
15481554
// Returns
15491555
// `type` - description
15501556
if (TemplateParameters && !TemplateParameters->empty()) {
1551-
Output.addParagraph().appendBoldText("Template Parameters:");
1557+
Output.addHeading(3).appendText("Template Parameters");
15521558
markup::BulletList &L = Output.addBulletList();
15531559
for (const auto &Param : *TemplateParameters) {
15541560
markup::Paragraph &P = L.addItem().addParagraph();
@@ -1562,7 +1568,7 @@ markup::Document HoverInfo::presentDoxygen() const {
15621568
}
15631569

15641570
if (Parameters && !Parameters->empty()) {
1565-
Output.addParagraph().appendBoldText("Parameters:");
1571+
Output.addHeading(3).appendText("Parameters");
15661572
markup::BulletList &L = Output.addBulletList();
15671573
for (const auto &Param : *Parameters) {
15681574
markup::Paragraph &P = L.addItem().addParagraph();
@@ -1581,7 +1587,7 @@ markup::Document HoverInfo::presentDoxygen() const {
15811587
if (ReturnType &&
15821588
((ReturnType->Type != "void" && !ReturnType->AKA.has_value()) ||
15831589
(ReturnType->AKA.has_value() && ReturnType->AKA != "void"))) {
1584-
Output.addParagraph().appendBoldText("Returns:");
1590+
Output.addHeading(3).appendText("Returns");
15851591
markup::Paragraph &P = Output.addParagraph();
15861592
P.appendCode(llvm::to_string(*ReturnType));
15871593

@@ -1595,7 +1601,7 @@ markup::Document HoverInfo::presentDoxygen() const {
15951601
}
15961602

15971603
if (SymbolDoc.hasDetailedDoc()) {
1598-
Output.addParagraph().appendBoldText("Details:");
1604+
Output.addHeading(3).appendText("Details");
15991605
SymbolDoc.detailedDocToMarkup(Output);
16001606
}
16011607

clang-tools-extra/clangd/SymbolDocumentation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,12 @@ class BlockCommentToMarkupDocument
339339
/// Emphasize the given command in a paragraph.
340340
/// Uses the command name with the first letter capitalized as the heading.
341341
void commandToHeadedParagraph(const comments::BlockCommandComment *B) {
342-
Out.addRuler();
343342
auto &P = Out.addParagraph();
344343
std::string Heading = B->getCommandName(Traits).slice(0, 1).upper() +
345344
B->getCommandName(Traits).drop_front().str();
346345
P.appendBoldText(Heading + ":");
347346
P.appendText(" \n");
348347
ParagraphToMarkupDocument(P, Traits).visit(B->getParagraph());
349-
Out.addRuler();
350348
}
351349
};
352350

clang-tools-extra/clangd/unittests/HoverTests.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,10 +3457,12 @@ template <typename T, typename C = bool> class Foo {}
34573457
```
34583458
34593459
---
3460+
### Brief
3461+
34603462
documentation
34613463
34623464
---
3463-
**Template Parameters:**
3465+
### Template Parameters
34643466
34653467
- `typename T`
34663468
- `typename C = bool`
@@ -3506,15 +3508,15 @@ ret_type foo(params) {}
35063508
```
35073509
35083510
---
3509-
**Parameters:**
3511+
### Parameters
35103512
35113513
-
35123514
- `type (aka can_type)`
35133515
- `type foo (aka can_type)`
35143516
- `type foo = default (aka can_type)`
35153517
35163518
---
3517-
**Returns:**
3519+
### Returns
35183520
35193521
`ret_type (aka can_ret_type)`)",
35203522
},
@@ -3649,7 +3651,7 @@ protected: size_t method()
36493651
```
36503652
36513653
---
3652-
**Returns:**
3654+
### Returns
36533655
36543656
`size_t (aka unsigned long)`)",
36553657
},
@@ -3688,7 +3690,7 @@ public: cls(int a, int b = 5)
36883690
```
36893691
36903692
---
3691-
**Parameters:**
3693+
### Parameters
36923694
36933695
- `int a`
36943696
- `int b = 5`)",
@@ -4001,10 +4003,12 @@ void foo()
40014003
```
40024004
40034005
---
4006+
### Brief
4007+
40044008
brief doc
40054009
40064010
---
4007-
**Details:**
4011+
### Details
40084012
40094013
longer doc)"},
40104014
{[](HoverInfo &HI) {
@@ -4036,15 +4040,17 @@ int foo()
40364040
```
40374041
40384042
---
4043+
### Brief
4044+
40394045
brief doc
40404046
40414047
---
4042-
**Returns:**
4048+
### Returns
40434049
40444050
`int`
40454051
40464052
---
4047-
**Details:**
4053+
### Details
40484054
40494055
longer doc)"},
40504056
{[](HoverInfo &HI) {
@@ -4105,38 +4111,36 @@ int foo(int a)
41054111
```
41064112
41074113
---
4114+
### Brief
4115+
41084116
brief doc
41094117
41104118
---
4111-
**Parameters:**
4119+
### Parameters
41124120
41134121
- `int a` - this is a param
41144122
41154123
---
4116-
**Returns:**
4124+
### Returns
41174125
41184126
`int` - it returns something
41194127
41204128
- `0` - if successful
41214129
- `1` - if failed
41224130
41234131
---
4124-
**Details:**
4132+
### Details
41254133
41264134
longer doc
41274135
4128-
---
41294136
**Note:**
41304137
this is a note
41314138
4132-
---
41334139
As you see, notes are "inlined".
41344140
4135-
---
41364141
**Warning:**
41374142
this is a warning
41384143
4139-
---
41404144
As well as warnings)"},
41414145
{[](HoverInfo &HI) {
41424146
HI.Kind = index::SymbolKind::Function;
@@ -4179,20 +4183,22 @@ int foo(int a)
41794183
```
41804184
41814185
---
4186+
### Brief
4187+
41824188
brief doc
41834189
41844190
---
4185-
**Parameters:**
4191+
### Parameters
41864192
41874193
- `int a` - this is a param
41884194
41894195
---
4190-
**Returns:**
4196+
### Returns
41914197
41924198
`int` - it returns something
41934199
41944200
---
4195-
**Details:**
4201+
### Details
41964202
41974203
longer doc)"},
41984204
};

clang-tools-extra/clangd/unittests/SymbolDocumentationTests.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,15 @@ Paragraph 1
218218
Paragraph 2)",
219219
R"(Paragraph 1
220220
221-
---
222221
\*\*Note:\*\*
223222
This is a note
224223
225-
---
226224
Paragraph 2)",
227225
R"(Paragraph 1
228226
229-
---
230227
**Note:**
231228
This is a note
232229
233-
---
234230
Paragraph 2)",
235231
R"(Paragraph 1
236232
@@ -253,19 +249,15 @@ Paragraph 1
253249
Paragraph 2)",
254250
R"(Paragraph 1
255251
256-
---
257252
\*\*Warning:\*\*
258253
This is a warning
259254
260-
---
261255
Paragraph 2)",
262256
R"(Paragraph 1
263257
264-
---
265258
**Warning:**
266259
This is a warning
267260
268-
---
269261
Paragraph 2)",
270262
R"(Paragraph 1
271263
@@ -281,12 +273,10 @@ Another paragraph)",
281273
R"(\*\*Note:\*\*
282274
this is not treated as brief
283275
284-
---
285276
Another paragraph)",
286277
R"(**Note:**
287278
this is not treated as brief
288279
289-
---
290280
Another paragraph)",
291281
R"(**Note:**
292282
this is not treated as brief
@@ -625,7 +615,6 @@ int function() { return 0; }
625615
R"(\*\*Note:\*\*
626616
Show that code blocks are correctly separated
627617
628-
---
629618
```
630619
/// Without the markdown preprocessing, this line and the line above would be part of the @note paragraph.
631620
@@ -636,7 +625,6 @@ int function() { return 0; }
636625
R"(**Note:**
637626
Show that code blocks are correctly separated
638627
639-
---
640628
```
641629
/// Without the markdown preprocessing, this line and the line above would be part of the @note paragraph.
642630
@@ -663,7 +651,6 @@ int function() { return 0; }
663651
R"(\*\*Note:\*\*
664652
Show that code blocks are correctly separated
665653
666-
---
667654
```
668655
/// Without the markdown preprocessing, this line and the line above would be part of the @note paragraph.
669656
@@ -674,7 +661,6 @@ int function() { return 0; }
674661
R"(**Note:**
675662
Show that code blocks are correctly separated
676663
677-
---
678664
```
679665
/// Without the markdown preprocessing, this line and the line above would be part of the @note paragraph.
680666

0 commit comments

Comments
 (0)