Skip to content

Commit aa42e00

Browse files
committed
Update documentation.
1 parent 1c56b11 commit aa42e00

File tree

12 files changed

+278
-36
lines changed

12 files changed

+278
-36
lines changed

src/Compiler/Backend.gren

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ module Compiler.Backend exposing
2323

2424
@docs version
2525

26-
@docs UnsupportedPlatform, downloadUrl, download, cachePath, isCached
26+
@docs UnsupportedPlatform, downloadUrl, download
2727

28-
@docs Command, InitFlags, ReplFlags, MakeFlags, MakeOutput, DocsFlags, DocsOutput, DiffArgs, Platform, encodeCommand, run
28+
@docs Command, ReplFlags, MakeFlags, MakeOutput, DocsFlags, DocsOutput, PackageValidateFlags, PackageDiffFlags, SourceFile, encodeCommand, run
2929

3030
-}
3131

@@ -141,6 +141,7 @@ type alias ReplFlags =
141141
}
142142

143143

144+
{-|-}
144145
type alias SourceFile =
145146
{ path : Path
146147
, data : String

src/Compiler/Dependencies.gren

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,38 @@ module Compiler.Dependencies exposing
55
)
66

77

8+
{-| The algorithm for calculating the required dependencies of a project.
9+
10+
@docs SimplifiedOutline, Solution, solve
11+
-}
12+
813
import Compiler.Outline as Outline exposing (Outline)
914
import Compiler.PackageName as PackageName exposing (PackageName)
1015
import Dict exposing (Dict)
1116
import SemanticVersion exposing (SemanticVersion)
1217
import SemanticVersionRange exposing (SemanticVersionRange)
1318

1419

20+
{-| A simlified outline only contains the information that is required by the algorithm.
21+
-}
1522
type alias SimplifiedOutline =
1623
{ name : PackageName
1724
, version : SemanticVersionRange
1825
, dependencies : Dict String SemanticVersionRange
1926
}
2027

2128

29+
{-| Return value of [solve](#solve). Let's you know if you've got all the required dependencies,
30+
or if you're missing something.
31+
-}
2232
type Solution
2333
= Complete
2434
| Missing { name : PackageName, version : SemanticVersionRange }
2535
| Conflict { name : PackageName, version1 : SemanticVersionRange, version2 : SemanticVersionRange }
2636

2737

38+
{-| Calculate the required dependencies of a project.
39+
-}
2840
solve : Array { name : PackageName, version : SemanticVersionRange } -> Dict String SimplifiedOutline -> Solution
2941
solve rootRequirements loadedOutlines =
3042
solveHelp rootRequirements Dict.empty loadedOutlines

src/Compiler/License.gren

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,46 @@ module Compiler.License exposing
88
)
99

1010

11+
{-| A module for working with OSI approved licenses.
12+
13+
@docs License, bsd3, toString, toJson, jsonDecoder, findMostSimilar
14+
-}
15+
1116
import Dict exposing (Dict)
1217
import Json.Decode as Decode exposing (Decoder)
1318
import Json.Encode as Encode
1419
import String.EditDistance as EditDistance
1520

1621

22+
{-| An OSI approved license.
23+
-}
1724
type License
1825
= License String
1926

2027

28+
{-| The BSD 3 Clause license.
29+
-}
2130
bsd3 : License
2231
bsd3 =
2332
License "BSD-3-Clause"
2433

2534

35+
{-| `String` representation for a [License](#License).
36+
-}
2637
toString : License -> String
2738
toString (License value) =
2839
value
2940

3041

42+
{-| JSON Encoder for [License](#License).
43+
-}
3144
toJson : License -> Encode.Value
3245
toJson license =
3346
Encode.string (toString license)
3447

3548

49+
{-| JSON Decoder for [License](#License).
50+
-}
3651
jsonDecoder : Decoder License
3752
jsonDecoder =
3853
Decode.string
@@ -48,6 +63,9 @@ decodeHelper givenCode =
4863
Decode.fail ("Invalid license name: " ++ givenCode)
4964

5065

66+
{-| Find the three most similar licenses to the given `String`. Useful if you have a
67+
mistyped license string and wish to suggest the correct typing.
68+
-}
5169
findMostSimilar : String -> Array String
5270
findMostSimilar givenCode =
5371
EditDistance.findMostSimilar
@@ -58,9 +76,9 @@ findMostSimilar givenCode =
5876
givenCode
5977

6078

61-
{-|
62-
-- OSI approved licenses in SPDX format.
63-
-- <https://spdx.org/licenses/>
79+
{-| OSI approved licenses in SPDX format.
80+
81+
Read more at <https://spdx.org/licenses/>.
6482
-}
6583
osiApprovedSpdxLicenses : Dict String String
6684
osiApprovedSpdxLicenses =

src/Compiler/ModuleName.gren

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,31 @@ module Compiler.ModuleName exposing
77
)
88

99

10+
{-| A module for working with Gren module names.
11+
12+
@docs ModuleName
13+
14+
## Constructors
15+
16+
@docs fromString, jsonDecoder
17+
18+
## Conversions
19+
20+
@docs toString, toJson
21+
-}
22+
1023
import Json.Decode as Decode exposing (Decoder)
1124
import Json.Encode as Encode
1225

1326

27+
{-|-}
1428
type ModuleName
1529
= ModuleName String
1630

1731

32+
{-| Construct a [ModuleName](#ModuleName) from a `String`. Will return `Nothing`
33+
if the `String` doesn't represent a valid [ModuleName](#ModuleName).
34+
-}
1835
fromString : String -> Maybe ModuleName
1936
fromString str =
2037
let
@@ -36,6 +53,8 @@ fromString str =
3653
Nothing
3754

3855

56+
{-| JSON Decoder for [ModuleName](#ModuleName).
57+
-}
3958
jsonDecoder : Decoder ModuleName
4059
jsonDecoder =
4160
Decode.string
@@ -50,11 +69,15 @@ jsonDecoder =
5069
)
5170

5271

72+
{-| `String` representation for [ModuleName](#ModuleName).
73+
-}
5374
toString : ModuleName -> String
5475
toString (ModuleName name) =
5576
name
5677

5778

79+
{-| JSON Encoder for [ModuleName](#ModuleName).
80+
-}
5881
toJson : ModuleName -> Encode.Value
5982
toJson moduleName =
6083
Encode.string (toString moduleName)

src/Compiler/Outline.gren

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ module Compiler.Outline exposing
1414
)
1515

1616

17+
{-| Module for working with `gren.json` files.
18+
19+
@docs Outline, AppOutline, PkgOutline, VersionConstraint, Exposed, defaultSummary, findSourceFiles
20+
21+
## JSON
22+
23+
@docs jsonDecoder, pkgJsonDecoder, toJson
24+
-}
25+
1726
import Bytes
1827
import SemanticVersion exposing (SemanticVersion)
1928
import SemanticVersionRange exposing (SemanticVersionRange)
@@ -29,11 +38,13 @@ import Dict exposing (Dict)
2938
import Task exposing (Task)
3039

3140

41+
{-|-}
3242
type Outline
3343
= App AppOutline
3444
| Pkg PkgOutline
3545

3646

47+
{-|-}
3748
type alias AppOutline =
3849
{ platform : Platform
3950
, sourceDirectories : Array Path
@@ -45,6 +56,7 @@ type alias AppOutline =
4556
}
4657

4758

59+
{-|-}
4860
type alias PkgOutline =
4961
{ platform : Platform
5062
, name : PackageName
@@ -57,23 +69,29 @@ type alias PkgOutline =
5769
}
5870

5971

72+
{-| Exposed modules in [PkgOutline](#PkgOutline).
73+
-}
6074
type Exposed
6175
= ExposedArray (Array ModuleName)
6276
| ExposedDict (Dict String (Array ModuleName))
6377

6478

79+
{-| A dependency version constraint. Either a `SemanticVersion`, `SemanticVersionRange` or a `Path` for a local dependency.
80+
-}
6581
type VersionConstraint a
6682
= Version a
6783
| LocalPath Path
6884

6985

86+
{-| The default summary created by `gren init`.
87+
-}
7088
defaultSummary : String
7189
defaultSummary =
7290
"helpful summary of your project, less than 80 characters"
7391

7492

75-
-- TODO: Ignore hidden directories
76-
-- More info: https://github.com/gren-lang/compiler/pull/287
93+
{-| Find the source files of a given project.
94+
-}
7795
findSourceFiles : FileSystem.Permission -> Outline -> Path -> Task FileSystem.Error (Array { path : Path, moduleName : String, source : String })
7896
findSourceFiles fsPerm outline outlinePath =
7997
let
@@ -138,6 +156,8 @@ readSourceFile fsPerm { absolute, relative } =
138156
)
139157

140158

159+
{-| JSON Decoder for [Outline](#Outline).
160+
-}
141161
jsonDecoder : Decoder Outline
142162
jsonDecoder =
143163
Decode.field "type" Decode.string
@@ -151,6 +171,8 @@ jsonDecoder =
151171
)
152172

153173

174+
{-| JSON Decoder for [PkgOutline](#PkgOutline).
175+
-}
154176
pkgJsonDecoder : Decoder PkgOutline
155177
pkgJsonDecoder =
156178
jsonDecoder
@@ -301,6 +323,8 @@ pkgDependenciesEncoder deps =
301323
Encode.dict identity (constraintEncoder SemanticVersionRange.toJson) deps
302324

303325

326+
{-| JSON Encoder for [Outline](#Outline).
327+
-}
304328
toJson : Outline -> Encode.Value
305329
toJson outline =
306330
when outline is

src/Compiler/PackageName.gren

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ module Compiler.PackageName exposing
2020

2121
{-| Functions for working with package identifiers.
2222

23-
@docs Package, example, author, name, fromString, cliParser, jsonDecoder, toString, toJson
23+
@docs PackageName, example
24+
25+
## Constructors
26+
27+
@docs fromString, cliParser, jsonDecoder
28+
29+
## Queries
30+
31+
@docs author, name
32+
33+
## Conversions
34+
35+
@docs toString, toJson
2436

2537
## Common package names
2638

@@ -130,6 +142,8 @@ cliParser =
130142
}
131143

132144

145+
{-| A JSON decoder for [PackageName](#PackageName)
146+
-}
133147
jsonDecoder : Decoder PackageName
134148
jsonDecoder =
135149
Decode.string

0 commit comments

Comments
 (0)