Skip to content

Commit b32175f

Browse files
github-actions[bot]Copilotdsyme
authored
[Repo Assist] Improve Literate.ParseAndCheckScriptFile/ParseScriptString XML docs; fix Windows-only path fallback (#1091)
* Add XML doc comments to Literate.ParseAndCheckScriptFile/ParseScriptString; fix Windows-only path fallback - Add full <summary>/<param> XML doc comments to ParseAndCheckScriptFile and ParseScriptString to be consistent with the other Literate.Parse* methods which already have detailed documentation. - Fix hardcoded "C:\script.fsx" fallback path (used when neither 'path' nor 'rootInputFolder' is supplied) in ParseScriptString and ParsePynbString. The fallback is now simply "script.fsx" so it looks correct on Linux/macOS in diagnostic messages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger checks --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
1 parent ca49b9e commit b32175f

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* `fsdocs convert` now accepts the input file as a positional argument (e.g. `fsdocs convert notebook.ipynb -o notebook.html`). [#1019](https://github.com/fsprojects/FSharp.Formatting/pull/1019)
1111
* `fsdocs convert` infers the output format from the output file extension when `--outputformat` is not specified (e.g. `-o out.md` implies `--outputformat markdown`). [#1019](https://github.com/fsprojects/FSharp.Formatting/pull/1019)
1212
* `fsdocs convert` now accepts `-o` as a shorthand for `--output`. [#1019](https://github.com/fsprojects/FSharp.Formatting/pull/1019)
13+
* Added full XML doc comments (`<summary>`, `<param>`) to `Literate.ParseAndCheckScriptFile` and `Literate.ParseScriptString` to match the documentation style of the other `Literate.Parse*` methods.
14+
15+
### Fixed
16+
* `Literate.ParseScriptString` and `Literate.ParsePynbString` used a hardcoded Windows path (`C:\script.fsx`) as the fallback script filename when neither `path` nor `rootInputFolder` is supplied. The fallback is now a simple platform-neutral `script.fsx`.
1317
* Add regression tests for cross-assembly tooltip resolution (issue [#1085](https://github.com/fsprojects/FSharp.Formatting/issues/1085)): verify that hover tooltips for types whose fields reference types from other assemblies show the correct type names (not `obj`) when `#r` paths resolve correctly.
1418

1519
### Changed

src/FSharp.Formatting.Literate/Literate.fs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ type Literate private () =
9898

9999
doc.With(paragraphs = pars)
100100

101-
/// Parse F# Script file to LiterateDocument
101+
/// <summary>
102+
/// Parse an F# script file (<c>.fsx</c>) to a <see cref="T:FSharp.Formatting.Literate.LiterateDocument"/>,
103+
/// type-checking it via the F# Compiler Service.
104+
/// </summary>
105+
/// <param name="path">The path to the <c>.fsx</c> script file to parse.</param>
106+
/// <param name="fscOptions">Additional F# compiler options (e.g. extra <c>-r:</c> references).</param>
107+
/// <param name="definedSymbols">Conditional-compilation symbols to define.</param>
108+
/// <param name="references">A map of reference labels to URLs, used to resolve Markdown-style links.</param>
109+
/// <param name="fsiEvaluator">An optional FSI evaluator; when supplied, code snippets are executed and their output included.</param>
110+
/// <param name="parseOptions">Markdown parse options. Defaults to <see cref="F:FSharp.Formatting.Markdown.MarkdownParseOptions.AllowYamlFrontMatter"/>.</param>
111+
/// <param name="rootInputFolder">The root folder used to resolve relative paths within the script. Defaults to the directory containing <paramref name="path"/>.</param>
112+
/// <param name="onError">A callback invoked with each error/warning message encountered during parsing or type-checking. Defaults to <c>ignore</c>.</param>
102113
static member ParseAndCheckScriptFile
103114
(
104115
path: string,
@@ -120,7 +131,20 @@ type Literate private () =
120131
|> Transformations.formatCodeSnippets path ctx
121132
|> Transformations.evaluateCodeSnippets ctx
122133

123-
/// Parse string as F# Script to LiterateDocument
134+
/// <summary>
135+
/// Parse a string containing F# script source code (<c>.fsx</c> syntax) to a
136+
/// <see cref="T:FSharp.Formatting.Literate.LiterateDocument"/>,
137+
/// type-checking it via the F# Compiler Service.
138+
/// </summary>
139+
/// <param name="content">The F# script source code to parse.</param>
140+
/// <param name="path">An optional file path used in diagnostics and to resolve relative references. When not supplied, defaults to <c>script.fsx</c> in <paramref name="rootInputFolder"/> (or just <c>script.fsx</c>).</param>
141+
/// <param name="fscOptions">Additional F# compiler options (e.g. extra <c>-r:</c> references).</param>
142+
/// <param name="definedSymbols">Conditional-compilation symbols to define.</param>
143+
/// <param name="references">A map of reference labels to URLs, used to resolve Markdown-style links.</param>
144+
/// <param name="fsiEvaluator">An optional FSI evaluator; when supplied, code snippets are executed and their output included.</param>
145+
/// <param name="parseOptions">Markdown parse options. Defaults to <see cref="F:FSharp.Formatting.Markdown.MarkdownParseOptions.AllowYamlFrontMatter"/>.</param>
146+
/// <param name="rootInputFolder">The root folder used to resolve relative paths within the script.</param>
147+
/// <param name="onError">A callback invoked with each error/warning message encountered during parsing or type-checking. Defaults to <c>ignore</c>.</param>
124148
static member ParseScriptString
125149
(
126150
content,
@@ -141,7 +165,7 @@ type Literate private () =
141165
| Some s -> s
142166
| None ->
143167
match rootInputFolder with
144-
| None -> "C:\\script.fsx"
168+
| None -> "script.fsx"
145169
| Some r -> Path.Combine(r, "script.fsx")
146170

147171
ParseScript(parseOptions, ctx).ParseAndCheckScriptFile(filePath, content, rootInputFolder, onError)
@@ -242,7 +266,7 @@ type Literate private () =
242266
| Some s -> s
243267
| None ->
244268
match rootInputFolder with
245-
| None -> "C:\\script.fsx"
269+
| None -> "script.fsx"
246270
| Some r -> Path.Combine(r, "script.fsx")
247271

248272
let content = ParsePynb.pynbStringToFsx content

0 commit comments

Comments
 (0)