From 27bc5adca6b13ccec3aa221f314a5d2d2f93b97b Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Fri, 6 Nov 2026 10:33:30 +0100 Subject: [PATCH 1/3] Render see langword in API docs and tool tips A has no cref, so the API docs wrote nothing for it and a tool tip replaced it with its empty text. The API docs now write the keyword as inline code, the same as true, and a tool tip keeps the word. Co-Authored-By: Claude Opus 5.5 --- src/FSharp.Formatting.ApiDocs/XmlDocReader.fs | 8 ++++ .../ToolTipReader.fs | 6 +-- tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs | 38 +++++++++++++++++++ .../files/crefLib2/Library2.fs | 6 +++ .../CodeFormatTests.fs | 13 +++++++ 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/FSharp.Formatting.ApiDocs/XmlDocReader.fs b/src/FSharp.Formatting.ApiDocs/XmlDocReader.fs index 9cbb68618..915821c96 100644 --- a/src/FSharp.Formatting.ApiDocs/XmlDocReader.fs +++ b/src/FSharp.Formatting.ApiDocs/XmlDocReader.fs @@ -211,6 +211,14 @@ module internal XmlDocReader = urlMap.ResolveCref cname |> ignore let crefAsHtml = HttpUtility.HtmlEncode cref.Value html.Append(crefAsHtml) |> ignore + else + // a keyword such as has nothing to link to, + // so it reads as code, the same as true + match elem.Attribute(XName.Get "langword") with + | null -> () + | langword -> + html.AppendFormat("{0}", HttpUtility.HtmlEncode langword.Value) + |> ignore | "c" -> html.Append("") |> ignore diff --git a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs index 7a680391c..b5e228cea 100644 --- a/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs +++ b/src/FSharp.Formatting.CodeFormat/ToolTipReader.fs @@ -196,8 +196,8 @@ let private tryReadXmlDoc (text: string) = // document, so give it a root of its own before parsing let root = XElement.Parse("" + text + "", LoadOptions.PreserveWhitespace) - // a keeps its text in an attribute, so it would leave a - // hole in the sentence around it once we ask an element for its text + // a or a keeps its text in an attribute, + // so it would leave a hole in the sentence around it once we ask an element for its text for reference in List.ofSeq (root.Descendants()) do match reference.Name.LocalName with | "see" @@ -205,7 +205,7 @@ let private tryReadXmlDoc (text: string) = | "paramref" | "typeparamref" -> let named = - [ "cref"; "name" ] + [ "cref"; "name"; "langword" ] |> List.tryPick (fun name -> match reference.Attribute(XName.Get name) with | null -> None diff --git a/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs b/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs index 4033327ce..955780f5a 100644 --- a/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs +++ b/tests/FSharp.ApiDocs.Tests/ApiDocsTests.fs @@ -1321,6 +1321,44 @@ let ``Math in XML generated ok`` (format: OutputFormat) = files.[(sprintf "creflib2-mathtest.%s" format.Extension)] |> shouldContainText """1 < 2 < 3 > 0""" +[] +[] +let ``See langword renders as inline code`` (format: OutputFormat) = + let libraries = [ testBin "crefLib1.dll"; testBin "crefLib2.dll" ] |> fullpaths + + let output = getOutputDir format "crefLibs_langword" + printfn "Output: %s" output + + let inputs = + [ + for lib in libraries -> + ApiDocInput.FromFile( + lib, + sourceRepo = "https://github.com/fsprojects/FSharp.Formatting/tree/master", + sourceFolder = (__SOURCE_DIRECTORY__ "../.."), + mdcomments = false + ) + ] + + let _model, _searchIndex = + DocsGenerator(format) + .Run( + inputs, + output, + collectionName = "CrefLibs", + template = docTemplate format, + substitutions = substitutions, + libDirs = ([ testBin ] |> fullpaths) + ) + + let fileNames = Directory.GetFiles(output "reference") + + let files = dict [ for f in fileNames -> Path.GetFileName(f), File.ReadAllText(f) ] + + // a keyword has no cref to link, so it reads as code, the same as true + files.[(sprintf "creflib2-class12.%s" format.Extension)] + |> shouldContainText "Returns true when it works, otherwise false." + [] [] let ``ApiDocs test that csharp (publiconly) support works`` (format: OutputFormat) = diff --git a/tests/FSharp.ApiDocs.Tests/files/crefLib2/Library2.fs b/tests/FSharp.ApiDocs.Tests/files/crefLib2/Library2.fs index 4f9057a90..272f51a2d 100644 --- a/tests/FSharp.ApiDocs.Tests/files/crefLib2/Library2.fs +++ b/tests/FSharp.ApiDocs.Tests/files/crefLib2/Library2.fs @@ -159,3 +159,9 @@ type Class10() = /// type Class11() = member this.X = "F#" + +/// +/// Returns when it works, otherwise . +/// +type Class12() = + member this.X = "F#" diff --git a/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs b/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs index 1d851db5c..1c3b41da1 100644 --- a/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs +++ b/tests/FSharp.CodeFormat.Tests/CodeFormatTests.fs @@ -742,6 +742,19 @@ let m = make () let _content, tooltip = getContentAndToolTip source tooltip |> shouldContainText "Produces a Marker value" +[] +let ``A see langword keeps its keyword in the sentence it sits in`` () = + let source = + """ +/// Returns when it works +let works () = true + +let w = works () +""" + + let _content, tooltip = getContentAndToolTip source + tooltip |> shouldContainText "Returns true when it works" + // -------------------------------------------------------------------------------------- // Tests for cross-assembly type resolution in tooltips (issue #1085) // -------------------------------------------------------------------------------------- From 1088617a1a2543660da1f252f36859fcb6c7ee98 Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Fri, 6 Nov 2026 13:59:36 +0100 Subject: [PATCH 2/3] Add a release note for see langword Co-Authored-By: Claude Opus 5.5 --- RELEASE_NOTES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ca11c5693..6569797a1 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,6 +6,9 @@ * Avoid recomputing `List.length` on the shrinking remainder for every scanned character when splitting a Markdown pipe-table row into cells (`pipeTableFindSplits` in `MarkdownTableParser.fs`). The scan now tracks the number of consumed characters incrementally, turning an O(n²) split into an O(n) one for rows with many delimiters, with no behavior change. * Avoided a per-character `Seq.windowed`/`String()` allocation in `StartsWithNTimesTrimIgnoreStartWhitespace`, the active pattern used to count repeated fence characters (`` ` `` / `~`) when parsing code fences and headers. The count is now computed with `String.CompareOrdinal` over string offsets, with no intermediate substring allocations. Behavior is unchanged. +### Fixed +* A `` in a doc comment rendered as nothing, so `Returns when …` read "Returns when …". The API docs show the keyword as inline code, the same as `true`, and a tool tip on a code snippet keeps the word. [#1371](https://github.com/fsprojects/FSharp.Formatting/pull/1371) + ## [23.0.0-alpha.8] - 2026-09-18 ### Added From e234cac615b0010d5e821c2fd387a178c148deeb Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Fri, 6 Nov 2026 14:42:43 +0100 Subject: [PATCH 3/3] Release 23.0.0-alpha.9 Co-Authored-By: Claude Opus 5.5 --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 6569797a1..c491150d6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased] +## [23.0.0-alpha.9] - 2026-11-06 ### Changed * Avoid recomputing `List.length` on the shrinking remainder for every scanned character when splitting a Markdown pipe-table row into cells (`pipeTableFindSplits` in `MarkdownTableParser.fs`). The scan now tracks the number of consumed characters incrementally, turning an O(n²) split into an O(n) one for rows with many delimiters, with no behavior change.