Skip to content

Add --ignoreuncategorized flag #953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/commandline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
33 changes: 29 additions & 4 deletions src/fsdocs-tool/BuildCommand.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1296,6 +1307,12 @@ type CoreBuildOptions(watch) =
[<Option("noapidocs", Default = false, Required = false, HelpText = "Disable generation of API docs.")>]
member val noapidocs = false with get, set

[<Option("ignoreuncategorized",
Default = false,
Required = false,
HelpText = "Disable generation of 'Other' category for uncategorized docs.")>]
member val ignoreuncategorized = false with get, set

[<Option("ignoreprojects", Default = false, Required = false, HelpText = "Disable project cracking.")>]
member val ignoreprojects = false with get, set

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -1847,7 +1871,8 @@ type CoreBuildOptions(watch) =
docContent.GetNavigationEntries(
this.input,
actualDocModels,
Some currentPagePath
Some currentPagePath,
ignoreUncategorized = this.ignoreuncategorized
)

globals
Expand Down
Loading