-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[clangd] extend and rearrange doxygen hover documentation #152918
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1276,6 +1276,7 @@ std::optional<HoverInfo> getHover(ParsedAST &AST, Position Pos, | |
HI.Definition = | ||
URIForFile::canonicalize(Inc.Resolved, AST.tuPath()).file().str(); | ||
HI.DefinitionLanguage = ""; | ||
HI.IsIncludeDirective = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add a new item into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I did now. |
||
maybeAddUsedSymbols(AST, HI, Inc); | ||
return HI; | ||
} | ||
|
@@ -1504,41 +1505,103 @@ markup::Document HoverInfo::presentDoxygen() const { | |
Header.appendText(index::getSymbolKindString(Kind)).appendSpace(); | ||
assert(!Name.empty() && "hover triggered on a nameless symbol"); | ||
|
||
Header.appendCode(Name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW the |
||
if (IsIncludeDirective) { | ||
Header.appendCode(Name); | ||
|
||
if (!Definition.empty()) | ||
Output.addParagraph().appendCode(Definition); | ||
|
||
if (!UsedSymbolNames.empty()) { | ||
Output.addRuler(); | ||
usedSymbolNamesToMarkup(Output); | ||
} | ||
|
||
return Output; | ||
} | ||
|
||
if (!Definition.empty()) { | ||
Output.addRuler(); | ||
definitionScopeToMarkup(Output); | ||
} else { | ||
Header.appendCode(Name); | ||
} | ||
|
||
if (!Provider.empty()) { | ||
providerToMarkupParagraph(Output); | ||
} | ||
|
||
// Put a linebreak after header to increase readability. | ||
Output.addRuler(); | ||
// Print Types on their own lines to reduce chances of getting line-wrapped by | ||
// editor, as they might be long. | ||
if (ReturnType) { | ||
// For functions we display signature in a list form, e.g.: | ||
// → `x` | ||
// Parameters: | ||
// - `bool param1` | ||
// - `int param2 = 5` | ||
Output.addParagraph().appendText("→ ").appendCode( | ||
llvm::to_string(*ReturnType)); | ||
} | ||
|
||
SymbolDocCommentVisitor SymbolDoc(Documentation, CommentOpts); | ||
|
||
if (SymbolDoc.hasBriefCommand()) { | ||
SymbolDoc.briefToMarkup(Output.addParagraph()); | ||
Output.addRuler(); | ||
} | ||
|
||
// For functions we display signature in a list form, e.g.: | ||
// Template Parameters: | ||
// - `typename T` - description | ||
// Parameters: | ||
// - `bool param1` - description | ||
// - `int param2 = 5` - description | ||
// Returns | ||
// `type` - description | ||
if (TemplateParameters && !TemplateParameters->empty()) { | ||
Output.addParagraph().appendBoldText("Template Parameters:"); | ||
markup::BulletList &L = Output.addBulletList(); | ||
for (const auto &Param : *TemplateParameters) { | ||
markup::Paragraph &P = L.addItem().addParagraph(); | ||
P.appendCode(llvm::to_string(Param)); | ||
if (SymbolDoc.isTemplateTypeParmDocumented(llvm::to_string(Param.Name))) { | ||
P.appendText(" - "); | ||
SymbolDoc.templateTypeParmDocToMarkup(llvm::to_string(Param.Name), P); | ||
} | ||
} | ||
Output.addRuler(); | ||
} | ||
|
||
if (Parameters && !Parameters->empty()) { | ||
Output.addParagraph().appendText("Parameters:"); | ||
Output.addParagraph().appendBoldText("Parameters:"); | ||
markup::BulletList &L = Output.addBulletList(); | ||
for (const auto &Param : *Parameters) { | ||
markup::Paragraph &P = L.addItem().addParagraph(); | ||
P.appendCode(llvm::to_string(Param)); | ||
|
||
if (SymbolDoc.isParameterDocumented(llvm::to_string(Param.Name))) { | ||
P.appendText(" -"); | ||
P.appendText(" - "); | ||
SymbolDoc.parameterDocToMarkup(llvm::to_string(Param.Name), P); | ||
} | ||
} | ||
Output.addRuler(); | ||
} | ||
|
||
// Print Types on their own lines to reduce chances of getting line-wrapped by | ||
// editor, as they might be long. | ||
if (ReturnType && | ||
((ReturnType->Type != "void" && !ReturnType->AKA.has_value()) || | ||
(ReturnType->AKA.has_value() && ReturnType->AKA != "void"))) { | ||
Output.addParagraph().appendBoldText("Returns:"); | ||
markup::Paragraph &P = Output.addParagraph(); | ||
P.appendCode(llvm::to_string(*ReturnType)); | ||
|
||
if (SymbolDoc.hasReturnCommand()) { | ||
P.appendText(" - "); | ||
SymbolDoc.returnToMarkup(P); | ||
} | ||
Output.addRuler(); | ||
} | ||
|
||
// add specially handled doxygen commands. | ||
SymbolDoc.warningsToMarkup(Output); | ||
SymbolDoc.notesToMarkup(Output); | ||
|
||
// add any other documentation. | ||
SymbolDoc.docToMarkup(Output); | ||
|
||
Output.addRuler(); | ||
|
||
// Don't print Type after Parameters or ReturnType as this will just duplicate | ||
// the information | ||
if (Type && !ReturnType && !Parameters) | ||
|
@@ -1559,13 +1622,6 @@ markup::Document HoverInfo::presentDoxygen() const { | |
calleeArgInfoToMarkupParagraph(Output.addParagraph()); | ||
} | ||
|
||
SymbolDoc.docToMarkup(Output); | ||
|
||
if (!Definition.empty()) { | ||
Output.addRuler(); | ||
definitionScopeToMarkup(Output); | ||
} | ||
|
||
if (!UsedSymbolNames.empty()) { | ||
Output.addRuler(); | ||
usedSymbolNamesToMarkup(Output); | ||
|
@@ -1613,7 +1669,7 @@ markup::Document HoverInfo::presentDefault() const { | |
} | ||
|
||
if (Parameters && !Parameters->empty()) { | ||
Output.addParagraph().appendText("Parameters: "); | ||
Output.addParagraph().appendText("Parameters:"); | ||
markup::BulletList &L = Output.addBulletList(); | ||
for (const auto &Param : *Parameters) | ||
L.addItem().addParagraph().appendCode(llvm::to_string(Param)); | ||
|
Uh oh!
There was an error while loading. Please reload this page.