@@ -328,6 +328,159 @@ struct MarkdownRenderer_PageElementsTests {
328328 """ )
329329 }
330330 }
331+
332+ @Test ( arguments: RenderGoal . allCases)
333+ func testRenderSwiftDeclaration( goal: RenderGoal ) {
334+ let symbolPaths = [
335+ " first-parameter-symbol-id " : URL ( string: " /documentation/ModuleName/FirstParameterValue/index.html " ) !,
336+ " second-parameter-symbol-id " : URL ( string: " /documentation/ModuleName/SecondParameterValue/index.html " ) !,
337+ " return-value-symbol-id " : URL ( string: " /documentation/ModuleName/ReturnValue/index.html " ) !,
338+ ]
339+
340+ let declaration = makeRenderer ( goal: goal, pathsToReturn: symbolPaths) . declaration ( [
341+ . swift: [
342+ . init( kind: . keyword, spelling: " func " , preciseIdentifier: nil ) ,
343+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
344+ . init( kind: . identifier, spelling: " doSomething " , preciseIdentifier: nil ) ,
345+ . init( kind: . text, spelling: " ( " , preciseIdentifier: nil ) ,
346+ . init( kind: . externalParameter, spelling: " with " , preciseIdentifier: nil ) ,
347+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
348+ . init( kind: . internalParameter, spelling: " first " , preciseIdentifier: nil ) ,
349+ . init( kind: . text, spelling: " : " , preciseIdentifier: nil ) ,
350+ . init( kind: . typeIdentifier, spelling: " FirstParameterValue " , preciseIdentifier: " first-parameter-symbol-id " ) ,
351+ . init( kind: . text, spelling: " , " , preciseIdentifier: nil ) ,
352+ . init( kind: . externalParameter, spelling: " and " , preciseIdentifier: nil ) ,
353+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
354+ . init( kind: . internalParameter, spelling: " second " , preciseIdentifier: nil ) ,
355+ . init( kind: . text, spelling: " : " , preciseIdentifier: nil ) ,
356+ . init( kind: . typeIdentifier, spelling: " SecondParameterValue " , preciseIdentifier: " second-parameter-symbol-id " ) ,
357+ . init( kind: . text, spelling: " ) " , preciseIdentifier: nil ) ,
358+ . init( kind: . keyword, spelling: " throws " , preciseIdentifier: nil ) ,
359+ . init( kind: . text, spelling: " -> " , preciseIdentifier: nil ) ,
360+ . init( kind: . typeIdentifier, spelling: " ReturnValue " , preciseIdentifier: " return-value-symbol-id " ) ,
361+ ]
362+ ] )
363+ switch goal {
364+ case . richness:
365+ declaration. assertMatches ( prettyFormatted: true , expectedXMLString: """
366+ <pre id= " declaration " >
367+ <code>
368+ <span class= " token-keyword " >func</span>
369+ <span class= " token-identifier " >doSomething</span>
370+ (<span class= " token-externalParam " >with</span>
371+ <span class= " token-internalParam " >first</span>
372+ : <a class= " token-typeIdentifier " href= " ../../firstparametervalue/index.html " >FirstParameterValue</a>
373+ , <span class= " token-externalParam " >and</span>
374+ <span class= " token-internalParam " >second</span>
375+ : <a class= " token-typeIdentifier " href= " ../../secondparametervalue/index.html " >SecondParameterValue</a>
376+ ) <span class= " token-keyword " >throws</span>
377+ -> <a class= " token-typeIdentifier " href= " ../../returnvalue/index.html " >ReturnValue</a>
378+ </code>
379+ </pre>
380+ """ )
381+ case . conciseness:
382+ declaration. assertMatches ( prettyFormatted: true , expectedXMLString: """
383+ <pre>
384+ <code>func doSomething(with first: FirstParameterValue, and second: SecondParameterValue) throws-> ReturnValue</code>
385+ </pre>
386+ """ )
387+ }
388+ }
389+
390+ @Test ( arguments: RenderGoal . allCases)
391+ func testRenderLanguageSpecificDeclarations( goal: RenderGoal ) {
392+ let symbolPaths = [
393+ " first-parameter-symbol-id " : URL ( string: " /documentation/ModuleName/FirstParameterValue/index.html " ) !,
394+ " second-parameter-symbol-id " : URL ( string: " /documentation/ModuleName/SecondParameterValue/index.html " ) !,
395+ " return-value-symbol-id " : URL ( string: " /documentation/ModuleName/ReturnValue/index.html " ) !,
396+ " error-parameter-symbol-id " : URL ( string: " /documentation/Foundation/NSError/index.html " ) !,
397+ ]
398+
399+ let declaration = makeRenderer ( goal: goal, pathsToReturn: symbolPaths) . declaration ( [
400+ . swift: [
401+ . init( kind: . keyword, spelling: " func " , preciseIdentifier: nil ) ,
402+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
403+ . init( kind: . identifier, spelling: " doSomething " , preciseIdentifier: nil ) ,
404+ . init( kind: . text, spelling: " ( " , preciseIdentifier: nil ) ,
405+ . init( kind: . externalParameter, spelling: " with " , preciseIdentifier: nil ) ,
406+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
407+ . init( kind: . internalParameter, spelling: " first " , preciseIdentifier: nil ) ,
408+ . init( kind: . text, spelling: " : " , preciseIdentifier: nil ) ,
409+ . init( kind: . typeIdentifier, spelling: " FirstParameterValue " , preciseIdentifier: " first-parameter-symbol-id " ) ,
410+ . init( kind: . text, spelling: " , " , preciseIdentifier: nil ) ,
411+ . init( kind: . externalParameter, spelling: " and " , preciseIdentifier: nil ) ,
412+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
413+ . init( kind: . internalParameter, spelling: " second " , preciseIdentifier: nil ) ,
414+ . init( kind: . text, spelling: " : " , preciseIdentifier: nil ) ,
415+ . init( kind: . typeIdentifier, spelling: " SecondParameterValue " , preciseIdentifier: " second-parameter-symbol-id " ) ,
416+ . init( kind: . text, spelling: " ) " , preciseIdentifier: nil ) ,
417+ . init( kind: . keyword, spelling: " throws " , preciseIdentifier: nil ) ,
418+ . init( kind: . text, spelling: " -> " , preciseIdentifier: nil ) ,
419+ . init( kind: . typeIdentifier, spelling: " ReturnValue " , preciseIdentifier: " return-value-symbol-id " ) ,
420+ ] ,
421+
422+ . objectiveC: [
423+ . init( kind: . text, spelling: " - ( " , preciseIdentifier: nil ) ,
424+ . init( kind: . typeIdentifier, spelling: " ReturnValue " , preciseIdentifier: " return-value-symbol-id " ) ,
425+ . init( kind: . text, spelling: " ) " , preciseIdentifier: nil ) ,
426+ . init( kind: . identifier, spelling: " doSomethingWithFirst " , preciseIdentifier: nil ) ,
427+ . init( kind: . text, spelling: " : ( " , preciseIdentifier: nil ) ,
428+ . init( kind: . typeIdentifier, spelling: " FirstParameterValue " , preciseIdentifier: " first-parameter-symbol-id " ) ,
429+ . init( kind: . text, spelling: " ) " , preciseIdentifier: nil ) ,
430+ . init( kind: . internalParameter, spelling: " first " , preciseIdentifier: nil ) ,
431+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
432+ . init( kind: . identifier, spelling: " andSecond " , preciseIdentifier: nil ) ,
433+ . init( kind: . text, spelling: " : ( " , preciseIdentifier: nil ) ,
434+ . init( kind: . typeIdentifier, spelling: " SecondParameterValue " , preciseIdentifier: " second-parameter-symbol-id " ) ,
435+ . init( kind: . text, spelling: " ) " , preciseIdentifier: nil ) ,
436+ . init( kind: . internalParameter, spelling: " second " , preciseIdentifier: nil ) ,
437+ . init( kind: . text, spelling: " " , preciseIdentifier: nil ) ,
438+ . init( kind: . identifier, spelling: " error " , preciseIdentifier: nil ) ,
439+ . init( kind: . text, spelling: " : ( " , preciseIdentifier: nil ) ,
440+ . init( kind: . typeIdentifier, spelling: " NSError " , preciseIdentifier: " error-parameter-symbol-id " ) ,
441+ . init( kind: . text, spelling: " **) " , preciseIdentifier: nil ) ,
442+ . init( kind: . internalParameter, spelling: " error " , preciseIdentifier: nil ) ,
443+ . init( kind: . text, spelling: " ; " , preciseIdentifier: nil ) ,
444+ ]
445+ ] )
446+ switch goal {
447+ case . richness:
448+ declaration. assertMatches ( prettyFormatted: true , expectedXMLString: """
449+ <pre id= " declaration " >
450+ <code class= " swift-only " >
451+ <span class= " token-keyword " >func</span>
452+ <span class= " token-identifier " >doSomething</span>
453+ (<span class= " token-externalParam " >with</span>
454+ <span class= " token-internalParam " >first</span>
455+ : <a class= " token-typeIdentifier " href= " ../../firstparametervalue/index.html " >FirstParameterValue</a>
456+ , <span class= " token-externalParam " >and</span>
457+ <span class= " token-internalParam " >second</span>
458+ : <a class= " token-typeIdentifier " href= " ../../secondparametervalue/index.html " >SecondParameterValue</a>
459+ ) <span class= " token-keyword " >throws</span>
460+ -> <a class= " token-typeIdentifier " href= " ../../returnvalue/index.html " >ReturnValue</a>
461+ </code>
462+ <code class= " occ-only " >- (<a class= " token-typeIdentifier " href= " ../../returnvalue/index.html " >ReturnValue</a>
463+ ) <span class= " token-identifier " >doSomethingWithFirst</span>
464+ : (<a class= " token-typeIdentifier " href= " ../../firstparametervalue/index.html " >FirstParameterValue</a>
465+ ) <span class= " token-internalParam " >first</span>
466+ <span class= " token-identifier " >andSecond</span>
467+ : (<a class= " token-typeIdentifier " href= " ../../secondparametervalue/index.html " >SecondParameterValue</a>
468+ ) <span class= " token-internalParam " >second</span>
469+ <span class= " token-identifier " >error</span>
470+ : (<a class= " token-typeIdentifier " href= " ../../../foundation/nserror/index.html " >NSError</a>
471+ **) <span class= " token-internalParam " >error</span>
472+ ;</code>
473+ </pre>
474+ """ )
475+
476+ case . conciseness:
477+ declaration. assertMatches ( prettyFormatted: true , expectedXMLString: """
478+ <pre>
479+ <code>func doSomething(with first: FirstParameterValue, and second: SecondParameterValue) throws-> ReturnValue</code>
480+ </pre>
481+ """ )
482+ }
483+ }
331484
332485 // MARK: -
333486
0 commit comments