Skip to content

Commit e8d7a4e

Browse files
authored
Merge branch 'main' into repo-assist/fix-issue-924-watch-root-override-c4e35a7b2fb520aa
2 parents 7a3ac18 + 99d95b2 commit e8d7a4e

5 files changed

Lines changed: 46 additions & 14 deletions

File tree

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66
* Add `--root` option to `fsdocs watch` to override the root URL for generated pages. Useful for serving docs via GitHub Codespaces, reverse proxies, or other remote hosting where `localhost` URLs are inaccessible. E.g. `fsdocs watch --root /` or `fsdocs watch --root https://example.com/docs/`. When not set, defaults to `http://localhost:<port>/` as before. [#924](https://github.com/fsprojects/FSharp.Formatting/issues/924)
7+
* Search dialog now auto-focuses the search input when opened, clears on close, and can be triggered with `Ctrl+K` / `Cmd+K` in addition to `/`.
78
* Add `dotnet fsdocs convert` command to convert a single `.md`, `.fsx`, or `.ipynb` file to HTML (or another output format) without building a full documentation site. [#811](https://github.com/fsprojects/FSharp.Formatting/issues/811)
89
* `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)
910
* `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)

build.fsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ let testStage =
4949
$"dotnet test {solutionFile} --configuration {configuration} --no-build --blame --logger trx --results-directory TestResults -tl"
5050
}
5151

52+
// Standalone doc-script type-check using the locally built fsdocs tool.
53+
// Assumes the solution has been built (e.g. after running the CI pipeline or
54+
// `dotnet build`). Catches type errors in .fsx documentation sources early,
55+
// matching the `--strict` check in the full GenerateDocs stage.
56+
let fsdocsLocalBin =
57+
let ext = if System.OperatingSystem.IsWindows() then ".exe" else ""
58+
$"src/fsdocs-tool/bin/Release/net10.0/fsdocs{ext}"
59+
60+
let checkDocScriptsStage =
61+
stage "CheckDocScripts" { run $"\"{fsdocsLocalBin}\" build --strict --clean --properties Configuration=Release" }
62+
5263
pipeline "CI" {
5364
lintStage
5465

@@ -68,6 +79,8 @@ pipeline "CI" {
6879

6980
testStage
7081

82+
checkDocScriptsStage
83+
7184
stage "GenerateDocs" {
7285
// Skip on Windows CI runners: docs are only deployed from Linux
7386
whenNot { envVar "RUNNER_OS" "Windows" }
@@ -92,6 +105,7 @@ pipeline "Verify" {
92105
lintStage
93106
testStage
94107
stage "Analyzers" { run "dotnet msbuild /t:AnalyzeSolution" }
108+
checkDocScriptsStage
95109
runIfOnlySpecified true
96110
}
97111

docs/content/fsdocs-search.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,23 @@ if (root && searchBtn) {
5151
const resultsElement = document.querySelector("dialog ul");
5252
const searchBox = document.querySelector("dialog input[type=search]");
5353

54-
searchBtn.addEventListener("click", () => {
54+
function openSearch() {
5555
searchDialog.showModal();
56-
})
56+
searchBox.focus();
57+
}
58+
59+
function closeSearch() {
60+
searchBox.value = '';
61+
empty.textContent = "Type something to start searching.";
62+
clearResults();
63+
searchDialog.close();
64+
}
65+
66+
searchBtn.addEventListener("click", openSearch)
5767

5868
searchDialog.addEventListener("click", ev => {
5969
if (ev.target.tagName === "DIALOG") {
60-
searchBox.value = '';
61-
searchDialog.close()
70+
closeSearch();
6271
}
6372
})
6473

@@ -112,13 +121,21 @@ if (root && searchBtn) {
112121
}
113122
});
114123

115-
window.addEventListener('keyup', ev => {
124+
window.addEventListener('keydown', ev => {
116125
if (ev.key === 'Escape' && searchDialog.open) {
117-
searchDialog.close();
126+
ev.preventDefault();
127+
closeSearch();
118128
}
119129

120-
if (ev.key === '/' && !searchDialog.open) {
121-
searchDialog.showModal();
130+
const focusedTag = document.activeElement?.tagName;
131+
const isTypingInInput = focusedTag === 'INPUT' || focusedTag === 'TEXTAREA';
132+
const isShortcut =
133+
(ev.key === '/' && !isTypingInInput) ||
134+
(ev.key === 'k' && (ev.ctrlKey || ev.metaKey));
135+
136+
if (isShortcut && !searchDialog.open) {
137+
ev.preventDefault();
138+
openSearch();
122139
}
123140
})
124141
} else {

docs/evaluation.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ let a = 10
158158
(*** include-value:a ***)"""
159159

160160
// Create evaluator and parse script
161-
let fsi = FsiEvaluator()
161+
let fsi = new FsiEvaluator()
162162

163163
let doc = Literate.ParseScriptString(content, fsiEvaluator = fsi)
164164

@@ -192,7 +192,7 @@ This can be done by calling `cref:M:FSharp.Formatting.Literate.Evaluation.FsiEva
192192
193193
*)
194194
// Create evaluator & register simple formatter for lists
195-
let fsiEvaluator = FsiEvaluator()
195+
let fsiEvaluator = new FsiEvaluator()
196196

197197
fsiEvaluator.RegisterTransformation(fun (o, ty, _executionCount) ->
198198
// If the type of value is an F# list, format it nicely

src/FSharp.Formatting.Literate/ParseScript.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,14 +370,14 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
370370
let sourceSnippets, diagnostics =
371371
CodeFormatter.ParseAndCheckSource(filePath, content, ctx.CompilerOptions, defines, onError)
372372

373-
let mutable fail = false
373+
let mutable hasErrors = false
374374

375375
for (SourceError((l0, c0), (l1, c1), kind, msg)) in diagnostics do
376376
printfn
377377
" %s: %s(%d,%d)-(%d,%d) %s"
378378
filePath
379379
(if kind = ErrorKind.Error then
380-
fail <- true
380+
hasErrors <- true
381381
"error"
382382
else
383383
"warning")
@@ -387,8 +387,8 @@ type internal ParseScript(parseOptions, ctx: CompilerContext) =
387387
c1
388388
msg
389389

390-
if fail then
391-
ctx.OnError "errors parsing or checking script"
390+
if hasErrors then
391+
ctx.OnError(sprintf "errors found in '%s'" filePath)
392392

393393
let parsedBlocks =
394394
[ for Snippet(name, lines) in sourceSnippets do

0 commit comments

Comments
 (0)