Skip to content

Commit 15d65e8

Browse files
authored
more compiler docs (dotnet#12345)
* more docs * titles
1 parent fa84e0f commit 15d65e8

24 files changed

+261
-208
lines changed

docs/coding-standards.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Coding standards
3-
category: Compiler
4-
categoryindex: 1
5-
index: 2
3+
category: General
4+
categoryindex: 100
5+
index: 200
66
---
77
# Coding standards and idioms
88

docs/compiler-startup-performance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Compiler Startup Performance
3-
category: Compiler
4-
categoryindex: 1
5-
index: 7
3+
category: Compiler Internals
4+
categoryindex: 200
5+
index: 700
66
---
77
# Compiler Startup Performance
88

docs/diagnostics.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
11
---
22
title: Diagnostics
3-
category: Compiler
4-
categoryindex: 1
5-
index: 3
3+
category: General
4+
categoryindex: 100
5+
index: 300
66
---
7+
# Diagnostics
78

8-
## Adding Error Messages
9+
The key types are
910

10-
Adding or adjusting errors emitted by the compiler is usually straightforward (though it can sometimes imply deeper compiler work). Here's the general process:
11+
* `ErrorLogger`
12+
* `FSharpDiagnosticSeverity`
13+
* `FSharpDiagnostic`
14+
15+
and functions
16+
17+
* `warning` - emit a warning
18+
* `errorR` - emit an error and continue
19+
* `error` - emit an error and throw an exception
20+
* `errorRecovery` - recover from an exception
21+
22+
## Diagnostic messages
23+
24+
For the compiler, a key file is `FSComp.txt` olding most of the messages. There are also a few other similar files including some old error messages in `FSStrings.resx`.
25+
26+
## Adding Diagnostics
27+
28+
Adding or adjusting diagnostics emitted by the compiler is usually straightforward (though it can sometimes imply deeper compiler work). Here's the general process:
1129

1230
1. Reproduce the compiler error or warning with the latest F# compiler built from the [F# compiler repository](https://github.com/dotnet/fsharp).
1331
2. Find the error code (such as `FS0020`) in the message.
@@ -19,23 +37,23 @@ From here, you can either simply update the error test, or you can use some of t
1937

2038
If you're including data from user code in an error message, it's important to also write a test that verifies the exact error message for a given string of F# code.
2139

22-
## Formatting User Text from Typed Tree items
40+
## Formatting Typed Tree items in Diagnostics
2341

24-
When formatting Typed Tree objects such as `TyconRef`s as text, you normally use either
42+
Diagnostics must often format TAST items as user text. When formatting these, you normally use either
2543

2644
* The functions in the `NicePrint` module such as `NicePrint.outputTyconRef`. These take a `DisplayEnv` that records the context in which a type was referenced, for example, the open namespaces. Opened namespaces are not shown in the displayed output.
2745

2846
* The `DisplayName` properties on the relevant object. This drops the `'n` text that .NET adds to the compiled name of a type, and uses the F#-facing name for a type rather than the compiled name for a type (for example, the name given in a `CompiledName` attribute).
2947

30-
* The functions such as `Tastops.fullTextOfTyconRef`, used to show the full, qualified name of an item.
31-
3248
When formatting "info" objects, see the functions in the `NicePrint` module.
3349

3450
## Notes on displaying types
3551

36-
When displaying a type, you will normally want to "prettify" the type first. This converts any remaining type inference variables to new, better user-friendly type variables with names like `'a`. Various functions prettify types prior to display, for example, `NicePrint.layoutPrettifiedTypes` and others.
52+
Diagnostics must often format types.
53+
54+
* When displaying a type, you will normally want to "prettify" the type first. This converts any remaining type inference variables to new, better user-friendly type variables with names like `'a`. Various functions prettify types prior to display, for example, `NicePrint.layoutPrettifiedTypes` and others.
3755

38-
When displaying multiple types in a comparative way, for example, two types that didn't match, you will want to display the minimal amount of infomation to convey the fact that the two types are different, for example, `NicePrint.minimalStringsOfTwoTypes`.
56+
* When displaying multiple types in a comparative way, for example, two types that didn't match, you will want to display the minimal amount of infomation to convey the fact that the two types are different, for example, `NicePrint.minimalStringsOfTwoTypes`.
3957

40-
When displaying a type, you have the option of displaying the constraints implied by any type variables mentioned in the types, appended as `when ...`. For example, `NicePrint.layoutPrettifiedTypeAndConstraints`.
58+
* When displaying a type, you have the option of displaying the constraints implied by any type variables mentioned in the types, appended as `when ...`. For example, `NicePrint.layoutPrettifiedTypeAndConstraints`.
4159

docs/fcs/caches.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
33
title: FSharpChecker caches
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 10
4+
category: Language Service Internals
5+
categoryindex: 300
6+
index: 1000
77
---
88
*)
99
(*** hide ***)

docs/fcs/compiler.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
3-
title: Hosting the compiler
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 9
3+
title: Tutorial: Hosting the compiler
4+
category: Compiler Service API
5+
categoryindex: 300
6+
index: 900
77
---
88
*)
99
(*** hide ***)

docs/fcs/corelib.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
33
title: Notes on FSharp.Core
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 11
4+
category: Compiler Service API
5+
categoryindex: 300
6+
index: 1100
77
---
88
*)
99
(*** hide ***)

docs/fcs/editor.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
3-
title: Editor services
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 5
3+
title: Tutorial: Editor services
4+
category: Compiler Service API
5+
categoryindex: 300
6+
index: 500
77
---
88
*)
99
(*** hide ***)

docs/fcs/filesystem.fsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
33
title: IFileSystem
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 12
4+
category: Compiler Service API
5+
categoryindex: 300
6+
index: 1200
77
---
88
*)
99
(*** hide ***)

docs/fcs/index.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: Overview
3-
category: Compiler Service
4-
categoryindex: 2
5-
index: 1
3+
category: Compiler Service API
4+
categoryindex: 300
5+
index: 100
66
---
77
# FSharp.Compiler.Service
88

@@ -48,7 +48,15 @@ The libraries contain additional public API that can be used, but is not documen
4848

4949
> **NOTE:** The FSharp.Compiler.Service API is subject to change when later versions of the nuget package are published
5050
51-
## API Namespaces
51+
## The Public Surface Area
52+
53+
We are in the process of cleaning up the surface area of FCS to allow it to be fully binary compatible going forward.
54+
55+
The full current surface area can be seen at: https://fsharp.github.io/fsharp-compiler-docs/reference/index.html
56+
57+
The API is generally designed with F#/.NET design conventions (e.g. types in namespaces, not modules, no nesting of modules etc.) and we must continue to iterate to make this so.
58+
59+
The parts of the compiler under `FSharp.Compiler.AbstractIL.*` are "incidental" and not really designed for public use apart from the hook for JetBrains Rider (Aside: In theory all these other parts could be renamed to FSharp.Compiler though there's no need to do that right now). These internal parts tend to be implemented with the "module containing lots of stuff in one big file" approach for layers of the compiler.
5260

5361
### Basics - Syntax, Text and Diagnostics
5462

docs/fcs/interactive.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(**
22
---
3-
title: Hosted execution
4-
category: Compiler Service
5-
categoryindex: 2
6-
index: 7
3+
title: Tutorial: Hosted execution
4+
category: Compiler Service API
5+
categoryindex: 300
6+
index: 700
77
---
88
*)
99
(*** hide ***)

0 commit comments

Comments
 (0)