Skip to content
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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"rollForward": false
},
"fornax": {
"version": "0.13.1",
"version": "0.16.0-beta002",
"commands": [
"fornax"
],
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/build+test+deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

# old .NET required by old fornax version
- name: Setup old .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.x

- name: Restore tools
run: dotnet tool restore
- name: Restore dependencies
Expand Down
3 changes: 2 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ let DoNothing = ignore

let buildDir = "./build/"
let nugetDir = "./out/"
let docsDir = "./docs/"
let rootDir = __SOURCE_DIRECTORY__ |> DirectoryInfo

System.Environment.CurrentDirectory <- rootDir.FullName
Expand Down Expand Up @@ -153,7 +154,7 @@ Target.create "Test" (fun _ ->
)

Target.create "Docs" (fun _ ->
exec "dotnet" @"fornax build" "docs"
exec "dotnet" "fornax build" docsDir
)

// --------------------------------------------------------------------------------------
Expand Down
Binary file removed docs/_lib/Fornax.Core.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/config.fsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#r "_lib/Fornax.Core.dll"
#r "nuget: Fornax.Core, 0.16.0-beta002"

open Config

Expand Down
3 changes: 2 additions & 1 deletion docs/config.fsx.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ STORAGE: NONE
RESTRICTION: == netstandard2.0
NUGET
remote: https://api.nuget.org/v3/index.json
FSharp.Core (4.7.2)
FSharp.Compiler.Service (41.0.7)
FSharp.Core (6.0.7)
133 changes: 74 additions & 59 deletions docs/generators/apiref.fsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#r "../_lib/Fornax.Core.dll"
#r "../../packages/docs/Markdig/lib/netstandard2.0/Markdig.dll"
#r "../../packages/docs/Newtonsoft.Json/lib/netstandard2.0/Newtonsoft.Json.dll"
#r "../../packages/docs/FSharp.Formatting/lib/netstandard2.0/FSharp.MetadataFormat.dll"
#r "nuget: Fornax.Core, 0.16.0-beta002"
#r "nuget: Markdig, 0.41.3"
#r "nuget: FSharp.Formatting, 20.0.1"

#if !FORNAX
#load "../loaders/apirefloader.fsx"
Expand All @@ -10,7 +9,8 @@
#load "partials/layout.fsx"

open System
open FSharp.MetadataFormat
open System.Text.Json
open FSharp.Formatting.ApiDocs
open Html
open Apirefloader
open Markdig
Expand All @@ -21,15 +21,15 @@ let markdownPipeline =
.UseGridTables()
.Build()

let getComment (c: Comment) =
let getComment (c: ApiDocComment) =
let t =
c.RawData
|> List.map (fun n -> n.Value)
|> String.concat "\n\n"
Markdown.ToHtml(t, markdownPipeline)


let formatMember (m: Member) =
let formatMember (m: ApiDocMember) =
let attributes =
m.Attributes
|> List.filter (fun a -> a.FullName <> "Microsoft.FSharp.Core.CustomOperationAttribute")
Expand Down Expand Up @@ -62,7 +62,8 @@ let formatMember (m: Member) =
br []
br []
b [] [!! "Signature: "]
!!m.Details.Signature
match m.Details with
| ApiDocMemberDetails(usageHtml, _, _, _, _, _, _, _) -> !!usageHtml.HtmlText
br []
if not (attributes.IsEmpty) then
b [] [!! "Attributes:"]
Expand All @@ -72,103 +73,117 @@ let formatMember (m: Member) =
td [] [!! (getComment m.Comment)]
]

let generateType ctx (page: ApiPageInfo<Type>) =
let generateType ctx (page: ApiPageInfo<ApiDocEntity>) =
let t = page.Info
let body =
div [Class "api-page"] [
h2 [] [!! t.Name]
b [] [!! "Namespace: "]
a [Href ($"%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
a [Href ($"../%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
br []
b [] [!! "Parent: "]
a [Href ($"%s{page.ParentUrlName}.html")] [!! page.ParentName]
span [] [!! (getComment t.Comment)]
if page.ParentName <> page.NamespaceName then
b [] [!! "Parent Module: "]
a [Href ($"../%s{page.ParentUrlName}.html")] [!! page.ParentName]
br []
b [] [!! "Assembly: "]
!! t.Assembly.Name
br []
if not (String.IsNullOrWhiteSpace t.Category) then
b [] [!! "Category:"]
b [] [!! "Category: "]
!!t.Category
br []
if not (t.Attributes.IsEmpty) then
b [] [!! "Attributes:"]
b [] [!! "Attributes: "]
for a in t.Attributes do
br []
code [] [!! (a.Name)]
br []
br []
br []

table [] [
tr [] [
th [ Width "35%" ] [!!"Name"]
th [ Width "65%"] [!!"Description"]
]
if not t.Constructors.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Constructors"]]]
if not (t.Constructors : ApiDocMember list).IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Constructors"]]]
yield! t.Constructors |> List.map formatMember

if not t.InstanceMembers.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Instance Members"]]]
if not (t.InstanceMembers : ApiDocMember list).IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Instance Members"]]]
yield! t.InstanceMembers |> List.map formatMember

if not t.RecordFields.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Record Fields"]]]
yield! t.RecordFields |> List.map formatMember
// Record Fields from AllMembers
let recordFields = t.AllMembers |> List.filter (fun m -> m.Kind = ApiDocMemberKind.RecordField)
if not recordFields.IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Record Fields"]]]
yield! recordFields |> List.map formatMember

if not t.StaticMembers.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Static Members"]]]
if not (t.StaticMembers : ApiDocMember list).IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Static Members"]]]
yield! t.StaticMembers |> List.map formatMember

if not t.StaticParameters.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Static Parameters"]]]
yield! t.StaticParameters |> List.map formatMember
// Static Parameters from AllMembers
let staticParams = t.AllMembers |> List.filter (fun m -> m.Kind = ApiDocMemberKind.StaticParameter)
if not staticParams.IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Static Parameters"]]]
yield! staticParams |> List.map formatMember

if not t.UnionCases.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Union Cases"]]]
yield! t.UnionCases |> List.map formatMember
// Union Cases from AllMembers
let unionCases = t.AllMembers |> List.filter (fun m -> m.Kind = ApiDocMemberKind.UnionCase)
if not unionCases.IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Union Cases"]]]
yield! unionCases |> List.map formatMember
]
]
t.UrlName, Layout.layout ctx [body] t.Name
t.UrlBaseName, Layout.layout ctx [body] t.Name

let generateModule ctx (page: ApiPageInfo<Module>) =
let generateModule ctx (page: ApiPageInfo<ApiDocEntity>) =
let m = page.Info
let body =
div [Class "api-page"] [
h2 [] [!!m.Name]
h2 [] [!! m.Name]
b [] [!! "Namespace: "]
a [Href ($"%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
br []
b [] [!! "Parent: "]
a [Href ($"%s{page.ParentUrlName}.html")] [!! page.ParentName]
span [] [!! (getComment m.Comment)]
a [Href ($"../%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
br []
if page.ParentName <> page.NamespaceName then
b [] [!! "Parent Module: "]
a [Href ($"../%s{page.ParentUrlName}.html")] [!! page.ParentName]
br []
if not (String.IsNullOrWhiteSpace m.Category) then
b [] [!! "Category:"]
b [] [!! "Category: "]
!!m.Category
br []
br []

// Split NestedEntities into types and modules
let nestedTypes = m.NestedEntities |> List.filter (fun e -> e.IsTypeDefinition)
let nestedModules = m.NestedEntities |> List.filter (fun e -> not e.IsTypeDefinition)

if not m.NestedTypes.IsEmpty then
if not nestedTypes.IsEmpty then
b [] [!! "Declared Types"]
table [] [
tr [] [
th [ Width "35%" ] [!!"Type"]
th [ Width "65%"] [!!"Description"]
]
for t in m.NestedTypes do
for t in nestedTypes do
tr [] [
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
td [] [!! (getComment t.Comment)]
]
]
br []

if not m.NestedModules.IsEmpty then
if not nestedModules.IsEmpty then
b [] [!! "Declared Modules"]
table [] [
tr [] [
th [ Width "35%" ] [!!"Module"]
th [ Width "65%"] [!!"Description"]
]
for t in m.NestedModules do
for t in nestedModules do
tr [] [
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
td [] [!! (getComment t.Comment)]
]
]
br []

if not m.ValuesAndFuncs.IsEmpty then
if not (m.ValuesAndFuncs : ApiDocMember list).IsEmpty then
b [] [!! "Values and Functions"]
table [] [
tr [] [
Expand All @@ -179,7 +194,7 @@ let generateModule ctx (page: ApiPageInfo<Module>) =
]
br []

if not m.TypeExtensions.IsEmpty then
if not (m.TypeExtensions : ApiDocMember list).IsEmpty then
b [] [!! "Type Extensions"]
table [] [
tr [] [
Expand All @@ -189,45 +204,45 @@ let generateModule ctx (page: ApiPageInfo<Module>) =
yield! m.TypeExtensions |> List.map formatMember
]
]
m.UrlName, Layout.layout ctx [body] m.Name
m.UrlBaseName, Layout.layout ctx [body] m.Name

let generateNamespace ctx (allTypes: ApiPageInfo<ApiDocEntity> list) (ns: ApiDocNamespace) =
let namespaceTypes = allTypes |> List.filter (fun t -> t.NamespaceName = ns.Name && t.ParentName = ns.Name)

let generateNamespace ctx (n: Namespace) =
let body =
div [Class "api-page"] [
h2 [] [!!n.Name]

if not n.Types.IsEmpty then
h2 [] [!!ns.Name]

if not namespaceTypes.IsEmpty then
b [] [!! "Declared Types"]
table [] [
tr [] [
th [ Width "35%" ] [!!"Type"]
th [ Width "65%"] [!!"Description"]
]
for t in n.Types do
for t in namespaceTypes do
tr [] [
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
td [] [!!(getComment t.Comment)]
td [] [a [Href ($"%s{t.Info.UrlBaseName}.html")] [!! t.Info.Name ]]
td [] [!! (getComment t.Info.Comment)]
]
]
br []

if not n.Modules.IsEmpty then

if not (ns.Entities).IsEmpty then
b [] [!! "Declared Modules"]
table [] [
tr [] [
th [ Width "35%" ] [!!"Module"]
th [ Width "65%"] [!!"Description"]
]
for t in n.Modules do
for t in ns.Entities do
tr [] [
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
td [] [!! (getComment t.Comment)]
]
]
]
n.Name, Layout.layout ctx [body] (n.Name)
ns.Name, Layout.layout ctx [body] (ns.Name)


let generate' (ctx : SiteContents) =
Expand All @@ -238,10 +253,10 @@ let generate' (ctx : SiteContents) =
all
|> Seq.toList
|> List.collect (fun n ->
let name = n.GeneratorOutput.AssemblyGroup.Name
let name = n.GeneratorOutput.Collection.CollectionName
let namespaces =
n.GeneratorOutput.AssemblyGroup.Namespaces
|> List.map (generateNamespace ctx)
n.GeneratorOutput.Collection.Namespaces
|> List.map (generateNamespace ctx n.Types)

let modules =
n.Modules
Expand Down
Loading
Loading