Skip to content

Commit e698c42

Browse files
committed
rename Method to InstanceMethod
1 parent d5ea277 commit e698c42

File tree

5 files changed

+14
-68
lines changed

5 files changed

+14
-68
lines changed

class.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import (
88
type Classes []Class
99

1010
type Class struct {
11-
Methods Methods `json:"methods"`
12-
Name string `json:"name"`
13-
Line int `json:"line"`
14-
// Comment string `json:"comment"`
15-
Comment template.HTML `json:"comment"`
16-
Filename string
17-
Commit string
18-
Repo string
11+
ClassMethods Methods `json:"class_methods"`
12+
InstanceMethods Methods `json:"instance_methods"`
13+
Name string `json:"name"`
14+
Line int `json:"line"`
15+
Comment template.HTML `json:"comment"`
16+
Filename string
17+
Commit string
18+
Repo string
1919
}
2020

2121
func (a *Class) MatchName(str string) bool {

docs/index.html

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -126,61 +126,7 @@ <h2>Setup &amp; Update Goby Documentation</h2>
126126

127127
<h2>Documenting Goby Code</h2>
128128

129-
<p>We use Markdown to document. All markdown syntax are supported.</p>
130-
131-
<h3>Documenting Classes</h3>
132-
133-
<p>All classes can be found in <code>/vm</code> directory. Each class is represented by a file. For example, you can find <code>Integer</code> class in <code>integer.go</code> file.</p>
134-
135-
<p>The class definition can be found with the <code>type</code> named as the filename or suffixed with &ldquo;Object&rdquo;. The documentation for this class is right above this <code>type</code>. For example, <code>Integer</code> class is documented as:</p>
136-
137-
<pre><code class="go">// Integer represents number objects which can bring into mathematical calculations.
138-
//
139-
// ```
140-
// 1 + 1 # =&gt; 2
141-
// 2 * 2 # =&gt; 4
142-
// ```
143-
type IntegerObject struct {
144-
Class *RInteger
145-
Value int
146-
}
147-
</code></pre>
148-
149-
<h3>Documenting Methods</h3>
150-
151-
<p>Methods of a class are stored in an array, with its name prefixed with <code>builtin</code> and suffixed with <code>Methods</code>. For example, the name for <code>Integer</code> class is <code>builtinIntegerMethods</code>.</p>
152-
153-
<p>Each method comes with two keys, <code>Fn</code> and <code>Name</code>. The document of a method comes right above <code>Name</code>. For example:</p>
154-
155-
<pre><code class="go">var builtinIntegerMethods = []*BuiltInMethod{
156-
{
157-
// Returns the sum of self and another Integer.
158-
//
159-
// ```
160-
// 1 + 1
161-
// ```
162-
Name: &quot;+&quot;,
163-
Fn: func(receiver Object) builtinMethodBody {
164-
// ...
165-
},
166-
},
167-
}
168-
</code></pre>
169-
170-
<p>Remember to leave one space after <code>//</code>.</p>
171-
172-
<h3>Others</h3>
173-
174-
<p>Currently the documentation only supports <code>//</code> comments, not <code>/* */</code>. The following style will not be parsed:</p>
175-
176-
<pre><code class="go">/*
177-
Integer represents number objects which can bring into mathematical calculations.
178-
*/
179-
type IntegerObject struct {
180-
Class *RInteger
181-
Value int
182-
}
183-
</code></pre>
129+
<p>Go to <a href="https://github.com/goby-lang/goby/wiki/Documenting-Goby-Code">Goby wiki</a>.</p>
184130

185131
</div>
186132

html.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ func generateClassFile(classes Classes, class Class) {
4141
panicIf(err)
4242
classComment := blackfriday.MarkdownCommon([]byte(class.Comment))
4343
class.Comment = template.HTML(string(classComment))
44-
for i := 0; i < len(class.Methods); i++ {
45-
methodComment := blackfriday.MarkdownCommon([]byte(class.Methods[i].Comment))
46-
class.Methods[i].Comment = template.HTML(methodComment)
44+
for i := 0; i < len(class.InstanceMethods); i++ {
45+
methodComment := blackfriday.MarkdownCommon([]byte(class.InstanceMethods[i].Comment))
46+
class.InstanceMethods[i].Comment = template.HTML(methodComment)
4747
}
4848
variables := map[string]interface{}{
4949
"classes": classes,

parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func classFromFile(filepath string) Class {
105105
allMethods = append(allMethods, method)
106106
}
107107

108-
class.Methods = allMethods
108+
class.InstanceMethods = allMethods
109109
return class
110110
}
111111

templates/html/class.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h2>Description</h2>
88

99
<h2>Instance Methods</h2>
1010
<hr />
11-
{{ range .class.Methods }}
11+
{{ range .class.InstanceMethods }}
1212
<h4 class="method">
1313
<span class="prefix">#</span>
1414
<span class="title">{{.FnName}}</span>

0 commit comments

Comments
 (0)