• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1usingBookmaker
2===
3<a href='usingBookmaker#Bookmaker'>Bookmaker</a> generates markdown files to view documentation on skia.org, and generates includes for use in C++.
4<a href='usingBookmaker#Bookmaker'>Bookmaker</a> reads canonical documentation from files suffixed with bmh in the docs directory. These bmh
5files describe how public interfaces work, and generate Skia fiddle examples to illustrate them.
6
7The docs files must be manually edited to stay current with Skia as it evolves.
8
9<a name='Installing'></a>
10
11Install
12<a href='https://golang.org/doc/install'>Go</a></a> if needed.
13Check the version. The results should be 1.10 or greater.
14
15<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
16$ go version
17</pre>
18
19Get the fiddle command <a href='undocumented#Line'>line</a> interface tool.
20By default this will appear in your home directory.
21
22<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
23$ go get go.skia.org/infra/fiddlek/go/fiddlecli
24</pre>
25
26Check the version. The command should work and the result should be 1.0 or greater.
27
28<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
29$ ~/go/bin/fiddlecli --version
30</pre>
31
32If fiddlecli is already installed but out of date, update with:
33
34<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
35$ go get -u go.skia.org/infra/fiddlek/go/fiddlecli
36</pre>
37
38Build <a href='usingBookmaker#Bookmaker'>Bookmaker</a>.
39
40<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
41$ ninja -C out/skia <a href='usingBookmaker#Bookmaker'>bookmaker </a>
42</pre>
43
44<a name='Running'></a>
45
46<a href='usingBookmaker#Bookmaker'>Bookmaker</a> extracts examples, generates example hashes with fiddle, and generates web markdown
47and c++ includes.
48
49<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
50$ ./out/skia/bookmaker -E && ~/go/bin/fiddlecli --quiet && ./out/skia/bookmaker
51</pre>
52
53A successful run generates:
54
55<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
56cross-check...................
57</pre>
58
59<a name='Broken_Build'></a>
60
61The bots
62<a href='https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker'>Housekeeper-PerCommit-Bookmaker</a></a> and
63<a href='https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker'>Housekeeper-Nightly-Bookmaker</a></a> verify that <a href='usingBookmaker#Bookmaker'>Bookmaker</a> <a href='undocumented#Data'>data</a> in docs builds without error and is consistent with include files it documents.
64
65Possible failures include:
66
67<table>  <tr>
68    <td>Public interface in include directory does not match documented interface in docs directory.</td>
69  </tr>  <tr>
70    <td>Example in <a href='usingBookmaker#Bookmaker'>bookmaker</a> bmh file does not compile, or does not produce expected output.</td>
71  </tr>  <tr>
72    <td>Undocumented but referenced interface is missing from undocumented <a href='usingBookmaker#Bookmaker'>bookmaker</a> file in docs directory.</td>
73  </tr>
74</table>
75
76Editing comments in includes or editing private interfaces will not break the bots.
77<a href='usingBookmaker#Bookmaker'>Bookmaker</a> detects that comments edited in includes do not match comments in docs; it will generate an updated include in the
78directory where it is run.
79
80If
81<a href='https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker'>Housekeeper-PerCommit-Bookmaker</a></a> bot is red, the error is usually related to an edit to an include which has not been reflected in docs.
82
83To fix this, edit the docs file corresponding to the changed include file.
84
85For instance, if the change was made to <a href='SkIRect_Reference#SkIRect'>SkIRect</a>, edit docs/SkIRect_Reference.bmh.
86Checking in the edited docs/SkIRect_Reference.bmh will fix the bot.
87
88If the interface is deprecated, private, or experimental, documentation is not
89required. Put the word "Deprecated", "Private", or "Experimental"; upper or lower
90case, in a comment just before the symbol to be ignored.
91
92If
93<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:
94
95<table>  <tr>
96    <td>A change to include broke documentation examples.</td>
97  </tr>  <tr>
98    <td>Something changed the examples that output <a href='undocumented#Text'>text</a>.</td>
99  </tr>  <tr>
100    <td>Some interface was added, deleted, edited.</td>
101  </tr>  <tr>
102    <td>Documentation is malformed.</td>
103  </tr>
104</table>
105
106The bot output describes what changed, and includes the file and <a href='undocumented#Line'>line</a>
107where the error occurred.
108
109To regenerate the documentation, follow the Installing and Regenerate steps below.
110
111<a name='Editing_Comments'></a>
112
113Edit docs instead of include/core files to update comments if possible.
114
115The <a href='usingBookmaker#Bookmaker'>Bookmaker</a> bots do not complain if the docs file does not match the
116corresponding include comments. Running <a href='usingBookmaker#Bookmaker'>Bookmaker</a> include generation will
117report when docs and includes comments do not match.
118
119For instance, if include/core/SkSurface.h comments do not match
120docs/SkSurface_Reference.bmh, running:
121
122<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
123$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
124</pre>
125
126generates
127
128<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
129wrote updated <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.h
130</pre>
131
132The updated <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.h is written to the root to avoid subsequent runs of
133<a href='usingBookmaker#Bookmaker'>Bookmaker</a> from recompiling. if <a href='SkSurface_Reference#SkSurface'>SkSurface</a>.h was not changed, it is not written,
134and <a href='usingBookmaker#Bookmaker'>Bookmaker</a> will not generate any output.
135
136<a name='Broken_Example'></a>
137
138An example may cause <a href='usingBookmaker#Bookmaker'>Bookmaker</a> or a bot running <a href='usingBookmaker#Bookmaker'>Bookmaker</a> to fail if it fails to compile.
139
140Fix the example by pasting it into <a href='https://fiddle.skia.org'>Skia Fiddle</a></a> and editing it until it runs successfully.
141
142If the example cannot be fixed, it can be commented out by changing
143
144<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
145#Example
146</pre>
147
148to
149
150<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
151#NoExample
152</pre>
153
154. The disabled example can contain additional markup, which will be ignored.
155
156<a name='Regenerate'></a>
157
158Complete rebuilding of all <a href='usingBookmaker#Bookmaker'>bookmaker</a> output looks like:
159
160<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
161$ ./out/dir/bookmaker -a docs/status.json -e fiddle.json
162$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
163$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
164$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api
165$ ./out/dir/bookmaker -a docs/status.json -x
166$ ./out/dir/bookmaker -a docs/status.json -p
167</pre>
168
169<a name='New_Documentation'></a>
170
171Generate an starter <a href='usingBookmaker#Bookmaker'>Bookmaker</a> file from an existing include.
172
173<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
174$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
175</pre>
176
177If a method or function has an unnamed parameter, <a href='usingBookmaker#Bookmaker'>bookmaker</a> generates an error:
178
179<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
180C:/puregit/include/core/SkPixmap.h(208): error: #Method missing param name
181bool erase(const <a href='SkColor4f_Reference#SkColor4f'>SkColor4f</a>&, const <a href='SkIRect_Reference#SkIRect'>SkIRect</a>* subset = nullptr) const
182           ^
183</pre>
184
185All parameters require names to allow markdown and doxygen documents to refer to
186them. After naming all parameters, check in the include before continuing.
187
188A successful run generates
189
190<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
191docs/SkXXX_Reference.bmh
192</pre>
193
194.
195
196Next, use your favorite editor to fill out
197
198<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
199docs/SkXXX_Reference.bmh
200</pre>
201
202.
203
204<a name='Style'></a>
205
206Documentation consists of cross references, descriptions, and examples.
207All structs, classes, enums, their members and methods, functions, and so on,
208require descriptions. Most also require examples.
209
210All methods and functions should include examples if practical.
211It's difficult to think of a meaningful example for class destructors.
212In cases like these, change the placeholder:
213
214<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
215#Example
216</pre>
217
218to:
219
220<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
221#NoExample
222</pre>
223
224Descriptions start with an active verb. Descriptions are complete, punctuated
225sentences unless they describe parameters or return values. Parameters and
226returned values are described by phrases that start lower case and do not
227include trailing punctuation.
228
229Descriptions are not self-referential; they do not include the thing they
230describe. Descriptions may contain upper case or camel case references to
231definitions but otherwise should be free of jargon.
232
233Descriptions may contain code and formulas, each bracketed by markup.
234
235Similar items may be grouped into topics. Topics may include subtopics.
236
237Each <a href='undocumented#Document'>document</a> begins with one or more indices that include the contents of
238that file. A class reference includes an index listing contained topics,
239a separate listing for constructors, one for methods, and so on.
240
241Class methods contain a description, any parameters, any return value,
242an example, and any cross references.
243
244Each method must contain either one or more examples or markup indicating
245that there is no example.
246
247After editing is complete, searching for "incomplete" should fail,
248assuming "incomplete" is not the perfect word to use in a description or
249example!
250
251<a name='Adding_Documentation'></a>
252
253Generate fiddle.json from all examples, including the ones you just wrote.
254Error checking is syntatic: starting keywords are closed, keywords have the
255correct parents.
256If you run <a href='usingBookmaker#Bookmaker'>Bookmaker</a> inside Visual_Studio, you can click on errors and it
257will take you to the source <a href='undocumented#Line'>line</a> in question.
258
259<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
260$ ./out/dir/bookmaker -e fiddle.json -b docs
261</pre>
262
263Once complete, run fiddlecli to generate the example hashes.
264Errors are contained by the output but aren't reported yet.
265
266<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
267$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
268</pre>
269
270Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
271Error checking includes: undefined references, fiddle compiler errors,
272missing or mismatched printf output.
273Again, you can click on any errors inside Visual_Studio.
274
275<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
276$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
277</pre>
278
279The original include may have changed since you started creating the markdown.
280Check to see if it is up to date.
281This reports if a method no longer exists or its parameters have changed.
282
283<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
284$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
285</pre>
286
287Generate an updated include header. Run:
288
289<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
290$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
291</pre>
292
293to write the updated SkXXX.h to the current directory.
294
295Once adding the file is complete, add the file to status.json in the
296Completed section. You may add it to the InProgress section during
297development, or leave status.json unchanged.
298
299If the new file has been added to status.json, you can run
300any of the above commands with -a docs/status.json in place of
301-b docs or -i includes.
302
303<a name='Bugs'></a>
304
305<a href='usingBookmaker#Bookmaker'>Bookmaker</a> bugs are tracked
306<a href='https://bug.skia.org/6898'>here</a></a> .
307
308