Skip to content

Commit 88fc93d

Browse files
committed
juledoc: update to latest syntax
1 parent 50e0891 commit 88fc93d

File tree

5 files changed

+115
-110
lines changed

5 files changed

+115
-110
lines changed

builder/builder.jule

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ struct Builder {
2323

2424
impl Builder {
2525
// Formats node and returns formatted code (including documentation comments).
26-
fn formatNode(self, mut node: ast::Node): str {
26+
fn formatNode(*self, mut node: ast::Node): str {
2727
self.fmt.buf.Clear()
2828
self.fmt.node(node)
2929
ret strings::TrimSpace(self.fmt.buf.Str())
3030
}
3131

3232
// Formats type and returns formatted code.
33-
fn formatType(self, mut t: &ast::Expr): str {
33+
fn formatType(*self, mut t: &ast::Expr): str {
3434
self.fmt.buf.Clear()
3535
self.fmt.formatType(t)
3636
ret strings::TrimSpace(self.fmt.buf.Str())
3737
}
3838

3939
// Builds context from doc comments.
40-
fn buildCtx(self, doc: str): []doc::Context {
40+
fn buildCtx(*self, doc: str): []doc::Context {
4141
ctxb := ctxBuilder{}
4242
ret ctxb.build(doc)
4343
}
4444

4545
// Reads documentation comments from code and returns meta.
4646
// Also returns code with no documentation comments.
47-
fn readDocComments(self, mut code: str): (str, []doc::Context) {
47+
fn readDocComments(*self, mut code: str): (str, []doc::Context) {
4848
// Read doc comments.
4949
mut doc := strings::Builder{}
5050
for len(code) > 0 {
@@ -74,25 +74,25 @@ impl Builder {
7474
ret code, ctx
7575
}
7676

77-
fn formatMainNode(self, mut ast: &ast::AST, mut &i: int): str {
78-
mut data, ok := ast.Nodes[i].Data.(&ast::Var)
77+
fn formatMainNode(*self, mut ast: &ast::AST, mut &i: *int): str {
78+
mut data, ok := ast.Nodes[*i].Data.(&ast::Var)
7979
if !ok {
80-
ret self.formatNode(ast.Nodes[i])
80+
ret self.formatNode(ast.Nodes[*i])
8181
}
8282
// For variables, do not use plain node formatting.
8383
// Variables may be grouped with a common documentation.
8484
// Do not waste it.
8585
self.fmt.buf.Clear()
8686
{
87-
mut row := ast.Nodes[i].Token.Row
87+
mut row := ast.Nodes[*i].Token.Row
8888
if len(data.Directives) > 0 {
8989
row = data.Directives[0].Tag.Row
9090
}
9191
if row-self.fmt.writeCommentsExcept(row, true) > 1 {
9292
self.fmt.write("\n")
9393
}
9494
}
95-
self.fmt.groupDecls[&ast::Var, ast::Node](ast.Nodes, i, fn(mut &d: &ast::Var) {
95+
self.fmt.groupDecls[&ast::Var, ast::Node](ast.Nodes, i, fn(mut d: &ast::Var) {
9696
unsafe {
9797
if !d.Bind && isPub(d.Name) {
9898
self.fmt.buf.Write(self.fmt.indent)!
@@ -103,12 +103,12 @@ impl Builder {
103103
// If variable is not grouped, the build function will advance the offset,
104104
// avoid false offset.
105105
if len(data.Group) == 0 {
106-
i--
106+
*i--
107107
}
108108
ret strings::TrimSpace(self.fmt.buf.Str())
109109
}
110110

111-
fn handleNodeDoc(self, node: ast::Node, mut doc: &doc::Doc): &doc::Doc {
111+
fn handleNodeDoc(*self, node: ast::Node, mut doc: &doc::Doc): &doc::Doc {
112112
match type node.Data {
113113
| &ast::Var:
114114
// NOTE:
@@ -172,16 +172,16 @@ impl Builder {
172172
ret doc
173173
}
174174

175-
fn mainNode(self, mut ast: &ast::AST, mut &i: int): &doc::Doc {
175+
fn mainNode(*self, mut ast: &ast::AST, mut &i: *int): &doc::Doc {
176176
mut doc := new(doc::Doc)
177177
code, mut ctx := self.readDocComments(self.formatMainNode(ast, i))
178178
doc.Code = code
179179
doc.Ctx = ctx
180-
node := ast.Nodes[i]
180+
node := ast.Nodes[*i]
181181
ret self.handleNodeDoc(node, doc)
182182
}
183183

184-
fn node(self, mut node: ast::Node): &doc::Doc {
184+
fn node(*self, mut node: ast::Node): &doc::Doc {
185185
mut doc := new(doc::Doc)
186186
code, mut ctx := self.readDocComments(self.formatNode(node))
187187
doc.Code = code
@@ -191,7 +191,7 @@ impl Builder {
191191

192192
// Returns MetaStruct by ident.
193193
// If not exist already, appends new MetaStruct by ident and returns it.
194-
fn getStructMeta(self, ident: str): &doc::MetaStruct {
194+
fn getStructMeta(*self, ident: str): &doc::MetaStruct {
195195
for (_, mut hash) in self.structMetas {
196196
if hash.ident == ident {
197197
ret hash.meta
@@ -205,7 +205,7 @@ impl Builder {
205205
ret meta
206206
}
207207

208-
fn analysisImpl(self, mut ast: &ast::Impl) {
208+
fn analysisImpl(*self, mut ast: &ast::Impl) {
209209
// Destination type should be simple identifier type.
210210
// Otherwise we have to assume this implementation is not suitable to analysis.
211211
dest, _ := ast.Dest.Data.(&ast::NameExpr)
@@ -239,7 +239,7 @@ impl Builder {
239239
}
240240

241241
// Dispatches all collected struct meta.
242-
fn dispatchStructMeta(self, mut doc: []&doc::Doc) {
242+
fn dispatchStructMeta(*self, mut doc: []&doc::Doc) {
243243
for (_, mut hash) in self.structMetas {
244244
for (_, mut node) in doc {
245245
if (node.Owner == doc::Struct || node.Owner == doc::StrictTypeAlias) &&
@@ -251,13 +251,13 @@ impl Builder {
251251
}
252252

253253
// Dispatches all collected meta.
254-
fn DispatchMeta(self, mut doc: []&doc::Doc) {
254+
fn DispatchMeta(*self, mut doc: []&doc::Doc) {
255255
self.dispatchStructMeta(doc)
256256
}
257257

258258
// Builds and returns documentation.
259259
// Will not dispatch meta.
260-
fn BuildPartial(self, mut ast: &ast::AST, mut cm: &CommentMap): []&doc::Doc {
260+
fn BuildPartial(*self, mut ast: &ast::AST, mut cm: &CommentMap): []&doc::Doc {
261261
if ast == nil {
262262
ret nil
263263
}
@@ -274,7 +274,7 @@ impl Builder {
274274
|:
275275
// no-op
276276
}
277-
mut nodeDoc := self.mainNode(ast, i)
277+
mut nodeDoc := self.mainNode(ast, &i)
278278
if nodeDoc == nil {
279279
continue
280280
}
@@ -288,7 +288,7 @@ impl Builder {
288288
}
289289

290290
// Builds and returns documentation with dispatched meta.
291-
fn Build(self, mut ast: &ast::AST, mut cm: &CommentMap): []&doc::Doc {
291+
fn Build(*self, mut ast: &ast::AST, mut cm: &CommentMap): []&doc::Doc {
292292
mut doc := self.BuildPartial(ast, cm)
293293
self.DispatchMeta(doc)
294294
ret doc

builder/commentmap.jule

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct CommentMap {
1616
}
1717

1818
impl CommentMap {
19-
fn first(mut self, row: int): &comment {
19+
fn first(mut *self, row: int): &comment {
2020
if len(self.buf) == 0 {
2121
ret nil
2222
}
@@ -27,11 +27,11 @@ impl CommentMap {
2727
ret c
2828
}
2929

30-
fn dropFirst(mut self) {
30+
fn dropFirst(mut *self) {
3131
self.buf = self.buf[1:]
3232
}
3333

34-
fn pop(mut self, row: int): &comment {
34+
fn pop(mut *self, row: int): &comment {
3535
if len(self.buf) == 0 {
3636
ret nil
3737
}
@@ -43,7 +43,7 @@ impl CommentMap {
4343
ret c
4444
}
4545

46-
fn find(mut self, row: int): &comment {
46+
fn find(mut *self, row: int): &comment {
4747
if len(self.buf) == 0 {
4848
ret nil
4949
}
@@ -56,13 +56,13 @@ impl CommentMap {
5656
}
5757

5858
// Builds CommentMap from source code tokens.
59-
fn BuildCommentMap(mut &tokens: []&token::Token): &CommentMap {
59+
fn BuildCommentMap(mut &tokens: *[]&token::Token): &CommentMap {
6060
mut cm := &CommentMap{
6161
buf: make([]&comment, 0, 1<<8),
6262
}
6363
mut i := 0
64-
for i < len(tokens) {
65-
token := tokens[i]
64+
for i < len(*tokens) {
65+
token := (*tokens)[i]
6666
if token.ID != token::COMMENT {
6767
i++
6868
continue
@@ -75,8 +75,8 @@ fn BuildCommentMap(mut &tokens: []&token::Token): &CommentMap {
7575
txt: token.Kind,
7676
})
7777
}
78-
_ = copy(tokens[i:], tokens[i+1:])
79-
tokens = tokens[:len(tokens)-1]
78+
_ = copy((*tokens)[i:], (*tokens)[i+1:])
79+
*tokens = (*tokens)[:len(*tokens)-1]
8080
}
8181
ret cm
8282
}

builder/ctxbuilder.jule

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct ctxBuilder {
1313
}
1414

1515
impl ctxBuilder {
16-
fn text(self): doc::Text {
16+
fn text(*self): doc::Text {
1717
mut txt := strings::Builder{}
1818
line, indent := handleDocLine(self.lines[self.i])
1919
txt.WriteStr(line)!
@@ -44,7 +44,7 @@ impl ctxBuilder {
4444
ret doc::Text(txt.Str())
4545
}
4646

47-
fn list(self, mut line: str): doc::ListItem {
47+
fn list(*self, mut line: str): doc::ListItem {
4848
mut txt := strings::Builder{}
4949
txt.WriteStr(strings::TrimSpace(line[1:]))! // Add text with no list mark.
5050
self.i++ // Skip current line.
@@ -61,7 +61,7 @@ impl ctxBuilder {
6161
ret doc::ListItem(txt.Str())
6262
}
6363

64-
fn next(self): doc::Context {
64+
fn next(*self): doc::Context {
6565
mut ctx := doc::Context{}
6666
mut line := self.lines[self.i]
6767
line, ctx.Indent = handleDocLine(line)
@@ -77,7 +77,7 @@ impl ctxBuilder {
7777
}
7878

7979
// Removes leading and trailing separator lines.
80-
fn simplifyLines(self) {
80+
fn simplifyLines(*self) {
8181
if len(self.lines) == 0 {
8282
ret
8383
}
@@ -105,7 +105,7 @@ impl ctxBuilder {
105105
}
106106

107107
// Builds context from doc comments.
108-
fn build(self, doc: str): []doc::Context {
108+
fn build(*self, doc: str): []doc::Context {
109109
mut ctx := make([]doc::Context, 0)
110110
self.i = 0
111111
self.lines = strings::Split(doc, "\n")

0 commit comments

Comments
 (0)