Skip to content

Commit 8cff1f2

Browse files
authored
Merge pull request #736 from fsprojects/fornax-0.16.0-beta002
Migrated `Fornax` to `0.16.0-beta002`
2 parents a2b2d94 + b173d9f commit 8cff1f2

File tree

19 files changed

+269
-201
lines changed

19 files changed

+269
-201
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rollForward": false
1111
},
1212
"fornax": {
13-
"version": "0.13.1",
13+
"version": "0.16.0-beta002",
1414
"commands": [
1515
"fornax"
1616
],

.github/workflows/build+test+deploy.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ jobs:
107107
with:
108108
dotnet-version: ${{ env.DOTNET_VERSION }}
109109

110-
# old .NET required by old fornax version
111-
- name: Setup old .NET
112-
uses: actions/setup-dotnet@v3
113-
with:
114-
dotnet-version: 3.1.x
115-
116110
- name: Restore tools
117111
run: dotnet tool restore
118112
- name: Restore dependencies

build.fsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ let DoNothing = ignore
8484

8585
let buildDir = "./build/"
8686
let nugetDir = "./out/"
87+
let docsDir = "./docs/"
8788
let rootDir = __SOURCE_DIRECTORY__ |> DirectoryInfo
8889

8990
System.Environment.CurrentDirectory <- rootDir.FullName
@@ -153,7 +154,7 @@ Target.create "Test" (fun _ ->
153154
)
154155

155156
Target.create "Docs" (fun _ ->
156-
exec "dotnet" @"fornax build" "docs"
157+
exec "dotnet" "fornax build" docsDir
157158
)
158159

159160
// --------------------------------------------------------------------------------------

docs/_lib/Fornax.Core.dll

-729 KB
Binary file not shown.

docs/config.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#r "_lib/Fornax.Core.dll"
1+
#r "nuget: Fornax.Core, 0.16.0-beta002"
22

33
open Config
44

docs/config.fsx.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ STORAGE: NONE
22
RESTRICTION: == netstandard2.0
33
NUGET
44
remote: https://api.nuget.org/v3/index.json
5-
FSharp.Core (4.7.2)
5+
FSharp.Compiler.Service (41.0.7)
6+
FSharp.Core (6.0.7)

docs/generators/apiref.fsx

Lines changed: 74 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#r "../_lib/Fornax.Core.dll"
2-
#r "../../packages/docs/Markdig/lib/netstandard2.0/Markdig.dll"
3-
#r "../../packages/docs/Newtonsoft.Json/lib/netstandard2.0/Newtonsoft.Json.dll"
4-
#r "../../packages/docs/FSharp.Formatting/lib/netstandard2.0/FSharp.MetadataFormat.dll"
1+
#r "nuget: Fornax.Core, 0.16.0-beta002"
2+
#r "nuget: Markdig, 0.41.3"
3+
#r "nuget: FSharp.Formatting, 20.0.1"
54

65
#if !FORNAX
76
#load "../loaders/apirefloader.fsx"
@@ -10,7 +9,8 @@
109
#load "partials/layout.fsx"
1110

1211
open System
13-
open FSharp.MetadataFormat
12+
open System.Text.Json
13+
open FSharp.Formatting.ApiDocs
1414
open Html
1515
open Apirefloader
1616
open Markdig
@@ -21,15 +21,15 @@ let markdownPipeline =
2121
.UseGridTables()
2222
.Build()
2323

24-
let getComment (c: Comment) =
24+
let getComment (c: ApiDocComment) =
2525
let t =
2626
c.RawData
2727
|> List.map (fun n -> n.Value)
2828
|> String.concat "\n\n"
2929
Markdown.ToHtml(t, markdownPipeline)
3030

3131

32-
let formatMember (m: Member) =
32+
let formatMember (m: ApiDocMember) =
3333
let attributes =
3434
m.Attributes
3535
|> List.filter (fun a -> a.FullName <> "Microsoft.FSharp.Core.CustomOperationAttribute")
@@ -62,7 +62,8 @@ let formatMember (m: Member) =
6262
br []
6363
br []
6464
b [] [!! "Signature: "]
65-
!!m.Details.Signature
65+
match m.Details with
66+
| ApiDocMemberDetails(usageHtml, _, _, _, _, _, _, _) -> !!usageHtml.HtmlText
6667
br []
6768
if not (attributes.IsEmpty) then
6869
b [] [!! "Attributes:"]
@@ -72,103 +73,117 @@ let formatMember (m: Member) =
7273
td [] [!! (getComment m.Comment)]
7374
]
7475

75-
let generateType ctx (page: ApiPageInfo<Type>) =
76+
let generateType ctx (page: ApiPageInfo<ApiDocEntity>) =
7677
let t = page.Info
7778
let body =
7879
div [Class "api-page"] [
7980
h2 [] [!! t.Name]
8081
b [] [!! "Namespace: "]
81-
a [Href ($"%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
82+
a [Href ($"../%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
8283
br []
83-
b [] [!! "Parent: "]
84-
a [Href ($"%s{page.ParentUrlName}.html")] [!! page.ParentName]
85-
span [] [!! (getComment t.Comment)]
84+
if page.ParentName <> page.NamespaceName then
85+
b [] [!! "Parent Module: "]
86+
a [Href ($"../%s{page.ParentUrlName}.html")] [!! page.ParentName]
87+
br []
88+
b [] [!! "Assembly: "]
89+
!! t.Assembly.Name
8690
br []
8791
if not (String.IsNullOrWhiteSpace t.Category) then
88-
b [] [!! "Category:"]
92+
b [] [!! "Category: "]
8993
!!t.Category
9094
br []
9195
if not (t.Attributes.IsEmpty) then
92-
b [] [!! "Attributes:"]
96+
b [] [!! "Attributes: "]
9397
for a in t.Attributes do
94-
br []
9598
code [] [!! (a.Name)]
96-
br []
99+
br []
100+
br []
97101

98102
table [] [
99103
tr [] [
100104
th [ Width "35%" ] [!!"Name"]
101105
th [ Width "65%"] [!!"Description"]
102106
]
103-
if not t.Constructors.IsEmpty then tr [] [ td [ColSpan 3. ] [ b [] [!! "Constructors"]]]
107+
if not (t.Constructors : ApiDocMember list).IsEmpty then tr [] [ td [ColSpan 2. ] [ b [] [!! "Constructors"]]]
104108
yield! t.Constructors |> List.map formatMember
105109

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

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

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

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

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

124-
let generateModule ctx (page: ApiPageInfo<Module>) =
134+
let generateModule ctx (page: ApiPageInfo<ApiDocEntity>) =
125135
let m = page.Info
126136
let body =
127137
div [Class "api-page"] [
128-
h2 [] [!!m.Name]
138+
h2 [] [!! m.Name]
129139
b [] [!! "Namespace: "]
130-
a [Href ($"%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
131-
br []
132-
b [] [!! "Parent: "]
133-
a [Href ($"%s{page.ParentUrlName}.html")] [!! page.ParentName]
134-
span [] [!! (getComment m.Comment)]
140+
a [Href ($"../%s{page.NamespaceUrlName}.html")] [!! page.NamespaceName]
135141
br []
142+
if page.ParentName <> page.NamespaceName then
143+
b [] [!! "Parent Module: "]
144+
a [Href ($"../%s{page.ParentUrlName}.html")] [!! page.ParentName]
145+
br []
136146
if not (String.IsNullOrWhiteSpace m.Category) then
137-
b [] [!! "Category:"]
147+
b [] [!! "Category: "]
138148
!!m.Category
139149
br []
150+
br []
151+
152+
// Split NestedEntities into types and modules
153+
let nestedTypes = m.NestedEntities |> List.filter (fun e -> e.IsTypeDefinition)
154+
let nestedModules = m.NestedEntities |> List.filter (fun e -> not e.IsTypeDefinition)
140155

141-
if not m.NestedTypes.IsEmpty then
156+
if not nestedTypes.IsEmpty then
142157
b [] [!! "Declared Types"]
143158
table [] [
144159
tr [] [
145160
th [ Width "35%" ] [!!"Type"]
146161
th [ Width "65%"] [!!"Description"]
147162
]
148-
for t in m.NestedTypes do
163+
for t in nestedTypes do
149164
tr [] [
150-
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
165+
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
151166
td [] [!! (getComment t.Comment)]
152167
]
153168
]
154169
br []
155170

156-
if not m.NestedModules.IsEmpty then
171+
if not nestedModules.IsEmpty then
157172
b [] [!! "Declared Modules"]
158173
table [] [
159174
tr [] [
160175
th [ Width "35%" ] [!!"Module"]
161176
th [ Width "65%"] [!!"Description"]
162177
]
163-
for t in m.NestedModules do
178+
for t in nestedModules do
164179
tr [] [
165-
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
180+
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
166181
td [] [!! (getComment t.Comment)]
167182
]
168183
]
169184
br []
170185

171-
if not m.ValuesAndFuncs.IsEmpty then
186+
if not (m.ValuesAndFuncs : ApiDocMember list).IsEmpty then
172187
b [] [!! "Values and Functions"]
173188
table [] [
174189
tr [] [
@@ -179,7 +194,7 @@ let generateModule ctx (page: ApiPageInfo<Module>) =
179194
]
180195
br []
181196

182-
if not m.TypeExtensions.IsEmpty then
197+
if not (m.TypeExtensions : ApiDocMember list).IsEmpty then
183198
b [] [!! "Type Extensions"]
184199
table [] [
185200
tr [] [
@@ -189,45 +204,45 @@ let generateModule ctx (page: ApiPageInfo<Module>) =
189204
yield! m.TypeExtensions |> List.map formatMember
190205
]
191206
]
192-
m.UrlName, Layout.layout ctx [body] m.Name
207+
m.UrlBaseName, Layout.layout ctx [body] m.Name
208+
209+
let generateNamespace ctx (allTypes: ApiPageInfo<ApiDocEntity> list) (ns: ApiDocNamespace) =
210+
let namespaceTypes = allTypes |> List.filter (fun t -> t.NamespaceName = ns.Name && t.ParentName = ns.Name)
193211

194-
let generateNamespace ctx (n: Namespace) =
195212
let body =
196213
div [Class "api-page"] [
197-
h2 [] [!!n.Name]
198-
199-
if not n.Types.IsEmpty then
214+
h2 [] [!!ns.Name]
200215

216+
if not namespaceTypes.IsEmpty then
201217
b [] [!! "Declared Types"]
202218
table [] [
203219
tr [] [
204220
th [ Width "35%" ] [!!"Type"]
205221
th [ Width "65%"] [!!"Description"]
206222
]
207-
for t in n.Types do
223+
for t in namespaceTypes do
208224
tr [] [
209-
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
210-
td [] [!!(getComment t.Comment)]
225+
td [] [a [Href ($"%s{t.Info.UrlBaseName}.html")] [!! t.Info.Name ]]
226+
td [] [!! (getComment t.Info.Comment)]
211227
]
212228
]
213229
br []
214230

215-
if not n.Modules.IsEmpty then
216-
231+
if not (ns.Entities).IsEmpty then
217232
b [] [!! "Declared Modules"]
218233
table [] [
219234
tr [] [
220235
th [ Width "35%" ] [!!"Module"]
221236
th [ Width "65%"] [!!"Description"]
222237
]
223-
for t in n.Modules do
238+
for t in ns.Entities do
224239
tr [] [
225-
td [] [a [Href ($"%s{t.UrlName}.html")] [!! t.Name ]]
240+
td [] [a [Href ($"%s{t.UrlBaseName}.html")] [!! t.Name ]]
226241
td [] [!! (getComment t.Comment)]
227242
]
228243
]
229244
]
230-
n.Name, Layout.layout ctx [body] (n.Name)
245+
ns.Name, Layout.layout ctx [body] (ns.Name)
231246

232247

233248
let generate' (ctx : SiteContents) =
@@ -238,10 +253,10 @@ let generate' (ctx : SiteContents) =
238253
all
239254
|> Seq.toList
240255
|> List.collect (fun n ->
241-
let name = n.GeneratorOutput.AssemblyGroup.Name
256+
let name = n.GeneratorOutput.Collection.CollectionName
242257
let namespaces =
243-
n.GeneratorOutput.AssemblyGroup.Namespaces
244-
|> List.map (generateNamespace ctx)
258+
n.GeneratorOutput.Collection.Namespaces
259+
|> List.map (generateNamespace ctx n.Types)
245260

246261
let modules =
247262
n.Modules

0 commit comments

Comments
 (0)