Skip to content

Commit

Permalink
upgrade to 39.0.0 and change to --properties (#640)
Browse files Browse the repository at this point in the history
Co-authored-by: Don Syme <[email protected]>
  • Loading branch information
dsyme and Don Syme authored Feb 11, 2021
1 parent 5cab888 commit 9148ad7
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 136 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 8.0.2
* Rename --property flag to --properties

## 8.0.1
* [Prevent CLI parameters from being discarded](https://github.com/fsprojects/FSharp.Formatting/pull/634)
* [Update Dockerfile and NuGet.config for binder](https://github.com/fsprojects/FSharp.Formatting/pull/636)
Expand Down
4 changes: 2 additions & 2 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ Target.create "GenerateDocs" (fun _ ->
// Τhe tool has been uninstalled when the
// artifacts folder was removed in the Clean target.
DotNet.exec id "tool" ("install --no-cache --version " + release.NugetVersion + " --add-source " + artifactsDir + " --tool-path " + artifactsDir + " FSharp.Formatting.CommandTool") |> ignore
CreateProcess.fromRawCommand (artifactsDir @@ "fsdocs") ["build"; "--strict"; "--clean"; "--property"; "Configuration=Release"]
CreateProcess.fromRawCommand (artifactsDir @@ "fsdocs") ["build"; "--strict"; "--clean"; "--properties"; "Configuration=Release"]
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
// DotNet.exec id "fsdocs" "build --strict --clean --property Configuration=Release" |> ignore
// DotNet.exec id "fsdocs" "build --strict --clean --properties Configuration=Release" |> ignore
// DotNet.exec id "tool" "uninstall --local FSharp.Formatting.CommandTool" |> ignore
Shell.cleanDir ".packages"
)
Expand Down
38 changes: 20 additions & 18 deletions docs/apidocs.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,39 @@ In addition, you may also use the [Recommended XML doc extensions for F# documen
An example of an XML documentation comment, assuming the code is in namespace `TheNamespace`:
*)
/// <summary>
/// Some actual comment
/// <para>Another paragraph, see <see cref="T:TheNamespace.SomeType"/>. </para>
/// A module
/// </summary>
///
/// <param name="x">The input</param>
///
/// <returns>The output</returns>
///
/// <example>
/// Try using
/// <code>
/// open TheNamespace
/// SomeModule.a
/// </code>
/// </example>
///
/// <namespacedoc>
/// <summary>A namespace to remember</summary>
///
/// <remarks>More on that</remarks>
/// </namespacedoc>
///
/// <category>Foo</category>
///
module SomeModule =
/// <summary>
/// Some actual comment
/// <para>Another paragraph, see <see cref="T:TheNamespace.SomeType"/>. </para>
/// </summary>
///
/// <param name="x">The input</param>
///
/// <returns>The output</returns>
///
/// <example>
/// Try using
/// <code>
/// open TheNamespace
/// SomeModule.a
/// </code>
/// </example>
///
/// <category>Foo</category>
let someFunction x = 42 + x

/// <summary>
/// A type, see <see cref="T:TheNamespace.SomeModule"/> and
/// <see cref="T:TheNamespace.SomeModule.someFunction"/>. </para>
/// <see cref="T:TheNamespace.SomeModule.someFunction"/>.
/// </summary>
///
type SomeType() =
Expand Down
2 changes: 1 addition & 1 deletion docs/commandline.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The command line options accepted are:
| `--clean` | Clean the output directory |
| `--help` | Display this help screen |
| `--version` | Display version information |
| `--property` | Provide a property to dotnet msbuild, e.g. --property Configuration=Release |
| `--properties` | Provide properties to dotnet msbuild, e.g. --properties Configuration=Release Version=3.4 |
| `--strict` | Fail if docs are missing or can't be generated |

The following command line options are also accepted but it is instead recommended you use
Expand Down
2 changes: 1 addition & 1 deletion docs/literate.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ version of the F# compiler:
- `prefix` - a string that is added to all automatically generated `id` attributes
in the generated HTML document (to avoid collisions with other HTML elements)
- `fscoptions` - this can be used to pass any additional command line
- `fscOptions` - this can be used to pass any additional command line
parameters to the F# compiler (you can use any standard parameters of `fsc.exe`)
- `lineNumbers` - if `true` then the generated F# snippets include line numbers.
- `references` - if `true` then the script automatically adds a "References"
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ framework: auto-detect
storage: none

nuget FSharp.Core >= 4.7 lowest_matching:true
nuget FSharp.Compiler.Service 38.0.2
nuget FSharp.Compiler.Service 39.0.0
nuget CommandLineParser ~> 2.8
nuget Microsoft.Build.Framework
nuget Microsoft.Build.Tasks.Core
Expand Down
68 changes: 34 additions & 34 deletions paket.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/FSharp.Formatting.ApiDocs/ApiDocs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type ApiDocs =
/// </summary>
///
/// <param name="inputs">the components to generate documentation for</param>
/// <param name="collectionName">the overall collection name</param>
/// <param name="substitutions">provides substitutions for substitution in the templates</param>
/// <param name="qualify">qualify the output set by collection name, e.g. <c>reference/FSharp.Core/...</c></param>
/// <param name="sourceFolder` and `sourceRepo">When specified, the documentation generator automatically
/// generates links to GitHub pages for each of the entity.</param>
/// <param name="libDirs">Use this to specify additional paths where referenced DLL files can be found when formatting code snippets inside Markdown comments</param>
/// <param name="otherFlags">Additional flags that are passed to the F# compiler (you can use this if you want to
/// specify references explicitly etc.)</param>
/// <param name="root">The root url of the generated documentation within the website</param>
/// <param name="urlRangeHighlight">A function that can be used to override the default way of generating GitHub links</param>
/// <param name="strict">Fail if any assembly is missing XML docs or can't be resolved</param>
///
Expand Down Expand Up @@ -67,13 +67,14 @@ type ApiDocs =
/// <param name="inputs">the components to generate documentation for</param>
/// <param name="output">the output directory</param>
/// <param name="collectionName">the overall collection name</param>
/// <param name="substitutions">provides substitutions for substitution in the templates</param>
/// <param name="template">the template to use for each documentation page</param>
/// <param name="root">The root url of the generated documentation within the website</param>
/// <param name="qualify">qualify the output set by collection name, e.g. `reference/FSharp.Core/...`</param>
/// <param name="libDirs">Use this to specify additional paths where referenced DLL files can be found when formatting code snippets inside Markdown comments</param>
/// <param name="otherFlags">Additional flags that are passed to the F# compiler to specify references explicitly etc.</param>
/// <param name="urlRangeHighlight">A function that can be used to override the default way of generating GitHub links</param>
///
/// <param name="strict">Fail if any assembly is missing XML docs or can't be resolved</param>
static member GenerateHtml(inputs, output, collectionName, substitutions, ?template, ?root, ?qualify, ?libDirs, ?otherFlags, ?urlRangeHighlight, ?strict) =
let root = defaultArg root "/"
let qualify = defaultArg qualify false
Expand Down
36 changes: 19 additions & 17 deletions src/FSharp.Formatting.ApiDocs/GenerateModel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ open System.Xml
open System.Xml.Linq

open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Range
open FSharp.Compiler.Text
open FSharp.Compiler.Text.Range
open FSharp.Formatting.Common
open FSharp.Formatting.Internal
open FSharp.Formatting.CodeFormat
Expand Down Expand Up @@ -665,7 +666,7 @@ type internal CrossReferenceResolver (root, collectionName, qualify) =
for nested in entity.NestedEntities do
registerEntity nested

for memb in entity.TryGetMembersFunctionsAndValues do
for memb in entity.TryGetMembersFunctionsAndValues() do
registerMember memb

let getUrlBaseNameForRegisteredEntity (entity:FSharpEntity) =
Expand Down Expand Up @@ -1011,7 +1012,7 @@ module internal SymbolReader =

static member internal Create
(publicOnly, assembly, map, sourceFolderRepo, urlRangeHighlight, mdcomments, urlMap,
assemblyPath, fscoptions, formatAgent, substitutions, warn ) =
assemblyPath, fscOptions, formatAgent, substitutions, warn ) =

{ PublicOnly=publicOnly
Assembly = assembly
Expand All @@ -1022,7 +1023,7 @@ module internal SymbolReader =
UrlRangeHighlight = urlRangeHighlight
SourceFolderRepository = sourceFolderRepo
AssemblyPath = assemblyPath
CompilerOptions = fscoptions
CompilerOptions = fscOptions
FormatAgent = formatAgent
Substitutions = substitutions}

Expand Down Expand Up @@ -1105,12 +1106,12 @@ module internal SymbolReader =
fullArgUsage ]

// op_XYZ operators
| _, false, _, name, _ when FSharp.Compiler.PrettyNaming.IsMangledOpName v.CompiledName ->
| _, false, _, name, _ when PrettyNaming.IsMangledOpName v.CompiledName ->
match argInfos with
// binary operators (taking a tuple)
| [[x;y]] ->
let left = formatCurriedArgsUsageAsHtml true false [[x]]
let nm = FSharp.Compiler.PrettyNaming.DecompileOpName v.CompiledName
let nm = PrettyNaming.DecompileOpName v.CompiledName
let right = formatCurriedArgsUsageAsHtml true false [[y]]
span [] [left
!! "&#32;"
Expand All @@ -1121,7 +1122,7 @@ module internal SymbolReader =
// binary operators (curried, like in FSharp.Core.Operators)
| [args1;args2] ->
let left = formatCurriedArgsUsageAsHtml true false [args1]
let nm = FSharp.Compiler.PrettyNaming.DecompileOpName v.CompiledName
let nm = PrettyNaming.DecompileOpName v.CompiledName
let right = formatCurriedArgsUsageAsHtml true false [args2]
span [] [left
!! "&#32;"
Expand All @@ -1131,7 +1132,7 @@ module internal SymbolReader =

// unary operators
| [[x]] ->
let nm = FSharp.Compiler.PrettyNaming.DecompileOpName v.CompiledName
let nm = PrettyNaming.DecompileOpName v.CompiledName
let right = formatCurriedArgsUsageAsHtml true false [[x]]
span [] [!! nm;
right ]
Expand Down Expand Up @@ -1685,7 +1686,7 @@ module internal SymbolReader =
let doc =
Literate.ParseMarkdownString
( text, path=Path.Combine(ctx.AssemblyPath, "docs.fsx"),
formatAgent=ctx.FormatAgent, fscoptions=ctx.CompilerOptions )
formatAgent=ctx.FormatAgent, fscOptions=ctx.CompilerOptions )

let doc = doc |> addMissingLinkToTypes ctx
let html = readMarkdownCommentAsHtml doc
Expand Down Expand Up @@ -1860,9 +1861,9 @@ module internal SymbolReader =
ctx.XmlMemberMap.Add(xmlDocSig, xmlDoc)
xmlDoc

// Type providers don't have their docs dumped into the xml file,
// Provided types don't have their docs dumped into the xml file,
// so we need to add them to the XmlMemberMap separately
let registerTypeProviderXmlDocs (ctx:ReadingContext) (typ:FSharpEntity) =
let registerProvidedTypeXmlDocs (ctx:ReadingContext) (typ:FSharpEntity) =
let xmlDoc = registerXmlDoc ctx typ.XmlDocSig (String.concat "" typ.XmlDoc)
xmlDoc.Elements(XName.Get "param")
|> Seq.choose (fun p ->
Expand All @@ -1875,7 +1876,7 @@ module internal SymbolReader =

let rec readType (ctx:ReadingContext) (typ:FSharpEntity) =
if typ.IsProvided && typ.XmlDoc.Count > 0 then
registerTypeProviderXmlDocs ctx typ
registerProvidedTypeXmlDocs ctx typ

let xmlDocSig = getXmlDocSigForType typ

Expand Down Expand Up @@ -2136,7 +2137,6 @@ type ApiDocModel =
let resolvedList =
//FSharpAssembly.LoadFiles(projects, libDirs, otherFlags = otherFlags)
FSharpAssembly.LoadFiles(dllFiles, libDirs, otherFlags = otherFlags, manualResolve=true)
|> Seq.toList
|> List.zip projects

// generate the names for the html files beforehand so we can resolve <see cref=""/> links.
Expand Down Expand Up @@ -2235,19 +2235,21 @@ type ApiDocModel =
ApiDocEntityInfo(typ, collection, ns, parent)

let rec nestedTypes ns (modul:ApiDocEntity) =
[ for n in modul.NestedEntities do
[ let entities = modul.NestedEntities
for n in entities do
if n.IsTypeDefinition then
yield createType ns (Some modul) n
for n in modul.NestedEntities do
for n in entities do
if not n.IsTypeDefinition then
yield! nestedTypes ns n ]

let typesInfos =
[ for ns in collection.Namespaces do
for n in ns.Entities do
let entities = ns.Entities
for n in entities do
if not n.IsTypeDefinition then
yield! nestedTypes ns n
for n in ns.Entities do
for n in entities do
if n.IsTypeDefinition then
yield createType ns None n ]

Expand Down
13 changes: 6 additions & 7 deletions src/FSharp.Formatting.CodeFormat/CodeFormatAgent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ open System
open System.IO
open System.Runtime.ExceptionServices
open FSharp.Compiler
open FSharp.Compiler.Range
open FSharp.Compiler.Text
open FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Text
open FSharp.Formatting.CodeFormat
open FSharp.Formatting.CodeFormat.CommentFilter
open FSharp.Formatting.Common
Expand Down Expand Up @@ -154,7 +153,7 @@ type CodeFormatAgent() =


// Processes a single line of the snippet
let processSnippetLine (checkResults: FSharpCheckFileResults) (semanticRanges: struct(Range.range * SemanticClassificationType)[])
let processSnippetLine (checkResults: FSharpCheckFileResults) (semanticRanges: struct(range * SemanticClassificationType)[])
(lines: string[]) (line: int, lineTokens: SnippetLine) =
let lineStr = lines.[line]

Expand Down Expand Up @@ -200,7 +199,7 @@ type CodeFormatAgent() =
if (token.TokenName = "IDENT") then
let island = List.rev island
let tip = checkResults.GetToolTipText(line + 1, token.LeftColumn + 1, lines.[line], island,FSharpTokenTag.IDENT)
match tip |> Async.RunSynchronously |> ToolTipReader.tryFormatTip with
match tip |> ToolTipReader.tryFormatTip with
| Some(_) as res -> res
| _ -> None
else None
Expand Down Expand Up @@ -322,7 +321,7 @@ type CodeFormatAgent() =
let filePath = Path.GetFullPath(filePath)
let! (opts,_errors) = fsChecker.GetProjectOptionsFromScript(filePath, SourceText.ofString source, loadedTimeStamp = DateTime.Now, otherFlags = args, assumeDotNetFramework = false)

let formatError (e:FSharpErrorInfo) =
let formatError (e:FSharpDiagnostic) =
sprintf "%s (%d,%d)-(%d,%d): %A FS%04d: %s" e.FileName e.StartLineAlternate e.StartColumn e.EndLineAlternate e.EndColumn e.Severity e.ErrorNumber e.Message

let formatErrors errors =
Expand Down Expand Up @@ -373,7 +372,7 @@ type CodeFormatAgent() =
//let! results = fsChecker.ParseAndCheckProject(opts)
//let _errors = results.Errors

if _errors |> List.filter (fun e -> e.Severity = FSharpErrorSeverity.Error) |> List.length > 0 then
if _errors |> List.filter (fun e -> e.Severity = FSharpDiagnosticSeverity.Error) |> List.length > 0 then
Log.warnf "errors from GetProjectOptionsFromScript '%s'" (formatErrors _errors)

//printfn "filePath = %A" filePath
Expand Down Expand Up @@ -444,7 +443,7 @@ type CodeFormatAgent() =
yield SourceError(
(errInfo.StartLineAlternate - 1, errInfo.StartColumn),
(errInfo.EndLineAlternate - 1, errInfo.EndColumn),
(if errInfo.Severity = FSharpErrorSeverity.Error then ErrorKind.Error else ErrorKind.Warning),
(if errInfo.Severity = FSharpDiagnosticSeverity.Error then ErrorKind.Error else ErrorKind.Warning),
errInfo.Message
)
|]
Expand Down
8 changes: 4 additions & 4 deletions src/FSharp.Formatting.CommandTool/BuildCommand.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type internal DocContent(outputDirectory, previous: Map<_,_>, lineNumbers, fsiEv
let model =
Literate.ParseAndTransformScriptFile
(inputFile, output = relativeOutputFile, outputKind = outputKind,
?formatAgent = None, ?prefix = None, ?fscoptions = None,
?formatAgent = None, ?prefix = None, ?fscOptions = None,
?lineNumbers = lineNumbers, references=false, ?fsiEvaluator = fsiEvaluator,
substitutions = substitutions,
generateAnchors = true,
Expand All @@ -119,7 +119,7 @@ type internal DocContent(outputDirectory, previous: Map<_,_>, lineNumbers, fsiEv
let model =
Literate.ParseAndTransformMarkdownFile
(inputFile, output = relativeOutputFile, outputKind = outputKind,
?formatAgent = None, ?prefix = None, ?fscoptions = None,
?formatAgent = None, ?prefix = None, ?fscOptions = None,
?lineNumbers = lineNumbers, references=false,
substitutions = substitutions,
generateAnchors = true,
Expand Down Expand Up @@ -325,7 +325,7 @@ type CoreBuildOptions(watch) =
[<Option("nodefaultcontent", Required = false, HelpText = "Do not copy default content styles, javascript or use default templates.")>]
member val nodefaultcontent = false with get, set

[<Option("property", Required = false, HelpText = "Provide a property to dotnet msbuild, e.g. --property Configuration=Release")>]
[<Option("properties", Required = false, HelpText = "Provide properties to dotnet msbuild, e.g. --properties Configuration=Release Version=3.4")>]
member val extraMsbuildProperties = Seq.empty<string> with get, set

[<Option("fscoptions", Required=false, HelpText = "Extra flags for F# compiler analysis, e.g. dependency resolution.")>]
Expand Down Expand Up @@ -398,7 +398,7 @@ type CoreBuildOptions(watch) =

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 --property Configuration=Release." dllFile
let msg = sprintf "*** %s does not exist, has it been built? You may need to provide --properties Configuration=Release." dllFile
if this.strict then
failwith msg
else
Expand Down
Loading

0 comments on commit 9148ad7

Please sign in to comment.