-
Notifications
You must be signed in to change notification settings - Fork 55
Add documentation for --include-extended-types
and --help
flags.
#53
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f3c9a28
add documentation for the --include-extended-types flag
theMomax b58e28c
add documentation for how to access the --help flag
theMomax 61779b1
add 'Whats included' and 'Finding Extended Types' sections to Extende…
theMomax 1bdb8fe
implement review feedback
theMomax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...cumentation/SwiftDocCPlugin.docc/Generating Documentation for Extended Types.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Generating Documentation for Extended Types | ||
|
||
Generate documentation for the extensions you make to types from other modules. | ||
theMomax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Overview | ||
|
||
By default, the Swift-DocC plugin ignores extensions you make to types that are not from the module you're generating documentation for. | ||
|
||
To include documentation for extended types, add the `--include-extended-types` flag to your invocations: | ||
|
||
$ swift package generate-documentation --include-extended-types | ||
|
||
> Note: Extension support is available when using Swift 5.8 or later and the Swift-DocC plugin 1.2 or later. | ||
|
||
## Understanding What is Included by Default | ||
|
||
Not everything that is declared in an extension is hidden behind the `--include-extended-types` flag. If the extension is declared in the same target as the type it is extending, the extension's contents will be included in the documentation by default. | ||
|
||
```swift | ||
public struct Sloth { } | ||
|
||
extension Sloth { | ||
// This function is included in the | ||
// documentation by default. | ||
public func wake() { /* ... */ } | ||
} | ||
|
||
// `Collection` is from the standard library, | ||
// not the `SlothCreator` library, so this is | ||
// what we call an "extended type". | ||
extension Collection where Element == Sloth { | ||
// This property is not included in | ||
// the documentation by default. | ||
public func wake() { | ||
for sloth in self { | ||
sloth.wake() | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Finding Extended Types in your Documentation | ||
|
||
Extended Types are part of the documentation archive of the target that declares the extensions. | ||
|
||
 | ||
|
||
theMomax marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Within that documentation archive, Extended Types are grouped by the Extended Module they belong to. You can find the latter on your documentation's landing page in a section called "Extended Modules". In our example from above, we have one Extended Module called "Swift" - the name of the standard library. This page can be referenced like this: ` ``SlothCreator/Swift`` `. | ||
|
||
The Extended Type ` ``SlothCreator/Swift/Collection`` ` is a child of the Extended Module and is listed under "Extended Protocols" on the ` ``SlothCreator/Swift`` ` page. | ||
|
||
> Note: The references above use the full path, including the name of the catalog's target, `SlothCreator`. This should help to understand the symbol's exact location, but usually isn't necessary. | ||
|
||
<!-- Copyright (c) 2023 Apple Inc and the Swift Project authors. All Rights Reserved. --> |
Binary file added
BIN
+711 KB
...ocCPluginDocumentation/SwiftDocCPlugin.docc/Resources/extended-type-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+754 KB
...uginDocumentation/SwiftDocCPlugin.docc/Resources/extended-type-example~dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ following from the command-line: | |
|
||
$ swift package generate-documentation | ||
|
||
Use the `--help` flag to get a list of all supported arguments: | ||
|
||
$ swift package plugin generate-documentation --help | ||
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. I think this is worth leaving for legacy reasons but just FYI – this was fixed in a recent version of ArgumentParser that SwiftPM adopted and should be resolved in nightly toolchains. So soon just this will work:
|
||
|
||
The documentation on this site is focused on the Swift-DocC plugin specifically. For more | ||
general documentation on how to use Swift-DocC, see the documentation | ||
[here](https://www.swift.org/documentation/docc/). | ||
|
@@ -43,6 +47,7 @@ general documentation on how to use Swift-DocC, see the documentation | |
|
||
- <doc:Generating-Documentation-for-a-Specific-Target> | ||
- <doc:Previewing-Documentation> | ||
- <doc:Generating-Documentation-for-Extended-Types> | ||
|
||
### Publishing Documentation | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you; including a screenshot of an extended type or module could be nice so that you see how these extended types will show up in your docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍