-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial incomplete and most likely not working impl * Lines * EOL * Trying to plumb in md * More extension hacking * Multiple tweaks * fixed extensions * supporting unordered list in md formatter * Multiple tweaks * basic table and image support for md formatting * rendering entities in GenerateMarkdown * Comment on copy/paste * Fixed rendering of parent module * Made table generation working * Multiple tweaks * added basic members rendering * added secaping pipeline character in table rendering * Multiple tweaks: * better member rendering * support for multiple paragraphs in table cells * Multiple tweaks: * only write paragraphs if there is content * render empty cells in table as nbsp to keep table structure * Member rendering improvements * Put remarks in the right place * Fixed choosing API docs format * also added missing Md cases for Literate * Extracting common logic #1 * Removed colon * Fixed the first interface not rendering bug Cleaned up redundant comments * Multiple fixes * finished md implementation * more api model categorisation refactorisation * Renamed files * Multiple fixes * made the user responsible for escaping pipeline chars * replaced nbsp by normal spaces * Using empty map for links * Clean up * Encode pipeline in member's name * Tests WIP * Fixed test * Fixed most of the tests * Fixed another test and removed excessive spaces * Removed redundant case * Converted interpolation to sprintf * Removed nameof usage * Multiple tweaks * disabled a test for what I think might not be an issue * fixed a failing test Co-authored-by: queil <[email protected]> Co-authored-by: Phillip Carter <[email protected]> Co-authored-by: Don Syme <[email protected]>
- Loading branch information
1 parent
9148ad7
commit 53f0772
Showing
19 changed files
with
1,043 additions
and
388 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
[<RequireQualifiedAccess>] | ||
module internal FSharp.Formatting.ApiDocs.Categorise | ||
|
||
open System | ||
|
||
// Honour the CategoryIndex to put the categories in the right order | ||
let private getSortedCategories xs exclude category categoryIndex = | ||
xs | ||
|> List.filter (exclude >> not) | ||
|> List.groupBy (category) | ||
|> List.map (fun (cat, xs) -> (cat, xs, xs |> List.minBy (categoryIndex))) | ||
|> List.sortBy (fun (cat, _xs, x) -> categoryIndex x, cat) | ||
|> List.map (fun (cat, xs, _x) -> cat, xs) | ||
|
||
// Group all members by their category | ||
let getMembersByCategory (members:ApiDocMember list) = | ||
getSortedCategories members (fun m -> m.Exclude) (fun m -> m.Category) (fun m -> m.CategoryIndex) | ||
|> List.mapi (fun i (key, elems) -> | ||
let elems = elems |> List.sortBy (fun m -> m.Name) | ||
let name = if String.IsNullOrEmpty(key) then "Other module members" else key | ||
(i, elems, name)) | ||
|
||
let entities (nsIndex: int, ns: ApiDocNamespace, suppress) = | ||
let entities = ns.Entities | ||
|
||
let categories = | ||
getSortedCategories entities (fun (m:ApiDocEntity) -> m.Exclude) (fun (m:ApiDocEntity) -> m.Category) (fun (m:ApiDocEntity) -> m.CategoryIndex) | ||
|
||
let allByCategory = | ||
[ for (catIndex, (categoryName, (categoryEntities: ApiDocEntity list))) in Seq.indexed categories do | ||
let categoryName = (if String.IsNullOrEmpty(categoryName) then "Other namespace members" else categoryName) | ||
let index = String.Format("{0}_{1}", nsIndex, catIndex) | ||
let categoryEntities = | ||
// When calculating list-of-namespaces suppress some entries | ||
// Some bespoke hacks to make FSharp.Core docs look ok. | ||
// | ||
// TODO: use <exclude /> to do these, or work out if there's a better way | ||
if suppress then | ||
categoryEntities | ||
|
||
// Remove FSharp.Data.UnitSystems.SI from the list-of-namespaces | ||
// display - it's just so rarely used, has long names and dominates the docs. | ||
// | ||
// See https://github.com/fsharp/fsharp-core-docs/issues/57, we may rethink this | ||
|> List.filter (fun e -> not (e.Symbol.Namespace = Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitSymbols")) | ||
|> List.filter (fun e -> not (e.Symbol.Namespace = Some "Microsoft.FSharp.Data.UnitSystems.SI.UnitNames")) | ||
// Don't show 'AnonymousObject' in list-of-namespaces navigation | ||
|> List.filter (fun e -> not (e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.RuntimeHelpers" && e.Symbol.DisplayName = "AnonymousObject")) | ||
// Don't show 'FSharp.Linq.QueryRunExtensions' in list-of-namespaces navigation | ||
|> List.filter (fun e -> not (e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions" && e.Symbol.DisplayName = "LowPriority")) | ||
|> List.filter (fun e -> not (e.Symbol.Namespace = Some "Microsoft.FSharp.Linq.QueryRunExtensions" && e.Symbol.DisplayName = "HighPriority")) | ||
else | ||
categoryEntities | ||
|
||
// We currently suppress all obsolete entries all the time | ||
let categoryEntities = | ||
categoryEntities | ||
|> List.filter (fun e -> not e.IsObsolete) | ||
|
||
let categoryEntities = | ||
categoryEntities | ||
|> List.sortBy (fun e -> | ||
(e.Symbol.DisplayName.ToLowerInvariant(), e.Symbol.GenericParameters.Count, | ||
e.Name, (if e.IsTypeDefinition then e.UrlBaseName else "ZZZ"))) | ||
|
||
if categoryEntities.Length > 0 then | ||
yield {| CategoryName = categoryName | ||
CategoryIndex = index | ||
CategoryEntites = categoryEntities |} ] | ||
|
||
allByCategory | ||
|
||
let model apiDocModel = | ||
[ for (nsIndex, ns) in Seq.indexed apiDocModel.Collection.Namespaces do | ||
let allByCategory = entities (nsIndex, ns, true) | ||
if allByCategory.Length > 0 then | ||
allByCategory, ns ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.