Files
swift-mirror/include/swift/SymbolGraphGen/DocumentationCategory.h
QuietMisdreavus f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00

49 lines
1.3 KiB
C++

//===--- DocumentationCategory.h - Accessors for @_documentation ----------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2022 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SYMBOLGRAPHGEN_DOCUMENTATIONCATEGORY_H
#define SWIFT_SYMBOLGRAPHGEN_DOCUMENTATIONCATEGORY_H
#include "swift/AST/Decl.h"
#include "llvm/Support/Compiler.h"
namespace swift {
namespace symbolgraphgen {
LLVM_ATTRIBUTE_USED
static StringRef documentationMetadataForDecl(const Decl *D) {
if (!D) return {};
if (const auto *DC = D->getAttrs().getAttribute<DocumentationAttr>()) {
return DC->Metadata;
}
return {};
}
LLVM_ATTRIBUTE_USED
static Optional<AccessLevel> documentationVisibilityForDecl(const Decl *D) {
if (!D) return None;
if (const auto *DC = D->getAttrs().getAttribute<DocumentationAttr>()) {
return DC->Visibility;
}
return None;
}
} // namespace symbolgraphgen
} // namespace swift
#endif // SWIFT_SYMBOLGRAPHGEN_DOCUMENTATIONCATEGORY_H