mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Let's say I am a good citizen and document my private symbols:
/** My TOP SECRET DOCUMENTATION */
private class Foo {
}
When I go to distribute the compiled binary, I find out my private
documentation is distributed as well:
$ swiftc test.swift -emit-module -module-name "test"
$ strings test.swiftdoc
My TOP SECRET DOCUMENTATION
/** My TOP SECRET DOCUMENTATION */
If a client can't use a symbol (e.g. it's private [or internal and not
-enable-testing]) don't emit the documentation for a symbol in the
swiftdoc.
Fixes: SR-762, rdar://21453624
The test coverage implements this truth table:
| visibility | -enable-testing | documentation? |
|------------|-----------------|----------------|
| private | no | ❌ |
| internal | no | ❌ |
| public | no | ✅ |
| private | yes | ❌ |
| internal | yes | ✅ |
| public | yes | ✅ |
Modified the existing comments test coverage to expect non-public
documentation not to be emitted.
Don't rely on existing comment structure
Refuse to emit comments if the decl cannot actually have one. To
accomplish this, we move `canHaveComment` into the Decl instance. It
must also be marked `const`, since one of its existing usages operates
on a const pointer.
Perform fewer checks when serializing the standard library.
33 lines
1.3 KiB
Swift
33 lines
1.3 KiB
Swift
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t/comments.framework/Modules/comments.swiftmodule/
|
|
|
|
// RUN: %target-swift-frontend -module-name comments -emit-module -emit-module-path %t/comments.framework/Modules/comments.swiftmodule/%target-swiftmodule-name -emit-module-doc-path %t/comments.framework/Modules/comments.swiftmodule/%target-swiftdoc-name %s
|
|
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -F %t | FileCheck %s
|
|
|
|
// RUN: cp -r %t/comments.framework/Modules/comments.swiftmodule %t/comments.swiftmodule
|
|
// RUN: %target-swift-ide-test -print-module-comments -module-to-print=comments -source-filename %s -I %t | FileCheck %s
|
|
|
|
// XFAIL: linux
|
|
|
|
/// first_decl_class_1 Aaa.
|
|
public class first_decl_class_1 {
|
|
|
|
/// decl_func_1 Aaa.
|
|
public func decl_func_1() {}
|
|
|
|
/**
|
|
* decl_func_3 Aaa.
|
|
*/
|
|
public func decl_func_2() {}
|
|
|
|
/// decl_func_3 Aaa.
|
|
/** Bbb. */
|
|
public func decl_func_3() {}
|
|
}
|
|
|
|
// CHECK: Class/first_decl_class_1 RawComment=[/// first_decl_class_1 Aaa.\n]
|
|
// CHECK: Func/first_decl_class_1.decl_func_1 RawComment=[/// decl_func_1 Aaa.\n]
|
|
// CHECK: Func/first_decl_class_1.decl_func_2 RawComment=[/**\n * decl_func_3 Aaa.\n */]
|
|
// CHECK: Func/first_decl_class_1.decl_func_3 RawComment=[/// decl_func_3 Aaa.\n/** Bbb. */]
|
|
|