RFC: Category footnotes in the diagnostics formatter

Hey all,

Following up on my previous RFC to add diagnostic categories, I just put up a pull request to print out category name links in the Markdown style, e.g.,

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

It's an extension to DiagnosticFormatter that's pretty straightforward

extension DiagnosticFormatter {
  /// Produce a string containing "footnotes" for each of the diagnostic
  /// category provided that has associated documentation. Each category
  /// is printed in Markdown link format, e.g.,
  ///
  /// ```
  /// [#categoryName]: <categoryDocumentationURL>
  /// ```
  ///
  /// This function also deduplicates entries and alphabetizes the results.
  ///
  /// - Parameters:
  ///   - categories: the categories to print
  ///   - leadingText: text that is prefixed to the list of categories when
  ///     there is at least one category to print.
  public func categoryFootnotes(
    _ categories: [DiagnosticCategory],
    leadingText: String = "\n"
  ) -> String
}

and I plan to use it in the compiler at the end of the translation unit with all of the categories that were referenced in diagnostics within that translation unit.

Doug

6 Likes