Skip to content

Commit

Permalink
Ensure formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAngryByrd committed Sep 17, 2023
1 parent 521b646 commit 4d55538
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 175 deletions.
7 changes: 7 additions & 0 deletions Content/Console/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
<PropertyGroup>
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config\dotnet-tools.json</_DotnetToolManifestFile>
<_DotnetToolRestoreOutputFile>$(MSBuildThisFileDirectory)build\obj\dotnet-tool-restore-$(NETCoreSdkVersion)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild</_DotnetFantomasOutputFile>
</PropertyGroup>

<!-- Make sure that dotnet tools (including paket) are restored before restoring any project -->
Expand All @@ -15,4 +16,10 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
<Touch Files="$(_DotnetToolRestoreOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

<!-- Make sure that files are formatted before building -->
<Target Name="Format" BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)" >
<Exec Command="dotnet fantomas ." StandardOutputImportance="High" StandardErrorImportance="High" />
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

</Project>
21 changes: 13 additions & 8 deletions Content/Console/build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -544,21 +544,26 @@ let githubRelease _ =
|> GitHub.publishDraft
|> Async.RunSynchronously


let formatCode _ =
let result = dotnet.fantomas "."
let result = dotnet.fantomas $"{rootDirectory}"

if not result.OK then
printfn "Errors while formatting all files: %A" result.Messages

let checkFormatCode _ =
let result = dotnet.fantomas "--check ."
let checkFormatCode ctx =
if isCI.Value then
let result = dotnet.fantomas $"{rootDirectory} --check"

if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, check output for more info"
if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, check output for more info"
else
Trace.logf "Errors while formatting: %A" result.Errors
else
Trace.logf "Errors while formatting: %A" result.Errors
// Only verify in CI, otherwise format all files
formatCode ctx

let initTargets () =
BuildServer.install [ GitHubActions.Installer ]
Expand Down
7 changes: 7 additions & 0 deletions Content/Library/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
<PropertyGroup>
<_DotnetToolManifestFile>$(MSBuildThisFileDirectory).config\dotnet-tools.json</_DotnetToolManifestFile>
<_DotnetToolRestoreOutputFile>$(MSBuildThisFileDirectory)build\obj\dotnet-tool-restore-$(NETCoreSdkVersion)</_DotnetToolRestoreOutputFile>
<_DotnetFantomasOutputFile>$(BaseIntermediateOutputPath)dotnet-fantomas-msbuild</_DotnetFantomasOutputFile>
</PropertyGroup>

<!-- Make sure that dotnet tools (including paket) are restored before restoring any project -->
Expand All @@ -15,4 +16,10 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director
<Touch Files="$(_DotnetToolRestoreOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

<!-- Make sure that files are formatted before building -->
<Target Name="Format" BeforeTargets="BeforeBuild" Inputs="@(Compile)" Outputs="$(_DotnetFantomasOutputFile)" >
<Exec Command="dotnet fantomas ." StandardOutputImportance="High" StandardErrorImportance="High" />
<Touch Files="$(_DotnetFantomasOutputFile)" AlwaysCreate="True" ForceTouch="True" />
</Target>

</Project>
116 changes: 57 additions & 59 deletions Content/Library/build/FsDocs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,70 @@ module Fsdocs =
/// <summary>
/// Fsdocs build command parameters and options
/// </summary>
type BuildCommandParams =
{
/// Input directory of content (default: docs)
Input: string option
type BuildCommandParams = {
/// Input directory of content (default: docs)
Input: string option

/// Project files to build API docs for outputs, defaults to all packable projects
Projects: seq<string> option
/// Project files to build API docs for outputs, defaults to all packable projects
Projects: seq<string> option

/// Output Directory (default <c>output</c> for <c>build</c> and <c>tmp/watch</c> for <c>watch</c>)
Output: string option
/// Output Directory (default <c>output</c> for <c>build</c> and <c>tmp/watch</c> for <c>watch</c>)
Output: string option

/// Disable generation of API docs
NoApiDocs: bool option
/// Disable generation of API docs
NoApiDocs: bool option

/// Evaluate F# fragments in scripts
Eval: bool option
/// Evaluate F# fragments in scripts
Eval: bool option

/// Save images referenced in docs
SaveImages: bool option
/// Save images referenced in docs
SaveImages: bool option

/// Add line numbers
LineNumbers: bool option
/// Add line numbers
LineNumbers: bool option

/// Additional substitution parameters for templates
Parameters: seq<string * string> option
/// Additional substitution parameters for templates
Parameters: seq<string * string> option

/// Disable project cracking.
IgnoreProjects: bool option
/// Disable project cracking.
IgnoreProjects: bool option

/// In API doc generation qualify the output by the collection name, e.g. 'reference/FSharp.Core/...' instead of 'reference/...' .
Qualify: bool option
/// In API doc generation qualify the output by the collection name, e.g. 'reference/FSharp.Core/...' instead of 'reference/...' .
Qualify: bool option

/// The tool will also generate documentation for non-public members
NoPublic: bool option
/// The tool will also generate documentation for non-public members
NoPublic: bool option

/// Do not copy default content styles, javascript or use default templates
NoDefaultContent: bool option
/// Do not copy default content styles, javascript or use default templates
NoDefaultContent: bool option

/// Clean the output directory
Clean: bool option
/// Clean the output directory
Clean: bool option

/// Display version information
Version: bool option
/// Display version information
Version: bool option

/// Provide properties to dotnet msbuild, e.g. <c>--properties Configuration=Release Version=3.4</c>
Properties: string option
/// Provide properties to dotnet msbuild, e.g. <c>--properties Configuration=Release Version=3.4</c>
Properties: string option

/// Additional arguments passed down as otherflags to the F# compiler when the API is being generated.
/// Note that these arguments are trimmed, this is to overcome a limitation in the command line argument
/// processing. A typical use-case would be to pass an addition assembly reference.
/// Example <c>--fscoptions " -r:MyAssembly.dll"</c>
FscOptions: string option
/// Additional arguments passed down as otherflags to the F# compiler when the API is being generated.
/// Note that these arguments are trimmed, this is to overcome a limitation in the command line argument
/// processing. A typical use-case would be to pass an addition assembly reference.
/// Example <c>--fscoptions " -r:MyAssembly.dll"</c>
FscOptions: string option

/// Fail if docs are missing or can't be generated
Strict: bool option
/// Fail if docs are missing or can't be generated
Strict: bool option

/// Source folder at time of component build (<c>&lt;FsDocsSourceFolder&gt;</c>)
SourceFolder: string option
/// Source folder at time of component build (<c>&lt;FsDocsSourceFolder&gt;</c>)
SourceFolder: string option

/// Source repository for github links (<c>&lt;FsDocsSourceRepository&gt;</c>)
SourceRepository: string option
/// Source repository for github links (<c>&lt;FsDocsSourceRepository&gt;</c>)
SourceRepository: string option

/// Assume comments in F# code are markdown (<c>&lt;UsesMarkdownComments&gt;</c>)
MdComments: bool option
}
/// Assume comments in F# code are markdown (<c>&lt;UsesMarkdownComments&gt;</c>)
MdComments: bool option
} with

/// Parameter default values.
static member Default = {
Expand Down Expand Up @@ -107,23 +106,22 @@ module Fsdocs =
/// <summary>
/// Fsdocs watch command parameters and options
/// </summary>
type WatchCommandParams =
{
/// Do not serve content when watching.
NoServer: bool option
type WatchCommandParams = {
/// Do not serve content when watching.
NoServer: bool option

/// Do not launch a browser window.
NoLaunch: bool option
/// Do not launch a browser window.
NoLaunch: bool option

/// URL extension to launch <c>http://localhost:/%s</c>.
Open: string option
/// URL extension to launch <c>http://localhost:/%s</c>.
Open: string option

/// Port to serve content for <c>http://localhost</c> serving.
Port: int option
/// Port to serve content for <c>http://localhost</c> serving.
Port: int option

/// Build Commands
BuildCommandParams: BuildCommandParams option
}
/// Build Commands
BuildCommandParams: BuildCommandParams option
} with

/// Parameter default values.
static member Default = {
Expand Down
Loading

0 comments on commit 4d55538

Please sign in to comment.