Nesting parameter/returns/throws doc comments for closure parameters

Under parameter doc comment list items, allow function doc comment
syntax to nest so you can document the meaning of closure parameters'
signatures.

rdar://problem/24794725
This commit is contained in:
David Farler
2016-04-10 15:32:07 -07:00
parent a9297eed9f
commit c20f3db09e
7 changed files with 170 additions and 62 deletions

View File

@@ -70,7 +70,7 @@ Optional<swift::markup::ParamField *> extractParamOutlineItem(
bool extractParameterOutline(
swift::markup::MarkupContext &MC, swift::markup::List *L,
SmallVectorImpl<const swift::markup::ParamField *> &ParamFields) {
SmallVectorImpl<swift::markup::ParamField *> &ParamFields) {
SmallVector<swift::markup::MarkupASTNode *, 8> NormalItems;
auto Children = L->getChildren();
if (Children.empty())
@@ -145,7 +145,7 @@ bool extractParameterOutline(
bool extractSeparatedParams(
swift::markup::MarkupContext &MC, swift::markup::List *L,
SmallVectorImpl<const swift::markup::ParamField *> &ParamFields) {
SmallVectorImpl<swift::markup::ParamField *> &ParamFields) {
SmallVector<swift::markup::MarkupASTNode *, 8> NormalItems;
auto Children = L->getChildren();
@@ -209,7 +209,7 @@ bool extractSeparatedParams(
bool extractSimpleField(
swift::markup::MarkupContext &MC, swift::markup::List *L,
DocComment::CommentParts &Parts,
swift::markup::CommentParts &Parts,
SmallVectorImpl<const swift::markup::MarkupASTNode *> &BodyNodes) {
auto Children = L->getChildren();
SmallVector<swift::markup::MarkupASTNode *, 8> NormalItems;
@@ -274,11 +274,11 @@ bool extractSimpleField(
return NormalItems.size() == 0;
}
static DocComment::CommentParts
static swift::markup::CommentParts
extractCommentParts(swift::markup::MarkupContext &MC,
swift::markup::MarkupASTNode *Node) {
DocComment::CommentParts Parts;
swift::markup::CommentParts Parts;
auto Children = Node->getChildren();
if (Children.empty())
return Parts;
@@ -289,7 +289,7 @@ extractCommentParts(swift::markup::MarkupContext &MC,
Parts.Brief = FirstParagraph;
SmallVector<const swift::markup::MarkupASTNode *, 4> BodyNodes;
SmallVector<const swift::markup::ParamField *, 8> ParamFields;
SmallVector<swift::markup::ParamField *, 8> ParamFields;
// Look for special top-level lists
size_t StartOffset = FirstParagraph == nullptr ? 0 : 1;
@@ -317,6 +317,11 @@ extractCommentParts(swift::markup::MarkupContext &MC,
Parts.BodyNodes = MC.allocateCopy(llvm::makeArrayRef(BodyNodes));
Parts.ParamFields = MC.allocateCopy(llvm::makeArrayRef(ParamFields));
for (auto Param : Parts.ParamFields) {
auto ParamParts = extractCommentParts(MC, Param);
Param->setParts(ParamParts);
}
return Parts;
}