Skip to content

Conversation

DougGregor
Copy link
Member

Categories associated with diagnostics are printed in a Markdown link style as part of diagnostics (e.g., [#StrictMemorySafety]). At the end of compilation, a tool may wish to provide documentation links to documentation for all of the categories that showed up in that compilation. This new function DiagnosticFormatter.categoryFootnotes() prints the categories it is given (also as Markdown) for that purpose, e.g.,

[#deprecated]: <http://example.com/deprecated>
[#StrictMemorySafety]: <http://example.com/memory-safety>

Categories associated with diagnostics are printed in a Markdown link style
as part of diagnostics (e.g., `[#StrictMemorySafety]`). At the end of
compilation, a tool may wish to provide documentation links to
documentation for all of the categories that showed up in that
compilation. This new function DiagnosticFormatter.categoryFootnotes()
prints the categories it is given (also as Markdown) for that purpose, e.g.,

    [#deprecated]: <http://example.com/deprecated>
    [#StrictMemorySafety]: <http://example.com/memory-safety>
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

swiftlang/swift#79873

@swift-ci please test

@DougGregor
Copy link
Member Author

swiftlang/swift#79873

@swift-ci please test Windows

@DougGregor
Copy link
Member Author

Speculatively merging; we can revise as needed

@DougGregor DougGregor merged commit b9ae3b7 into swiftlang:main Mar 10, 2025
25 checks passed
@DougGregor DougGregor deleted the category-footnotes branch March 10, 2025 02:30
/// [#categoryName]: <categoryDocumentationURL>
/// ```
///
/// This function also deduplicates entries and alphabetizes the results.
Copy link
Contributor

@ktoso ktoso Mar 10, 2025

Choose a reason for hiding this comment

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

Nice, worth doing that 👍

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Just one suggestion, otherwise LGTM. 👍🏽

/// - leadingText: text that is prefixed to the list of categories when
/// there is at least one category to print.
public func categoryFootnotes(
_ categories: [DiagnosticCategory],
Copy link
Member

Choose a reason for hiding this comment

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

Could we make this some Collection<DiagnosticCategory>, say if somebody collected the categories in a Set (which doesn’t seem too unreasonable to me).

Copy link
Member Author

Choose a reason for hiding this comment

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

Great idea! #3008

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.

3 participants