aboutsummaryrefslogtreecommitdiffhomepage
path: root/site/user/api/usingBookmaker.md
blob: 004361a2dc7bdbabe5443e62b5e248e6844b8f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
usingBookmaker
===

# <a name='Bookmaker'>Bookmaker</a>
How to use the <a href='#Bookmaker'>Bookmaker</a> utility.

## <a name='Broken_Build'>Broken Build</a>

If the <a href='https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker'>Housekeeper-PerCommit-Bookmaker</a></a> bot is red, the bot has detected that the files in docs and include/core differ.

The bot output describes what changed.

To fix this, edit the docs file corresponding to the changed include file.

For instance, if the change was made to <a href='SkIRect_Reference#SkIRect'>SkIRect</a>, edit docs/SkIRect_Reference.bmh.
Checking in the edited docs/SkIRect_Reference.bmh will fix the bot.

If the interface is deprecated, but still present in the interface, mark-up the
documentation to be deprecated as well.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
#Method void someMethodThatIsNowDeprecated()
#Deprecated
##
</pre>

Use

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
##Deprecated soon
</pre>

if the change is soon to be deprecated.

To regenerate the documentation, follow the <a href='#Installing'>Installing</a> and <a href='#Regenerate'>Regenerate</a> steps below.

If the <a href='https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker'>Housekeeper-Nightly-Bookmaker</a></a> bot is red, one of several things may have gone wrong:

<table>  <tr>
    <td>A change to include broke documentation examples.</td>
  </tr>  <tr>
    <td>Something changed the examples that output text.</td>
  </tr>  <tr>
    <td>Some interface was added, deleted, edited.</td>
  </tr>  <tr>
    <td>Documentation is malformed.</td>
  </tr>
</table>

The bot output describes what changed, and includes the file and line
where the error occurred.

To regenerate the documentation, follow the <a href='#Installing'>Installing</a> and <a href='#Regenerate'>Regenerate</a> steps below.

## <a name='Editing_Comments'>Editing Comments</a>

Edit docs instead of include/core files to update comments if possible.

The <a href='#Bookmaker'>Bookmaker</a> bots do not complain if the docs file does not match the
corresponding include comments. Running <a href='#Bookmaker'>Bookmaker</a> include generation will
report when docs and includes comments do not match.

For instance, if include/core/SkSurface.h comments do not match
docs/SkSurface_Reference.bmh, running:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
</pre>

generates

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
wrote updated <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.h
</pre>

The updated SkSurface.h is written to the root to avoid subsequent runs of
<a href='#Bookmaker'>Bookmaker</a> from recompiling. if SkSurface.h was not changed, it is not written,
and <a href='#Bookmaker'>Bookmaker</a> will not generate any output.

## <a name='Broken_Example'>Broken Example</a>

An example may cause <a href='#Bookmaker'>Bookmaker</a> or a bot running <a href='#Bookmaker'>Bookmaker</a> to fail if it can't
be compiled by fiddle. If the example cannot be fixed, it can be commented out
by changing

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
#Example
</pre>

to

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
#NoExample
</pre>

.
The disabled example can contain additional markup,
which will be ignored.

## <a name='Installing'>Installing</a>

Install <a href='https://golang.org/doc/install'>Go</a></a> if needed.
Get the fiddle command line interface tool.
By default this will appear in your home directory.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ go get go.skia.org/infra/fiddle/go/fiddlecli
</pre>

Build <a href='#Bookmaker'>Bookmaker</a>.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ninja -C out/dir bookmaker
</pre>

## <a name='Regenerate'>Regenerate</a>

Complete rebuilding of all bookmaker output looks like:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/skia/bookmaker -a docs/status.json -e fiddle.json
$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
$ ./out/skia/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
$ ./out/skia/bookmaker -a docs/status.json -x
$ ./out/skia/bookmaker -a docs/status.json -p
</pre>

## <a name='New_Documentation'>New Documentation</a>

Generate an starter <a href='#Bookmaker'>Bookmaker</a> file from an existing include.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
</pre>

If a method or function has an unnamed parameter, bookmaker generates an error:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
C:/puregit/include/core/<a href='SkPixmap_Reference#SkPixmap'>SkPixmap</a>.h(208): error: #Method missing param name
bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const
           ^
</pre>

All parameters require names to allow markdown and doxygen documents to refer to
them. After naming all parameters, check in the include before continuing.

A successful run generates

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
docs/SkXXX_Reference.bmh
</pre>

.

Next, use your favorite editor to fill out

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
docs/SkXXX_Reference.bmh
</pre>

.

## <a name='Style'>Style</a>

Documentation consists of cross references, descriptions, and examples.
All structs, classes, enums, their members and methods, functions, and so on,
require descriptions. Most also require examples.

All methods and functions should include examples if practical.
It's difficult to think of a meaningful example for class destructors.
In cases like these, change the placeholder:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
#Example
</pre>

to:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
#NoExample
</pre>

Descriptions start with an active verb. Descriptions are complete, punctuated
sentences unless they describe parameters or return values. Parameters and
returned values are described by phrases that start lower case and do not
include trailing punctuation.

Descriptions are not self-referential; they do not include the thing they
describe. Descriptions may contain upper case or camel case references to
definitions but otherwise should be free of jargon.

Descriptions may contain code and formulas, each bracketed by markup.

Similar items may be grouped into topics. Topics may include subtopics.

Each document begins with one or more indices that include the contents of
that file. A class reference includes an index listing contained topics,
a separate listing for constructors, one for methods, and so on.

Class methods contain a description, any parameters, any return value,
an example, and any cross references.

Each method must contain either one or more examples or markup indicating
that there is no example.

After editing is complete, searching for "" should fail,
assuming "" is not the perfect word to use in a description or
example!

## <a name='Adding_Documentation'>Adding Documentation</a>

Generate fiddle.json from all examples, including the ones you just wrote.
Error checking is syntatic: starting keywords are closed, keywords have the
correct parents.
If you run <a href='#Bookmaker'>Bookmaker</a> inside Visual_Studio, you can click on errors and it
will take you to the source line in question.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -e fiddle.json -b docs
</pre>

Once complete, run fiddlecli to generate the example hashes.
Errors are contained by the output but aren't reported yet.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
</pre>

Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
Error checking includes: undefined references, fiddle compiler errors,
missing or mismatched printf output.
Again, you can click on any errors inside Visual_Studio.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
</pre>

The original include may have changed since you started creating the markdown.
Check to see if it is up to date.
This reports if a method no longer exists or its parameters have changed.

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
</pre>

Generate an updated include header. Run:

<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
</pre>

to write the updated SkXXX.h to the current directory.

Once adding the file is complete, add the file to status.json in the
Completed section. You may add it to the InProgress section during
development, or leave status.json unchanged.

If the new file has been added to status.json, you can run
any of the above commands with -a docs/status.json in place of
-b docs or -i includes.

## <a name='Bugs'>Bugs</a>

<a href='#Bookmaker'>Bookmaker</a> bugs are tracked <a href='https://bug.skia.org/6898'>here</a></a> .