-
Notifications
You must be signed in to change notification settings - Fork 164
Emit symbol URL to link to declaration in repo #256
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
Conversation
e41b21d to
7f2be93
Compare
c8d7958 to
250f73c
Compare
3d304d2 to
b7121f5
Compare
|
@swift-ci please test |
b7121f5 to
6c429b9
Compare
|
@swift-ci please test |
21c5978 to
2c432e3
Compare
|
@swift-ci please test |
2c432e3 to
f75f8ba
Compare
|
@swift-ci please test |
f75f8ba to
44f6cc7
Compare
|
@ethan-kusters Did you have a chance to take a look at this? The DocC Render PR is moving forward swiftlang/swift-docc-render#366 (review) |
| /// Whether the documentation converter should include access level information for symbols. | ||
| let shouldEmitSymbolAccessLevels: Bool | ||
|
|
||
| /// The source repository where the documentation's sources are hosted. |
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.
| /// The source repository where the documentation's sources are hosted. | |
| /// The online source control repository where the documentation's source is hosted. |
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.
Good idea, I clarified this.
| /// The variants for the source file URI of a page. | ||
| public var sourceFileURIVariants: VariantCollection<String?> = .init(defaultValue: nil) | ||
|
|
||
| /// The source location of the topic's source code. |
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.
| /// The source location of the topic's source code. | |
| /// The source location of the topic's declaration. |
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.
I renamed this property and updated the documentation comment:
/// The remote location where the source declaration of the topic can be viewed.
public var remoteSource: RemoteSource? {| } | ||
|
|
||
| /// Describes the location of the topic's source code, hosted by a source service. | ||
| public struct Source: Codable, Equatable { |
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.
Maybe this should be Location or Declaration? We use Location in SymbolKit it looks like: https://github.com/apple/swift-docc-symbolkit/blob/main/openapi.yaml#L290.
I think Source is a good term for describing the entire collection of a project's source code but I'm not sure it's right for describing a specific symbol's declaration.
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.
I'm leaning towards being ok with "source" either referring to the source repository of the code in the 'semantic analysis' part of DocC and it referring to a specific symbol's remote source file when rendering each topic individually. I've renamed this to remoteSource to avoid confusion with the source of the symbol in a local file.
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.
(fyi @dobromir-hristov, if we go with this name change, we'll need to update the DocC Render PR to update the property name in the metadata object)
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.
No problem, just remind me in the PR with the final name :)
|
|
||
| /// Describes the location of the topic's source code, hosted by a source service. | ||
| public struct Source: Codable, Equatable { | ||
| /// The file name of the topic's source code. |
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.
| /// The file name of the topic's source code. | |
| /// The name of the file where the topic's declared. |
|
|
||
| /// Creates a source code repository. | ||
| /// - Parameters: | ||
| /// - checkoutPath: The path at which the repository is checked out locally. |
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.
Should we be more specific here? This needs to be the location where the repository was checked out when the given symbol graph was produced, right? Not just any local checkout.
...SwiftDocCUtilities/ArgumentParsing/Options/Source Repository/SourceRepositoryArguments.swift
Show resolved
Hide resolved
|
Looks great overall! Really nicely structured. Just left a few nit-picky comments. What are your thoughts on It would also be nice if when running |
| public var sourceFileURIVariants: VariantCollection<String?> = .init(defaultValue: nil) | ||
|
|
||
| /// The source location of the topic's source code. | ||
| public var source: Source? { |
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.
I left a comment below wondering if we should call this source, but regardless of what general name we land on here – should we specify that this is a remote location? That way it's clear how this is different from the existing sourceFileURI.
| public var source: Source? { | |
| public var remoteSource: Source? { |
| public var source: Source? { | |
| public var remoteLocation: Location? { |
| public var source: Source? { | |
| public var remoteSourceLocation: SourceLocation? { |
|
docc-render PR is approved. So let me know when you guys are ready and want to merge it :) |
44f6cc7 to
43aa251
Compare
I don't think
This would be nice as well, but opt-in as well I'd say. If your goal with |
4349e0c to
cdf218f
Compare
|
Based on feedback above, I've gone ahead and made However, it would be nice if the DocC SwiftPM plugin would automatically fill in |
|
@swift-ci please test |
cdf218f to
f84cd8a
Compare
|
@swift-ci please test |
ethan-kusters
left a comment
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.
Looks great- thank you!! Only blocking feedback is the OpenAPI spec validation. Very excited to have this in. 🥳
| SourceRepository( | ||
| checkoutPath: checkoutPath, | ||
| sourceServiceBaseURL: sourceServiceBaseURL, | ||
| formatLineNumber: { line in "lines-\(line)" } |
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.
It looks like lines- or line- will work here but line- seems a little nicer to me since we'll never be linking to a block.
| formatLineNumber: { line in "lines-\(line)" } | |
| formatLineNumber: { line in "line-\(line)" } |
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.
I couldn't find an official format reference from BitBucket, but lines- is what their website uses when you click on a file number, e.g., https://bitbucket.org/kannemadugupriyanka/sb1-test-fork-test-test/src/8f1c1b45b4622388b241cf281b595b4e02cef258/Test%20Test/.project#lines-4, so given that it seems safer to use lines-.
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.
Sounds good. I did come across this from BitBucket as a spec for what it's worth: https://support.atlassian.com/bitbucket-cloud/docs/hyperlink-to-source-code-in-bitbucket/.
But it lists something entirely different from what the UI does: #<filename>-<linenumber>.
And then the <filename> part is technically optional actually so:
works as well.
Any way 😃 Just matching the behavior of the UI seems fine enough.
Sources/SwiftDocC/SwiftDocC.docc/Resources/RenderNode.spec.json
Outdated
Show resolved
Hide resolved
| """ | ||
| ) | ||
| ) | ||
| public var sourceService: String? |
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.
Super nit-pick but ArgParser I think actually has built-in support for this kind of thing: https://apple.github.io/swift-argument-parser/documentation/argumentparser/declaringarguments/#Parsing-custom-types.
enum ReleaseMode: String, ExpressibleByArgument {
case debug, release
}
struct Example: ParsableCommand {
@Option var mode: ReleaseMode
mutating func run() throws {
print(mode)
}
}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.
I had that initially, but I wanted to allow any casing for these values, e.g., both--source-service GitHub and --source-service github, so I implemented the validation logic manually.
rdar://88537303
f84cd8a to
7217cc1
Compare
|
@swift-ci please test |
Added documentation to configure DocC's new functionality that emits links to symbols' declaration in the project's source repository, which was implemented in swiftlang#256.
Added documentation to configure DocC's new functionality that emits links to symbols' declaration in the project's source repository, which was implemented in swiftlang#256.
Added documentation to configure DocC's new functionality that emits links to symbols' declaration in the project's source repository, which was implemented in swiftlang#256.
Added documentation to configure DocC's new functionality that emits links to symbols' declaration in the project's source repository, which was implemented in #256.
Bug/issue #, if applicable: #186, rdar://88537303
Summary
Adds command-line arguments to configure a repo URL so that documentation websites can display a link to the symbol's declaration in the repo.
Example invocation:
Dependencies
swiftlang/swift-docc-render#366
Testing
Set the
DOCC_EXECenvironment variable to a local build of DocC from this branch and run with the flags described above. Verify that documentation pages for Swift symbols contains a.metadata.sourcefield that links to the symbol's declaration in the git service.Checklist
./bin/testscript and it succeededTODO