Skip to content

Respect formatting of links to symbols using custom titles #647

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

mportiz08
Copy link
Contributor

Bug/issue #, if applicable: #632 (108515663)

Summary

This resolves #632, which is a bug where code voice is automatically applied to a symbol link that has a custom title, even if it doesn't use any code voice itself.

If a custom title is used for a markdown link to a DocC symbol, the inline markdown formatting of that title should be respected as-is.

Example:

/// Default, should use code voice: ``StringBuilder``
///
/// Custom title, should use code voice: [`custom text`](doc:StringBuilder)
///
/// Custom title, should not use code voice: [custom text](doc:StringBuilder)
///
/// Custom title, should use italics and bold: [_**custom text**_](doc:StringBuilder)

Testing

Steps:

  1. Build this branch with npm run build
  2. Download/unzip example Swift package AttributeExamples.zip with custom title examples.
  3. Run env DOCC_HTML_DIR=/path/to/dist swift package --disable-sandbox preview-documentation --target AttributeExamples to preview the example package with this branch of the renderer.
  4. Open http://localhost:8080/documentation/attributeexamples/exampleusingcomplexattributes#overview and verify that all links are rendered with the expected formatting, given the markdown input from the source code.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

@mportiz08
Copy link
Contributor Author

@swift-ci test

@marinaaisa marinaaisa self-requested a review May 9, 2023 18:37
Copy link
Member

@marinaaisa marinaaisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@mportiz08 mportiz08 merged commit 864361e into swiftlang:main May 9, 2023
@mportiz08 mportiz08 deleted the dont-apply-code-element-to-refs-with-inline-formatting branch May 9, 2023 20:40
mportiz08 added a commit to mportiz08/swift-docc-render that referenced this pull request May 9, 2023
…#647)

**Example:**

```markdown
/// Default, should use code voice: ``StringBuilder``
///
/// Custom title, should use code voice: [`custom text`](doc:StringBuilder)
///
/// Custom title, should not use code voice: [custom text](doc:StringBuilder)
///
/// Custom title, should use italics and bold: [_**custom text**_](doc:StringBuilder)
```

Resolves: swiftlang#632 
Resolves: rdar://108515663
mportiz08 added a commit that referenced this pull request May 11, 2023
**Example:**

```markdown
/// Default, should use code voice: ``StringBuilder``
///
/// Custom title, should use code voice: [`custom text`](doc:StringBuilder)
///
/// Custom title, should not use code voice: [custom text](doc:StringBuilder)
///
/// Custom title, should use italics and bold: [_**custom text**_](doc:StringBuilder)
```

Resolves: #632 
Resolves: rdar://108515663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbol links with custom authored titles are rendered in code voice
3 participants