Skip to content

Commit 10d33b3

Browse files
committed
chore: initialise a ReferenceProject used to visually test the rendering of the different F# syntax + this project will also be used for unit test
1 parent 488281a commit 10d33b3

File tree

14 files changed

+276
-2
lines changed

14 files changed

+276
-2
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fsharp_max_array_or_list_width=120
1616
fsharp_max_infix_operator_expression=80
1717
fsharp_max_value_binding_width=120
1818

19-
[GenerateHtml.fs]
19+
[{GenerateHtml.fs,tests/FSharp.ApiDocs.Tests/files/ReferenceProject/**/*.fs}]
2020
# Specific settings for "View/HTML" related files
2121
# It makes the code more consistent in term of spacing and indentation
2222
fsharp_experimental_elmish = true
@@ -32,5 +32,5 @@ fsharp_multiline_bracket_style = aligned
3232
fsharp_keep_max_number_of_blank_lines = 1
3333
fsharp_align_function_signature_to_indentation = true
3434
fsharp_max_if_then_else_short_width = 0
35-
fsharp_max_record_number_of_items = 2
35+
fsharp_max_record_number_of_items = 0 # Keep records consistent
3636
fsharp_record_multiline_formatter = number_of_items

FSharp.Formatting.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{FAD5
128128
docs\content\fsdocs-theme-set-dark.js = docs\content\fsdocs-theme-set-dark.js
129129
EndProjectSection
130130
EndProject
131+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{DD76B368-3C5C-4E4A-B3B2-812E950BD497}"
132+
EndProject
133+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FSharp.ApiDocs.Tests", "FSharp.ApiDocs.Tests", "{DE36A7E8-8F98-4763-B859-F452BCA9A675}"
134+
EndProject
135+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "files", "files", "{DFDABFED-63CB-46D1-B27D-BF674A820903}"
136+
EndProject
137+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "ReferenceProject", "tests\FSharp.ApiDocs.Tests\files\ReferenceProject\ReferenceProject.fsproj", "{CDDD197C-6F51-4BDC-A2C2-87622A784A72}"
138+
EndProject
131139
Global
132140
GlobalSection(SolutionConfigurationPlatforms) = preSolution
133141
Debug|Any CPU = Debug|Any CPU
@@ -230,6 +238,10 @@ Global
230238
{CB78F0EA-8005-4735-A02C-B86CEDC29D85}.Debug|Any CPU.Build.0 = Debug|Any CPU
231239
{CB78F0EA-8005-4735-A02C-B86CEDC29D85}.Release|Any CPU.ActiveCfg = Release|Any CPU
232240
{CB78F0EA-8005-4735-A02C-B86CEDC29D85}.Release|Any CPU.Build.0 = Release|Any CPU
241+
{CDDD197C-6F51-4BDC-A2C2-87622A784A72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
242+
{CDDD197C-6F51-4BDC-A2C2-87622A784A72}.Debug|Any CPU.Build.0 = Debug|Any CPU
243+
{CDDD197C-6F51-4BDC-A2C2-87622A784A72}.Release|Any CPU.ActiveCfg = Release|Any CPU
244+
{CDDD197C-6F51-4BDC-A2C2-87622A784A72}.Release|Any CPU.Build.0 = Release|Any CPU
233245
EndGlobalSection
234246
GlobalSection(SolutionProperties) = preSolution
235247
HideSolutionNode = FALSE
@@ -265,6 +277,9 @@ Global
265277
{188DC91F-2202-4495-ACD2-542D7C30364E} = {C7804F57-7FC6-4CF6-BDF6-127D6F9EBEA6}
266278
{FAD5C374-4748-4A3D-A435-FFA425916F3A} = {312E452A-1068-4804-89E7-0AFBAD5F885F}
267279
{52B949AA-A3F7-4894-B713-804BAEB71118} = {4AE0198D-EDE5-40B0-A5CD-FC7B6F891D94}
280+
{DE36A7E8-8F98-4763-B859-F452BCA9A675} = {DD76B368-3C5C-4E4A-B3B2-812E950BD497}
281+
{DFDABFED-63CB-46D1-B27D-BF674A820903} = {DE36A7E8-8F98-4763-B859-F452BCA9A675}
282+
{CDDD197C-6F51-4BDC-A2C2-87622A784A72} = {DFDABFED-63CB-46D1-B27D-BF674A820903}
268283
EndGlobalSection
269284
GlobalSection(ExtensibilityGlobals) = postSolution
270285
SolutionGuid = {76F121F8-70E0-49FB-9ADF-C7B660C0EB67}

build.fsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,38 @@ pipeline "Verify" {
9393
runIfOnlySpecified true
9494
}
9595

96+
let referenceProjectDir = "./tests/FSharp.ApiDocs.Tests/files/ReferenceProject"
97+
98+
// TODO: Revisit to see how we can use `dotnet watch` to run a local version of the tool
99+
// against ReferenceProject
100+
// dotnet watch change the CWD and fsdocs-tool does not seems to allow changing the CWD
101+
pipeline "APIDocsReference" {
102+
103+
stage "Clean up" {
104+
// Remove temporary files
105+
run (fun _ ->
106+
Shell.cleanDirs [
107+
"./tests/FSharp.ApiDocs.Tests/files/ReferenceProject/.fsdocs"
108+
"./tests/FSharp.ApiDocs.Tests/files/ReferenceProject/.tmp"
109+
"./tests/FSharp.ApiDocs.Tests/files/ReferenceProject/.bin"
110+
"./tests/FSharp.ApiDocs.Tests/files/ReferenceProject/.obj"
111+
]
112+
)
113+
}
114+
115+
stage "Build project" {
116+
// Make sure we have the required information for generating the API docs
117+
workingDir referenceProjectDir
118+
run "dotnet build"
119+
}
120+
121+
stage "Generate API Docs" {
122+
// Run a local version of the tool against the ReferenceProject
123+
workingDir referenceProjectDir
124+
run "dotnet run --project ../../../../src/fsdocs-tool -- watch --nolaunch --projects ReferenceProject.fsproj --sourcefolder ../../../../src/fsdocs-tool/../../tests/FSharp.ApiDocs.Tests/files/ReferenceProject"
125+
}
126+
127+
runIfOnlySpecified
128+
}
129+
96130
tryPrintPipelineCommandHelp ()
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module ReferenceProject.Classes
2+
3+
open System.Runtime.InteropServices
4+
5+
// TODO:
6+
// - SRTP syntax
7+
// - Abstract classes
8+
// - Attributes ? Like AllowNullLiteral
9+
10+
type Empty =
11+
class end
12+
13+
type EmptyConstructor() =
14+
class end
15+
16+
type SeveralConstructors() =
17+
new (_prefix : int) = SeveralConstructors()
18+
new (_prefix : int, _indentSize : int) = SeveralConstructors()
19+
20+
// https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/members/explicit-fields-the-val-keyword
21+
type ExplicitFields () =
22+
member val ExplicitFieldGetSet = 0 with get, set
23+
member val ExplicitFieldGet = 0 with get
24+
25+
// https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/members/properties
26+
type Properties () =
27+
static member StaticProperty = 0
28+
static member StaticPropertyGetOnly with get () = 0
29+
static member StaticPropertySetOnly with set (_value : int) = ()
30+
static member StaticPropertyGetSet with get() = 0 and set(_value : int) = ()
31+
static member val StaticPropertyWithAutoImpl = 0 with get, set
32+
33+
// https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/members/methods
34+
type InstanceMethods () =
35+
member this.Void () = ()
36+
37+
// Non curried arguments
38+
member this.Echo (_message : string) = _message
39+
member this.Add (a : int) (b : int) = a + b
40+
41+
// Curried arguments
42+
member this.AddCurried (a : int, b : int) = a + b
43+
44+
// Methods with overloads
45+
member this.Log (_message : string) = ()
46+
member this.Log (_message : string, _level : int) = ()
47+
member this.Log (_message : string, _level : int, ?_prefix : string) = ()
48+
49+
type StaticMethods () =
50+
static member StaticVoid () = ()
51+
52+
// Non curried arguments
53+
static member StaticEcho (_message : string) = _message
54+
static member StaticAdd (a : int) (b : int) = a + b
55+
56+
// Curried arguments
57+
static member StaticAddCurried (a : int, b : int) = a + b
58+
59+
// Static methods with overloads
60+
static member StaticLog (_message : string) = ()
61+
static member StaticLog (_message : string, _level : int) = ()
62+
static member StaticLog (_message : string, _level : int, ?_prefix : string) = ()
63+
64+
[<AbstractClass>]
65+
type AbstractMethods () =
66+
abstract member AbstractMethod : unit -> unit
67+
abstract member AbstractMethodWithUnknownArguments : string -> int -> unit
68+
abstract member AbstractMethodWithNamedArguments : message : string -> level : int -> unit
69+
70+
type OptionalInterop () =
71+
member _.AddOne([<Optional; DefaultParameterValue(12)>] i) = i + 1
72+
73+
type InterfaceImplementation () =
74+
interface Interfaces.InterfaceC with
75+
member this.MethodA () = ()
76+
member this.MethodB () = ()
77+
member this.MethodC () = ()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module ReferenceProject.DiscriminatedUnions
2+
3+
type SingleCase =
4+
| SingleCase of string
5+
6+
type NamedArguments =
7+
| NamedArguments of prefix: string * indentSize: int
8+
9+
type MultipleCases =
10+
| Case1
11+
| Case2 of string
12+
| Case3 of message : string * callback : (int -> int)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module ReferenceProject.Functions
2+
3+
/// <summary>
4+
/// This function calculates the sum of two numbers.
5+
/// </summary>
6+
/// <param name="a">The first number.</param>
7+
/// <param name="b">The second number.</param>
8+
/// <returns>The sum of the two numbers.</returns>
9+
let add (a: int) (b: int) = a + b
10+
11+
let emptyFunction () = ()
12+
13+
let tupleArguments (a: int, b: int) = a + b
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module ReferenceProject.GlobalReferences
2+
3+
// Types in this file are used to be referenced by other files in the project.
4+
// This is to test things like type resolution and cross-file linking.
5+
6+
type CallBack = unit -> unit
7+
8+
type UserClass(firstName: string, lastName: string) =
9+
member this.FirstName = firstName
10+
member this.LastName = lastName
11+
member this.FullName = firstName + " " + lastName
12+
13+
type UserRecord =
14+
{
15+
FirstName: string
16+
LastName: string
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module ReferenceProject.Interfaces
2+
3+
type Empty =
4+
interface end
5+
6+
type InstanceMethods =
7+
abstract member Method : unit -> unit
8+
9+
type StaticMethods =
10+
static member Version = "This is version 1.0"
11+
static member Log (_message: string) = ()
12+
13+
// Interfaces for inheritance testing
14+
type InterfaceA =
15+
abstract member MethodA : unit -> unit
16+
17+
type InterfaceB =
18+
abstract member MethodB : unit -> unit
19+
20+
type InterfaceC =
21+
inherit InterfaceA
22+
inherit InterfaceB
23+
abstract member MethodC : unit -> unit
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module ReferenceProject.Modules
2+
3+
module ModuleA =
4+
5+
module ModuleA_A =
6+
7+
let answer = 42
8+
9+
module ModuleA_B =
10+
11+
let answer = 42
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace NamespaceA
2+
3+
module ModuleA =
4+
5+
let answer = 42

0 commit comments

Comments
 (0)