@@ -30,64 +30,86 @@ let rec collectModules pn pu nn nu (m: ApiDocEntity) =
3030
3131let loader ( projectRoot : string ) ( siteContet : SiteContents ) =
3232 try
33- // Try to find FSharpLint.Core.dll in the project build output
34- let projectDir = Path.Combine( projectRoot, " .." , " src" , " FSharpLint.Core" )
35- let binDir = Path.Combine( projectDir, " bin" , " Release" , " net9.0" )
36- let dllPath = Path.Combine( binDir, " FSharpLint.Core.dll" )
37-
38- let dlls =
39- [
40- " FSharpLint.Core" , dllPath
33+ // We need the console location as it contains all the dependencies
34+ let projectDir = Path.Combine( projectRoot, " .." , " src" , " FSharpLint.Console" )
35+ let dotNetMoniker = " net9.0"
36+ let projectName = " FSharpLint.Console"
37+ let projectArtifactName = " FSharpLint.Core.dll"
38+ // Try multiple possible locations for the assembly
39+ let possiblePaths = [
40+ // CI build output
41+ Path.Combine( " .." , " build" , projectArtifactName)
42+ // Release build
43+ Path.Combine( projectDir, " bin" , " Release" , dotNetMoniker, projectArtifactName)
44+ // Debug build
45+ Path.Combine( projectDir, " bin" , " Debug" , dotNetMoniker, projectArtifactName)
46+ // Default build output (no custom output path)
47+ Path.Combine( projectDir, " bin" , " Release" , projectArtifactName)
48+ Path.Combine( projectDir, " bin" , " Debug" , projectArtifactName)
4149 ]
42- let libs =
43- [
44- binDir
45- ]
46- for ( label, dll) in dlls do
47- if File.Exists dll then
48- let inputs = [ ApiDocInput.FromFile( dll)]
49- let output = ApiDocs.GenerateModel( inputs, label, [], libDirs = libs)
5050
51- let allModules =
52- output.Collection.Namespaces
53- |> List.collect ( fun n ->
54- List.collect ( collectModules n.Name n.Name n.Name n.Name) n.Entities
55- )
51+ let foundDll = possiblePaths |> List.tryFind File.Exists
52+
53+ match foundDll with
54+ | Some dllPath ->
55+ let binDir = Path.GetDirectoryName( dllPath)
56+ printfn $" Found assembly at: %s {dllPath}"
57+ printfn $" Using lib directory: %s {binDir}"
58+
59+ let libs = [ binDir]
60+
61+ // Try to load with minimal dependencies first
62+ let inputs = [ ApiDocInput.FromFile( dllPath, mdcomments = true )]
63+ try
64+ let output = ApiDocs.GenerateModel( inputs, projectName, [], libDirs = libs)
65+
66+ let allModules =
67+ output.Collection.Namespaces
68+ |> List.collect ( fun n ->
69+ List.collect ( collectModules n.Name n.Name n.Name n.Name) n.Entities
70+ )
5671
57- let allTypes =
58- [
59- yield !
60- output.Collection.Namespaces
61- |> List.collect ( fun n ->
62- n.Entities |> List.choose ( fun t ->
63- if t.IsTypeDefinition then
64- Some { ParentName = n.Name; ParentUrlName = n.Name; NamespaceName = n.Name; NamespaceUrlName = n.Name; Info = t}
65- else
66- None)
67- )
68- yield !
69- allModules
70- |> List.collect ( fun n ->
71- // Get nested types from nested entities
72- n.Info.NestedEntities
73- |> List.choose ( fun e ->
74- if e.IsTypeDefinition then
75- Some { ParentName = n.Info.Name; ParentUrlName = n.Info.UrlBaseName; NamespaceName = n.NamespaceName; NamespaceUrlName = n.NamespaceUrlName; Info = e}
76- else
77- None)
78- )
79- ]
80- let entities = {
81- Label = label
82- Modules = allModules
83- Types = allTypes
84- GeneratorOutput = output
85- }
86- siteContet.Add entities
87- else
88- printfn " Warning: Could not find assembly at %s " dll
72+ let allTypes =
73+ [
74+ yield !
75+ output.Collection.Namespaces
76+ |> List.collect ( fun n ->
77+ n.Entities |> List.choose ( fun t ->
78+ if t.IsTypeDefinition then
79+ Some { ParentName = n.Name; ParentUrlName = n.Name; NamespaceName = n.Name; NamespaceUrlName = n.Name; Info = t}
80+ else
81+ None)
82+ )
83+ yield !
84+ allModules
85+ |> List.collect ( fun n ->
86+ // Get nested types from nested entities
87+ n.Info.NestedEntities
88+ |> List.choose ( fun e ->
89+ if e.IsTypeDefinition then
90+ Some { ParentName = n.Info.Name; ParentUrlName = n.Info.UrlBaseName; NamespaceName = n.NamespaceName; NamespaceUrlName = n.NamespaceUrlName; Info = e}
91+ else
92+ None)
93+ )
94+ ]
95+ let entities = {
96+ Label = " FSharpLint.Core"
97+ Modules = allModules
98+ Types = allTypes
99+ GeneratorOutput = output
100+ }
101+ siteContet.Add entities
102+ printfn $" Successfully loaded API documentation for {projectName}"
103+ with
104+ | ex ->
105+ printfn $" Failed to generate API docs from %s {dllPath}: %A {ex}"
106+ printfn " Continuing without API documentation..."
107+ | None ->
108+ printfn $" Warning: Could not find {projectArtifactName} in any of the expected locations:"
109+ possiblePaths |> List.iter ( printfn " - %s " )
110+ printfn " API documentation will not be generated."
89111 with
90112 | ex ->
91- printfn " %A " ex
113+ printfn " Error in API reference loader: %A " ex
92114
93115 siteContet
0 commit comments