-
Notifications
You must be signed in to change notification settings - Fork 127
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
SwiftDocC: use "portable" paths for file names #668
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ final class RenderIndexTests: XCTestCase { | |
"type": "groupMarker" | ||
}, | ||
{ | ||
"path": "/documentation/mixedlanguageframework/bar/mystringfunction(_:)", | ||
"path": "/documentation/mixedlanguageframework/bar/mystringfunction(__)", | ||
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. @ethan-kusters do you remember if this value represents the path of the web URL or the file path within the documentation archive? I thought that this is the path that the browser would load to access this page. |
||
"title": "myStringFunction:error: (navigator title)", | ||
"type": "method", | ||
"children": [ | ||
|
@@ -327,7 +327,7 @@ final class RenderIndexTests: XCTestCase { | |
}, | ||
{ | ||
"title": "class func myStringFunction(String) throws -> String", | ||
"path": "/documentation/mixedlanguageframework/bar/mystringfunction(_:)", | ||
"path": "/documentation/mixedlanguageframework/bar/mystringfunction(__)", | ||
"type": "method" | ||
} | ||
] | ||
|
@@ -488,7 +488,7 @@ final class RenderIndexTests: XCTestCase { | |
"type": "groupMarker" | ||
}, | ||
{ | ||
"path": "\/documentation\/mixedlanguageframework\/foo-swift.struct\/init(rawvalue:)", | ||
"path": "\/documentation\/mixedlanguageframework\/foo-swift.struct\/init(rawvalue_)", | ||
"title": "init(rawValue: UInt)", | ||
"type": "init" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,7 +474,7 @@ class DocumentationContextTests: XCTestCase { | |
Folder(name: "Resources", content: [ | ||
// This whitespace and punctuation in this *file name* will be replaced by dashes in its identifier. | ||
// No content in this file result in identifiers. | ||
TextFile(name: "Technology file: with - whitespace, and_punctuation.tutorial", utf8Content: """ | ||
TextFile(name: "Technology file_ with - whitespace, and_punctuation.tutorial", utf8Content: """ | ||
@Tutorials(name: "Technology Name") { | ||
@Intro(title: "Intro Title") { | ||
@Video(source: introvideo.mp4, poster: introposter.png) | ||
|
@@ -510,10 +510,10 @@ class DocumentationContextTests: XCTestCase { | |
let identifierPaths = context.knownIdentifiers.map { $0.path }.sorted(by: { lhs, rhs in lhs.count < rhs.count }) | ||
XCTAssertEqual(identifierPaths, [ | ||
// From the two file names | ||
"/tutorials/Technology-file:-with---whitespace,-and_punctuation", | ||
"/tutorials/Technology-file_-with---whitespace,-and_punctuation", | ||
// From the volume's title and the chapter's names, appended to their technology's identifier | ||
"/tutorials/Technology-file:-with---whitespace,-and_punctuation/Volume_Section-Title:-with---various!-whitespace,-and/punctuation", | ||
"/tutorials/Technology-file:-with---whitespace,-and_punctuation/Volume_Section-Title:-with---various!-whitespace,-and/punctuation/Chapter_Title:-with---various!-whitespace,-and/punctuation" | ||
"/tutorials/Technology-file_-with---whitespace,-and_punctuation/Volume_Section-Title:-with---various!-whitespace,-and/punctuation", | ||
"/tutorials/Technology-file_-with---whitespace,-and_punctuation/Volume_Section-Title:-with---various!-whitespace,-and/punctuation/Chapter_Title:-with---various!-whitespace,-and/punctuation" | ||
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. Is it expected that the 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. No, that isn't expected, but how did the test pass 🤯. |
||
]) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,7 +287,7 @@ class ExternalLinkableTests: XCTestCase { | |
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] | ||
|
||
XCTAssertEqual(summary.title, "globalFunction(_:considering:)") | ||
XCTAssertEqual(summary.relativePresentationURL.absoluteString, "/documentation/mykit/globalfunction(_:considering:)") | ||
XCTAssertEqual(summary.relativePresentationURL.absoluteString, "/documentation/mykit/globalfunction(__considering_)") | ||
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 don't think this value should change. It represents the relative URL for this page. As far as I understood the URL would still contain the characters that aren't allowed in the file names. 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. Right, the URLs can contain the view, but the file paths would be replaced. I believe that the replativePresentationURL is still referencing the file path? 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. No, this is meant to refer to the web URL relative to where this documentation is hosted. This API is used to bridge with other documentation systems which aren't expected to have access to the doccarchive directly. Those systems are expected to use the summary information to create links that navigate the reader to the hosted documentation. 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. It can also refer to a landmark on a page which wouldn't have its own file in the documentation archive. |
||
XCTAssertEqual(summary.referenceURL.absoluteString, "doc://org.swift.docc.example/documentation/MyKit/globalFunction(_:considering:)") | ||
XCTAssertEqual(summary.language, .swift) | ||
XCTAssertEqual(summary.kind, .function) | ||
|
@@ -508,7 +508,7 @@ class ExternalLinkableTests: XCTestCase { | |
let summary = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)[0] | ||
|
||
XCTAssertEqual(summary.title, "myStringFunction(_:)") | ||
XCTAssertEqual(summary.relativePresentationURL.absoluteString, "/documentation/mixedlanguageframework/bar/mystringfunction(_:)") | ||
XCTAssertEqual(summary.relativePresentationURL.absoluteString, "/documentation/mixedlanguageframework/bar/mystringfunction(__)") | ||
XCTAssertEqual(summary.referenceURL.absoluteString, "doc://org.swift.MixedLanguageFramework/documentation/MixedLanguageFramework/Bar/myStringFunction(_:)") | ||
XCTAssertEqual(summary.language, .swift) | ||
XCTAssertEqual(summary.kind, .typeMethod) | ||
|
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 wonder if we should always append a hashed identifier to the name here to ensure that the file names don't collide.
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 think that appending the hashed identifier seems reasonable. Definitely would avoid any possible conflicts. Would we do that for any case where
isURLModified
is true?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 code already mostly does that when modifying the URL, although if it's a specific path component that's longer than what a file name is allowed to be, then it shortens that path component and appends the hash to that component instead of later in the URL.