Skip to content

Commit db8086a

Browse files
committed
Lint pony-doc and pony-lsp in CI
pony-lint was already linting its own source in CI. This extends that to pony-doc and pony-lsp so all three tools are held to the same standard. Adds lint-pony-doc and lint-pony-lsp Makefile targets and wires them into pr-tools.yml and ponyc-tier3.yml. Fixes all lint violations in both tools: file renames to match principal types, line-length wrapping, docstring formatting, blank-line spacing, call-argument formatting, exhaustive-match annotations, hard-tab removal, and public docstrings. Test fixtures in pony-lsp/test/error_workspace/ are excluded via .ignore since they contain intentional compile errors.
1 parent 6eed3c4 commit db8086a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7794
-4475
lines changed

.github/workflows/ponyc-tier3.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ jobs:
156156
gmake test-pony-doc config=debug
157157
gmake test-pony-lint config=debug
158158
gmake test-pony-lsp config=debug
159-
gmake lint-pony-lint config=debug
160159
gmake configure config=release
161160
gmake build config=release
162161
gmake test-ci-core config=release
@@ -273,7 +272,6 @@ jobs:
273272
gmake test-pony-doc config=debug
274273
gmake test-pony-lint config=debug
275274
gmake test-pony-lsp config=debug
276-
gmake lint-pony-lint config=debug
277275
gmake configure config=release
278276
gmake build config=release
279277
gmake test-ci-core config=release
@@ -500,7 +498,6 @@ jobs:
500498
gmake test-pony-doc config=debug
501499
gmake test-pony-lint config=debug
502500
gmake test-pony-lsp config=debug
503-
gmake lint-pony-lint config=debug
504501
gmake configure config=release
505502
gmake build config=release
506503
gmake test-ci-core config=release

.github/workflows/pr-tools.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
run: make test-pony-lsp config=debug
5353
- name: Lint pony-lint
5454
run: make lint-pony-lint config=debug
55+
- name: Lint pony-doc
56+
run: make lint-pony-doc config=debug
57+
- name: Lint pony-lsp
58+
run: make lint-pony-lsp config=debug
5559

5660
macos:
5761
if: github.event.pull_request.draft == false

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,12 @@ test-pony-lint: all
275275
lint-pony-lint: all
276276
$(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc --path ../../tools/lib/ponylang/pony_compiler/ -b pony-lint-ci ../../tools/pony-lint && echo Built `pwd`/pony-lint-ci && PONYPATH=../../tools/lib/ponylang/pony_compiler:$(PONYPATH) ./pony-lint-ci ../../tools/pony-lint/
277277

278+
lint-pony-doc: all
279+
$(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc --path ../../tools/lib/ponylang/pony_compiler/ -b pony-lint-ci ../../tools/pony-lint && echo Built `pwd`/pony-lint-ci && PONYPATH=../../tools/lib/ponylang/pony_compiler:$(PONYPATH) ./pony-lint-ci ../../tools/pony-doc/
280+
281+
lint-pony-lsp: all
282+
$(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc --path ../../tools/lib/ponylang/pony_compiler/ -b pony-lint-ci ../../tools/pony-lint && echo Built `pwd`/pony-lint-ci && PONYPATH=../../tools/lib/ponylang/pony_compiler:$(PONYPATH) ./pony-lint-ci ../../tools/pony-lsp/
283+
278284
test-pony-compiler: all
279285
$(SILENT)cd '$(outDir)' && PONYPATH=.:$(PONYPATH) ./ponyc --path ../../tools/lib/ponylang/pony_compiler/ -b pony-compiler-tests ../../tools/lib/ponylang/pony_compiler/tests && echo Build `pwd`/pony-compiler-tests && PONYPATH=../../tools/lib/ponylang/pony_compiler:../../packages:$(PONYPATH) ./pony-compiler-tests --sequential
280286

tools/pony-doc/_assets.pony

Lines changed: 2013 additions & 1038 deletions
Large diffs are not rendered by default.

tools/pony-doc/_type_extractor.pony

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ primitive _TypeExtractor
1717
match type_ast.id()
1818
| ast.TokenIds.tk_nominal() => _nominal(type_ast, package_map)
1919
| ast.TokenIds.tk_typeparamref() => _type_param_ref(type_ast)
20-
| ast.TokenIds.tk_uniontype() => _type_list(type_ast, package_map,
20+
| ast.TokenIds.tk_uniontype() =>
21+
_type_list(
22+
type_ast,
23+
package_map,
2124
{(types) => DocUnion(types) })
22-
| ast.TokenIds.tk_isecttype() => _type_list(type_ast, package_map,
25+
| ast.TokenIds.tk_isecttype() =>
26+
_type_list(
27+
type_ast,
28+
package_map,
2329
{(types) => DocIntersection(types) })
24-
| ast.TokenIds.tk_tupletype() => _type_list(type_ast, package_map,
30+
| ast.TokenIds.tk_tupletype() =>
31+
_type_list(
32+
type_ast,
33+
package_map,
2534
{(types) => DocTuple(types) })
2635
| ast.TokenIds.tk_arrow() => _arrow(type_ast, package_map)
2736
| ast.TokenIds.tk_thistype() => DocThis
@@ -93,8 +102,14 @@ primitive _TypeExtractor
93102
Filter.is_private(raw_name),
94103
Filter.is_internal(raw_name))
95104
else
96-
DocNominal("unknown", "", recover val Array[DocType] end,
97-
None, None, false, false)
105+
DocNominal(
106+
"unknown",
107+
"",
108+
recover val Array[DocType] end,
109+
None,
110+
None,
111+
false,
112+
false)
98113
end
99114

100115
fun _type_param_ref(type_ast: ast.AST box): DocTypeParamRef =>
@@ -126,7 +141,10 @@ primitive _TypeExtractor
126141
builder: {(Array[DocType] val): DocType} val)
127142
: DocType
128143
=>
129-
"""Extracts child types and wraps them via the builder function."""
144+
"""
145+
Extracts child types and wraps them via the builder
146+
function.
147+
"""
130148
let result: Array[DocType] iso = recover iso Array[DocType] end
131149
for child in type_ast.children() do
132150
result.push(apply(child, package_map))
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ primitive _Unreachable
1212
fun apply(loc: SourceLoc = __loc): None =>
1313
let url = "https://github.com/ponylang/ponyc/issues"
1414
let fmt = "Unreachable at %s:%zu\nPlease report: " + url + "\n"
15-
@fprintf(@pony_os_stderr(), fmt.cstring(),
16-
loc.file().cstring(), loc.line())
15+
@fprintf(
16+
@pony_os_stderr(),
17+
fmt.cstring(),
18+
loc.file().cstring(),
19+
loc.line())
1720
@exit(1)

tools/pony-doc/backend.pony

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
use "files"
22

33
trait Backend
4-
"""Generates documentation output from a `DocProgram` IR."""
4+
"""
5+
Generates documentation output from a `DocProgram` IR.
6+
"""
57
fun generate(
68
program: DocProgram box,
79
output_dir: FilePath,
810
include_private: Bool)
911
?
12+
=>
13+
"""
14+
Generate documentation for the given program.
15+
"""
16+
None

tools/pony-doc/doc_type.pony

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,38 @@ class val DocTypeParamRef
5555
ephemeral = ephemeral'
5656

5757
class val DocUnion
58-
"""A union type (e.g., `(String | None)`)."""
58+
"""
59+
A union type (e.g., `(String | None)`).
60+
"""
5961
let types: Array[DocType] val
6062

6163
new val create(types': Array[DocType] val) =>
6264
types = types'
6365

6466
class val DocIntersection
65-
"""An intersection type (e.g., `(Stringable & Hashable)`)."""
67+
"""
68+
An intersection type
69+
(e.g., `(Stringable & Hashable)`).
70+
"""
6671
let types: Array[DocType] val
6772

6873
new val create(types': Array[DocType] val) =>
6974
types = types'
7075

7176
class val DocTuple
72-
"""A tuple type (e.g., `(String, U32)`)."""
77+
"""
78+
A tuple type (e.g., `(String, U32)`).
79+
"""
7380
let types: Array[DocType] val
7481

7582
new val create(types': Array[DocType] val) =>
7683
types = types'
7784

7885
class val DocArrow
79-
"""An arrow (viewpoint adaptation) type (e.g., `this->T`)."""
86+
"""
87+
An arrow (viewpoint adaptation) type
88+
(e.g., `this->T`).
89+
"""
8090
let left: DocType
8191
let right: DocType
8292

@@ -85,7 +95,9 @@ class val DocArrow
8595
right = right'
8696

8797
class val DocThis
88-
"""The `this` type literal."""
98+
"""
99+
The `this` type literal.
100+
"""
89101
new val create() => None
90102

91103
class val DocCapability

tools/pony-doc/doc_types.pony

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class val DocProgram
2-
"""Top-level IR node representing an entire compiled Pony program."""
2+
"""
3+
Top-level IR node representing an entire compiled
4+
Pony program.
5+
"""
36
let name: String
47
let packages: Array[DocPackage] val
58

@@ -8,7 +11,10 @@ class val DocProgram
811
packages = packages'
912

1013
class val DocPackage
11-
"""A Pony package with its documented types and source files."""
14+
"""
15+
A Pony package with its documented types and source
16+
files.
17+
"""
1218
let qualified_name: String
1319
let doc_string: (String | None)
1420
let public_types: Array[DocEntity] val
@@ -84,7 +90,10 @@ class val DocEntity
8490
source = source'
8591

8692
class val DocMethod
87-
"""A documented method (constructor, function, or behaviour)."""
93+
"""
94+
A documented method (constructor, function, or
95+
behaviour).
96+
"""
8897
let kind: MethodKind
8998
let name: String
9099
let cap: (String | None)
@@ -117,7 +126,10 @@ class val DocMethod
117126
source = source'
118127

119128
class val DocField
120-
"""A documented field (var, let, or embed). Only public fields are collected."""
129+
"""
130+
A documented field (var, let, or embed). Only public
131+
fields are collected.
132+
"""
121133
let kind: FieldKind
122134
let name: String
123135
let field_type: DocType
@@ -138,7 +150,10 @@ class val DocField
138150
source = source'
139151

140152
class val DocParam
141-
"""A method parameter with its type and optional default value."""
153+
"""
154+
A method parameter with its type and optional default
155+
value.
156+
"""
142157
let name: String
143158
let param_type: DocType
144159
let default_value: (String | None)
@@ -153,7 +168,10 @@ class val DocParam
153168
default_value = default_value'
154169

155170
class val DocTypeParam
156-
"""A type parameter with optional constraint and default type."""
171+
"""
172+
A type parameter with optional constraint and default
173+
type.
174+
"""
157175
let name: String
158176
let constraint: (DocType | None)
159177
let default_type: (DocType | None)

tools/pony-doc/entity_kind.pony

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,59 @@ type EntityKind is
1212
| EntityTypeAlias )
1313

1414
primitive EntityClass
15-
"""Represents a Pony `class` declaration."""
15+
"""
16+
Represents a Pony `class` declaration.
17+
"""
1618
fun string(): String => "class"
1719
fun keyword(): String => "class"
1820

1921
primitive EntityActor
20-
"""Represents a Pony `actor` declaration."""
22+
"""
23+
Represents a Pony `actor` declaration.
24+
"""
2125
fun string(): String => "actor"
2226
fun keyword(): String => "actor"
2327

2428
primitive EntityTrait
25-
"""Represents a Pony `trait` declaration."""
29+
"""
30+
Represents a Pony `trait` declaration.
31+
"""
2632
fun string(): String => "trait"
2733
fun keyword(): String => "trait"
2834

2935
primitive EntityInterface
30-
"""Represents a Pony `interface` declaration."""
36+
"""
37+
Represents a Pony `interface` declaration.
38+
"""
3139
fun string(): String => "interface"
3240
fun keyword(): String => "interface"
3341

3442
primitive EntityPrimitive
35-
"""Represents a Pony `primitive` declaration."""
43+
"""
44+
Represents a Pony `primitive` declaration.
45+
"""
3646
fun string(): String => "primitive"
3747
fun keyword(): String => "primitive"
3848

3949
primitive EntityStruct
40-
"""Represents a Pony `struct` declaration."""
50+
"""
51+
Represents a Pony `struct` declaration.
52+
"""
4153
fun string(): String => "struct"
4254
fun keyword(): String => "struct"
4355

4456
primitive EntityTypeAlias
45-
"""Represents a Pony `type` alias declaration."""
57+
"""
58+
Represents a Pony `type` alias declaration.
59+
"""
4660
fun string(): String => "type"
4761
fun keyword(): String => "type"
4862

4963
primitive EntityKindBuilder
50-
"""Maps a pony_compiler TokenId to the corresponding EntityKind."""
64+
"""
65+
Maps a pony_compiler TokenId to the corresponding
66+
EntityKind.
67+
"""
5168
fun apply(id: ast.TokenId): EntityKind ? =>
5269
match id
5370
| ast.TokenIds.tk_class() => EntityClass

0 commit comments

Comments
 (0)