Skip to content

Commit 1a13f3b

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 1a13f3b

Some content is hidden

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

68 files changed

+7819
-4483
lines changed

.github/workflows/ponyc-tier3.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ jobs:
157157
gmake test-pony-lint config=debug
158158
gmake test-pony-lsp config=debug
159159
gmake lint-pony-lint config=debug
160+
gmake lint-pony-doc config=debug
161+
gmake lint-pony-lsp config=debug
160162
gmake configure config=release
161163
gmake build config=release
162164
gmake test-ci-core config=release
@@ -274,6 +276,8 @@ jobs:
274276
gmake test-pony-lint config=debug
275277
gmake test-pony-lsp config=debug
276278
gmake lint-pony-lint config=debug
279+
gmake lint-pony-doc config=debug
280+
gmake lint-pony-lsp config=debug
277281
gmake configure config=release
278282
gmake build config=release
279283
gmake test-ci-core config=release
@@ -501,6 +505,8 @@ jobs:
501505
gmake test-pony-lint config=debug
502506
gmake test-pony-lsp config=debug
503507
gmake lint-pony-lint config=debug
508+
gmake lint-pony-doc config=debug
509+
gmake lint-pony-lsp config=debug
504510
gmake configure config=release
505511
gmake build config=release
506512
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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ _ReSharper.*
3232
src/common/dtrace_probes.h
3333
packages/stdlib/stdlib
3434
/stdlib-docs/
35-
tools/pony-lsp/version.pony
35+
tools/pony-lsp/pony_lsp_version.pony
3636
tools/pony-lint/version.pony
3737
tools/pony-doc/version.pony
3838

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)

0 commit comments

Comments
 (0)