diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4c13f0b8..4e11e755 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,10 @@ # Changelog +## 21.0.0-beta-005 - 2025-04-23 + +### Added +* Add --ignoreuncategorized flag. [#953](https://github.com/fsprojects/FSharp.Formatting/pull/953) + ## 21.0.0-beta-004 - 2024-11-20 ### Changed diff --git a/docs/commandline.md b/docs/commandline.md index 3f460cb9..0abff1ae 100644 --- a/docs/commandline.md +++ b/docs/commandline.md @@ -26,6 +26,7 @@ The command line options accepted are: | `--input` | Input directory of content (default: `docs`) | | `--projects` | Project files to build API docs for outputs, defaults to all packable projects | | `--output` | Output Directory (default 'output' for 'build' and 'tmp/watch' for 'watch') | +| `--ignoreuncategorized` | Disable generation of the 'Other' category in the navigation bar for uncategorized docs | | `--noapidocs` | Disable generation of API docs | | `--ignoreprojects` | Disable project cracking | | `--eval` | Evaluate F# fragments in scripts | diff --git a/src/fsdocs-tool/BuildCommand.fs b/src/fsdocs-tool/BuildCommand.fs index d10d24d1..457c0530 100644 --- a/src/fsdocs-tool/BuildCommand.fs +++ b/src/fsdocs-tool/BuildCommand.fs @@ -687,8 +687,12 @@ type internal DocContent | _ -> () |] member _.GetNavigationEntries - (input, docModels: (string * bool * LiterateDocModel) list, currentPagePath: string option) - = + ( + input, + docModels: (string * bool * LiterateDocModel) list, + currentPagePath: string option, + ignoreUncategorized: bool + ) = let modelsForList = [ for thing in docModels do match thing with @@ -704,8 +708,15 @@ type internal DocContent | Some currentPagePath -> currentPagePath = inputFileFullPath } | _ -> () ] + let excludeUncategorized = + if ignoreUncategorized then + List.filter (fun (model: LiterateDocModel) -> model.Category.IsSome) + else + id + let modelsByCategory = modelsForList + |> excludeUncategorized |> List.groupBy (fun (model) -> model.Category) |> List.sortBy (fun (_, ms) -> match ms.[0].CategoryIndex with @@ -1296,6 +1307,12 @@ type CoreBuildOptions(watch) = [] member val noapidocs = false with get, set + [] + member val ignoreuncategorized = false with get, set + [] member val ignoreprojects = false with get, set @@ -1797,7 +1814,14 @@ type CoreBuildOptions(watch) = let docModels = docContent.Convert(this.input, defaultTemplate, extraInputs) let actualDocModels = docModels |> List.map fst |> List.choose id let extrasForSearchIndex = docContent.GetSearchIndexEntries(actualDocModels) - let navEntriesWithoutActivePage = docContent.GetNavigationEntries(this.input, actualDocModels, None) + + let navEntriesWithoutActivePage = + docContent.GetNavigationEntries( + this.input, + actualDocModels, + None, + ignoreUncategorized = this.ignoreuncategorized + ) let headTemplateContent = let headTemplatePath = Path.Combine(this.input, "_head.html") @@ -1847,7 +1871,8 @@ type CoreBuildOptions(watch) = docContent.GetNavigationEntries( this.input, actualDocModels, - Some currentPagePath + Some currentPagePath, + ignoreUncategorized = this.ignoreuncategorized ) globals