Skip to content

Commit

Permalink
update to Ionide.ProjInfo, use computed args for references in API do…
Browse files Browse the repository at this point in the history
…c generation (#663)

* update to Ionide.ProjInfo, use computed args

* update to Ionide.ProjInfo, use computed args

* try fix

* try fix

* try fix

* use local copy of external files

Co-authored-by: Don Syme <[email protected]>
  • Loading branch information
dsyme and Don Syme authored Apr 14, 2021
1 parent 4e8e70e commit e35dc9c
Show file tree
Hide file tree
Showing 20 changed files with 1,392 additions and 322 deletions.
7 changes: 7 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 11.0.1
* update to Ionide.ProjInfo
* use computed args for references in API doc generation
* Fix #616
* Fix #662
* Fix #646

## 10.1.1
* Switch to cleaner default styling based on DiffSharp styles
* Change `fsdocs-menu` to `fsdocs-nav`
Expand Down
4 changes: 2 additions & 2 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ nuget CommandLineParser ~> 2.8
nuget Microsoft.Build.Framework
nuget Microsoft.Build.Tasks.Core
nuget Microsoft.Build.Utilities.Core
nuget Dotnet.ProjInfo
nuget Dotnet.ProjInfo.Workspace
nuget Ionide.ProjInfo
nuget Ionide.ProjInfo.Sln
nuget Newtonsoft.Json
nuget Suave
nuget System.Memory
Expand Down
335 changes: 172 additions & 163 deletions paket.lock

Large diffs are not rendered by default.

22 changes: 1 addition & 21 deletions src/FSharp.Formatting.ApiDocs/GenerateModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2146,25 +2146,6 @@ type ApiDocModel internal (substitutions, collection, entityInfos, root, qualify
let dllFiles = projects |> List.map (fun p -> Path.GetFullPath p.Path)
let urlRangeHighlight = defaultArg urlRangeHighlight (fun url start stop -> String.Format("{0}#L{1}-{2}", url, start, stop))

// When resolving assemblies, look in folders where all DLLs live
AppDomain.CurrentDomain.add_AssemblyResolve(System.ResolveEventHandler(fun o e ->
Log.verbf "Resolving assembly: %s" e.Name
let asmName = System.Reflection.AssemblyName(e.Name)
let asmOpt =
dllFiles |> Seq.tryPick (fun dll ->
let root = Path.GetDirectoryName(dll)
let file = root @@ (asmName.Name + ".dll")
if File.Exists(file) then
try
let bytes = File.ReadAllBytes(file)
Some(System.Reflection.Assembly.Load(bytes))
with e ->
printfn "Couldn't load Assembly\n%s\n%s" e.Message e.StackTrace
None
else None )
defaultArg asmOpt null
))

// Compiler arguments used when formatting code snippets inside Markdown comments
let codeFormatCompilerArgs =
[ for dir in libDirs do yield sprintf "-I:\"%s\"" dir
Expand All @@ -2173,8 +2154,7 @@ type ApiDocModel internal (substitutions, collection, entityInfos, root, qualify

printfn " loading %d assemblies..." dllFiles.Length
let resolvedList =
//FSharpAssembly.LoadFiles(projects, libDirs, otherFlags = otherFlags)
FSharpAssembly.LoadFiles(dllFiles, libDirs, otherFlags = otherFlags, manualResolve=true)
FSharpAssembly.LoadFiles(dllFiles, libDirs, otherFlags = otherFlags)
|> List.zip projects

// generate the names for the html files beforehand so we can resolve <see cref=""/> links.
Expand Down
46 changes: 38 additions & 8 deletions src/FSharp.Formatting.CommandTool/BuildCommand.fs
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,29 @@ type CoreBuildOptions(watch) =
(projects |> List.map getTime |> List.toArray))
Utils.cacheBinary cacheFile
(fun (_, key2) -> key1 = key2)
(fun () -> Crack.crackProjects (this.strict, this.extraMsbuildProperties, userRoot, userCollectionName, userParameters, projects), key1)
(fun () ->
let props =
this.extraMsbuildProperties
|> Seq.toList
|> List.map (fun s ->
let arr = s.Split("=")
if arr.Length > 1 then
arr.[0], String.concat "=" arr.[1..]
else
failwith "properties must be of the form 'PropName=PropValue'")
Crack.crackProjects (this.strict, props, userRoot, userCollectionName, userParameters, projects), key1)

if crackedProjects.Length > 0 then
printfn ""
printfn "Inputs for API Docs:"
for (dllFile, _, _, _, _, _, _, _, _) in crackedProjects do
for (dllFile, _, _, _, _, _, _, _, _, _) in crackedProjects do
printfn " %s" dllFile

for (dllFile, _, _, _, _, _, _, _, _) in crackedProjects do
//printfn "Comand lines for API Docs:"
//for (_, runArguments, _, _, _, _, _, _, _, _) in crackedProjects do
// printfn " %O" runArguments

for (dllFile, _, _, _, _, _, _, _, _, _) in crackedProjects do
if not (File.Exists dllFile) then
let msg = sprintf "*** %s does not exist, has it been built? You may need to provide --properties Configuration=Release." dllFile
if this.strict then
Expand All @@ -440,13 +454,13 @@ type CoreBuildOptions(watch) =

// The substitutions may differ for some projects due to different settings in the project files, if so show that
let pd = dict docsParameters
for (dllFile, _, _, _, _, _, _, _, projectParameters) in crackedProjects do
for (dllFile, _, _, _, _, _, _, _, _, projectParameters) in crackedProjects do
for (((ParamKey pkv2) as pk2) , p2) in projectParameters do
if pd.ContainsKey pk2 && pd.[pk2] <> p2 then
printfn " (%s) %s --> %s" (Path.GetFileNameWithoutExtension(dllFile)) pkv2 p2

let apiDocInputs =
[ for (dllFile, repoUrlOption, repoBranchOption, repoTypeOption, projectMarkdownComments, projectWarn, projectSourceFolder, projectSourceRepo, projectParameters) in crackedProjects ->
[ for (dllFile, _, repoUrlOption, repoBranchOption, repoTypeOption, projectMarkdownComments, projectWarn, projectSourceFolder, projectSourceRepo, projectParameters) in crackedProjects ->
let sourceRepo =
match projectSourceRepo with
| Some s -> Some s
Expand Down Expand Up @@ -482,6 +496,22 @@ type CoreBuildOptions(watch) =
Warn = projectWarn;
PublicOnly = not this.nonpublic } ]

// Compute the merge of all referenced DLLs across all projects
// so they can be resolved during API doc generation.
//
// TODO: This is inaccurate: the different projects might not be referencing the same DLLs.
// We should do doc generation for each output of each proejct separately
let apiDocOtherFlags =
[ for (_dllFile, otherFlags, _, _, _, _, _, _, _, _) in crackedProjects do
for otherFlag in otherFlags do
if otherFlag.StartsWith("-r:") then
if File.Exists(otherFlag.[3..]) then
yield otherFlag
else
printfn "NOTE: the reference '%s' was not seen on disk, ignoring" otherFlag ]
// TODO: This 'distinctBy' is merging references that may be inconsistent across the project set
|> List.distinctBy (fun ref -> Path.GetFileName(ref.[3..]))

let output =
if this.output = "" then
if watch then "tmp/watch" else "output"
Expand Down Expand Up @@ -584,7 +614,7 @@ type CoreBuildOptions(watch) =
printfn ""
printfn "API docs:"
printfn " generating model for %d assemblies in API docs..." apiDocInputs.Length

let model, globals, index, phase2 =
match outputKind with
| OutputKind.Html ->
Expand All @@ -595,7 +625,7 @@ type CoreBuildOptions(watch) =
substitutions = docsParameters,
qualify = this.qualify,
?template = initialTemplate2,
otherFlags = Seq.toList this.fscoptions,
otherFlags = apiDocOtherFlags @ Seq.toList this.fscoptions,
root = root,
libDirs = paths,
strict = this.strict
Expand All @@ -608,7 +638,7 @@ type CoreBuildOptions(watch) =
substitutions = docsParameters,
qualify = this.qualify,
?template = initialTemplate2,
otherFlags = Seq.toList this.fscoptions,
otherFlags = apiDocOtherFlags @ Seq.toList this.fscoptions,
root = root,
libDirs = paths,
strict = this.strict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<UsesMarkdownComments>true</UsesMarkdownComments>
<DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>
</PropertyGroup>

<ItemGroup>
<Compile Include="external\InspectSln.fs" />
<Compile Include="external\Types.fs" />
<Compile Include="external\Utils.fs" />
<Compile Include="external\VisualTree.fs" />
<Compile Include="external\Library.fs" />
<None Include="paket.references" />
<Compile Include="..\Common\AssemblyInfo.fs">
<Link>Common\AssemblyInfo.fs</Link>
Expand Down
Loading

0 comments on commit e35dc9c

Please sign in to comment.