@@ -1736,6 +1736,53 @@ let expected = """
17361736 XCTAssertEqual ( " /=(_:_:) " , pageIdentifiersAndNames [ " /documentation/Operators/MyNumber/_=(_:_:)-3m4ko " ] )
17371737 }
17381738
1739+ func testFileNamesWithDifferentPunctuation( ) throws {
1740+ let tempURL = try createTempFolder ( content: [
1741+ Folder ( name: " unit-test.docc " , content: [
1742+ TextFile ( name: " Hello-world.md " , utf8Content: """
1743+ # Dash
1744+
1745+ No whitespace in the file name
1746+ """ ) ,
1747+
1748+ TextFile ( name: " Hello world.md " , utf8Content: """
1749+ # Only space
1750+
1751+ This has the same reference as " Hello-world.md " and will raise a warning.
1752+ """ ) ,
1753+
1754+ TextFile ( name: " Hello world.md " , utf8Content: """
1755+ # Multiple spaces
1756+
1757+ Each space is replaced with a dash in the reference, so this has a unique reference.
1758+ """ ) ,
1759+
1760+ TextFile ( name: " Hello, world!.md " , utf8Content: """
1761+ # Space and punctuation
1762+
1763+ The punctuation is not removed from the reference, so this has a unique reference.
1764+ """ ) ,
1765+
1766+ TextFile ( name: " Hello. world?.md " , utf8Content: """
1767+ # Space and different punctuation
1768+
1769+ The punctuation is not removed from the reference, so this has a unique reference.
1770+ """ ) ,
1771+ ] )
1772+ ] )
1773+ let ( _, _, context) = try loadBundle ( from: tempURL)
1774+
1775+ XCTAssertEqual ( context. problems. map ( \. diagnostic. summary) , [ " Redeclaration of 'Hello world.md'; this file will be skipped " ] )
1776+
1777+ XCTAssertEqual ( context. knownPages. map ( \. absoluteString) . sorted ( ) , [
1778+ " doc://unit-test/documentation/unit-test " ,
1779+ " doc://unit-test/documentation/unit-test/Hello,-world! " ,
1780+ " doc://unit-test/documentation/unit-test/Hello--world " ,
1781+ " doc://unit-test/documentation/unit-test/Hello-world " ,
1782+ " doc://unit-test/documentation/unit-test/Hello.-world- " ,
1783+ ] )
1784+ }
1785+
17391786 func testSpecialCharactersInLinks( ) throws {
17401787 let originalSymbolGraph = Bundle . module. url ( forResource: " TestBundle " , withExtension: " docc " , subdirectory: " Test Bundles " ) !. appendingPathComponent ( " mykit-iOS.symbols.json " )
17411788
@@ -1751,7 +1798,15 @@ let expected = """
17511798 """ ) ,
17521799
17531800 TextFile ( name: " article-with-😃-in-filename.md " , utf8Content: """
1754- # Article with 😃 emoji in file name
1801+ # Article with 😃 emoji in its filename
1802+
1803+ Abstract
1804+
1805+ ### Hello world
1806+ """ ) ,
1807+
1808+ TextFile ( name: " Article: with - various! whitespace & punctuation. in, filename.md " , utf8Content: """
1809+ # Article with various whitespace and punctuation in its filename
17551810
17561811 Abstract
17571812
@@ -1767,6 +1822,8 @@ let expected = """
17671822 - <doc:article-with-emoji-in-heading#Hello-🌍>
17681823 - <doc:article-with-😃-in-filename>
17691824 - <doc:article-with-😃-in-filename#Hello-world>
1825+ - <doc:Article:-with-various!-whitespace-&-punctuation.-in,-filename>
1826+ - <doc:Article:-with-various!-whitespace-&-punctuation.-in,-filename#Hello-world>
17701827
17711828 Now test the same links in topic curation.
17721829
@@ -1776,6 +1833,7 @@ let expected = """
17761833
17771834 - ``MyClass/myFunc🙂()``
17781835 - <doc:article-with-😃-in-filename>
1836+ - <doc:Article:-with-various!-whitespace-&-punctuation.-in,-filename>
17791837 """ ) ,
17801838 ] )
17811839 let bundleURL = try testBundle. write ( inside: createTemporaryDirectory ( ) )
@@ -1789,11 +1847,12 @@ let expected = """
17891847
17901848 let moduleSymbol = try XCTUnwrap ( entity. semantic as? Symbol )
17911849 let topicSection = try XCTUnwrap ( moduleSymbol. topics? . taskGroups. first)
1792-
1850+
17931851 // Verify that all the links in the topic section resolved
17941852 XCTAssertEqual ( topicSection. links. map ( \. destination) , [
17951853 " doc://special-characters/documentation/MyKit/MyClass/myFunc_() " ,
17961854 " doc://special-characters/documentation/special-characters/article-with---in-filename " ,
1855+ " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename " ,
17971856 ] )
17981857
17991858 // Verify that all resolved link exist in the context.
@@ -1808,10 +1867,11 @@ let expected = """
18081867 let renderNode = translator. visit ( moduleSymbol) as! RenderNode
18091868
18101869 // Verify that the resolved links rendered as links
1811- XCTAssertEqual ( renderNode. topicSections. first? . identifiers. count, 2 )
1870+ XCTAssertEqual ( renderNode. topicSections. first? . identifiers. count, 3 )
18121871 XCTAssertEqual ( renderNode. topicSections. first? . identifiers, [
18131872 " doc://special-characters/documentation/MyKit/MyClass/myFunc_() " ,
18141873 " doc://special-characters/documentation/special-characters/article-with---in-filename " ,
1874+ " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename " ,
18151875 ] )
18161876
18171877
@@ -1826,7 +1886,7 @@ let expected = """
18261886
18271887 XCTAssertEqual ( lists. count, 1 )
18281888 let list = try XCTUnwrap ( lists. first)
1829- XCTAssertEqual ( list. items. count, 4 , " Unexpected list items: \( list. items. map ( \. content) ) " )
1889+ XCTAssertEqual ( list. items. count, 6 , " Unexpected list items: \( list. items. map ( \. content) ) " )
18301890
18311891 func withContentAsReference( _ listItem: RenderBlockContent . ListItem ? , verify: ( RenderReferenceIdentifier , Bool , String ? , [ RenderInlineContent ] ? ) -> Void ) {
18321892 guard let listItem = listItem else {
@@ -1866,7 +1926,19 @@ let expected = """
18661926 XCTAssertEqual ( overridingTitle, nil )
18671927 XCTAssertEqual ( overridingTitleInlineContent, nil )
18681928 }
1869-
1929+ withContentAsReference ( list. items. dropFirst ( 4 ) . first) { identifier, isActive, overridingTitle, overridingTitleInlineContent in
1930+ XCTAssertEqual ( identifier. identifier, " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename " )
1931+ XCTAssertEqual ( isActive, true )
1932+ XCTAssertEqual ( overridingTitle, nil )
1933+ XCTAssertEqual ( overridingTitleInlineContent, nil )
1934+ }
1935+ withContentAsReference ( list. items. dropFirst ( 5 ) . first) { identifier, isActive, overridingTitle, overridingTitleInlineContent in
1936+ XCTAssertEqual ( identifier. identifier, " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename#Hello-world " )
1937+ XCTAssertEqual ( isActive, true )
1938+ XCTAssertEqual ( overridingTitle, nil )
1939+ XCTAssertEqual ( overridingTitleInlineContent, nil )
1940+ }
1941+
18701942 // Verify that the topic render references have titles with special characters when the original content contained special characters
18711943 XCTAssertEqual (
18721944 ( renderNode. references [ " doc://special-characters/documentation/MyKit/MyClass/myFunc_() " ] as? TopicRenderReference ) ? . title,
@@ -1878,12 +1950,20 @@ let expected = """
18781950 )
18791951 XCTAssertEqual (
18801952 ( renderNode. references [ " doc://special-characters/documentation/special-characters/article-with---in-filename " ] as? TopicRenderReference ) ? . title,
1881- " Article with 😃 emoji in file name "
1953+ " Article with 😃 emoji in its filename "
18821954 )
18831955 XCTAssertEqual (
18841956 ( renderNode. references [ " doc://special-characters/documentation/special-characters/article-with---in-filename#Hello-world " ] as? TopicRenderReference ) ? . title,
18851957 " Hello world "
18861958 )
1959+ XCTAssertEqual (
1960+ ( renderNode. references [ " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename " ] as? TopicRenderReference ) ? . title,
1961+ " Article with various whitespace and punctuation in its filename "
1962+ )
1963+ XCTAssertEqual (
1964+ ( renderNode. references [ " doc://special-characters/documentation/special-characters/Article:-with---various!-whitespace-&-punctuation.-in,-filename#Hello-world " ] as? TopicRenderReference ) ? . title,
1965+ " Hello world "
1966+ )
18871967 }
18881968
18891969 func testNonOverloadCollisionFromExtension( ) throws {
0 commit comments