blob: 02256a216a61f330353ad66f71782f28e51e4167 [file] [log] [blame]
Ben Wagner29380bd2017-10-09 14:43:00 -04001#External
Cary Clark77b3f3a2018-11-07 14:59:03 -05002SkXXX.md
3SkXXX.bmh
4docs/SkIRect_Reference.bmh
5docs/SkSurface_Reference.bmh
6docs/status.json
7include/core/SkSurface.h
Cary Clark7cfcbca2018-01-04 16:11:51 -05008SkSurface.h
Cary Clark77b3f3a2018-11-07 14:59:03 -05009fiddle.json
10fiddleout.json
11status.json
Ben Wagner29380bd2017-10-09 14:43:00 -040012CL
13Go
14Visual_Studio
Cary Clarkc7924c92017-12-14 08:28:46 -050015Completed InProgress
Cary Clark77b3f3a2018-11-07 14:59:03 -050016skia.org
Ben Wagner29380bd2017-10-09 14:43:00 -040017##
18
19#Topic Bookmaker
20
Cary Clarke8161dd2018-09-06 12:47:04 -040021Bookmaker generates markdown files to view documentation on skia.org, and generates includes for use in C++.
22Bookmaker reads canonical documentation from files suffixed with bmh in the docs directory. These bmh
23files describe how public interfaces work, and generate Skia fiddle examples to illustrate them.
24
25The docs files must be manually edited to stay current with Skia as it evolves.
Cary Clarkac47b882018-01-11 10:35:44 -050026
Cary Clark983f8de2018-11-01 10:53:54 -040027#Subtopic Installing
28
29Install
30#A Go # https://golang.org/doc/install ##
31 if needed.
32Check the version. The results should be 1.10 or greater.
33
34#Code
35$ go version
36##
37
38Get the fiddle command line interface tool.
39By default this will appear in your home directory.
40
41#Code
42$ go get go.skia.org/infra/fiddlek/go/fiddlecli
43##
44
45Check the version. The command should work and the result should be 1.0 or greater.
46
47#Code
48$ ~/go/bin/fiddlecli --version
49##
50
51If fiddlecli is already installed but out of date, update with:
52
53#Code
54$ go get -u go.skia.org/infra/fiddlek/go/fiddlecli
55##
56
57Build Bookmaker.
58
59#Code
60$ ninja -C out/skia bookmaker
61##
62
63#Subtopic Installing ##
64
65#Subtopic Running
66
67Bookmaker extracts examples, generates example hashes with fiddle, and generates web markdown
68and c++ includes.
69
70#Code
71$ ./out/skia/bookmaker -E && ~/go/bin/fiddlecli --quiet && ./out/skia/bookmaker
72##
73
74A successful run generates:
75
76#Code
77cross-check...................
78##
79
80#Subtopic Running ##
81
Cary Clark7cfcbca2018-01-04 16:11:51 -050082#Subtopic Broken_Build
83
Cary Clarke8161dd2018-09-06 12:47:04 -040084The bots
Cary Clark7cfcbca2018-01-04 16:11:51 -050085#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
Cary Clarke8161dd2018-09-06 12:47:04 -040086and
87#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
88verify that Bookmaker data in docs builds without error and is consistent with include files it documents.
Cary Clark7cfcbca2018-01-04 16:11:51 -050089
Cary Clarke8161dd2018-09-06 12:47:04 -040090Possible failures include:
91#List
92# Public interface in include directory does not match documented interface in docs directory. ##
93# Example in bookmaker bmh file does not compile, or does not produce expected output. ##
94# Undocumented but referenced interface is missing from undocumented bookmaker file in docs directory. ##
95##
96
97Editing comments in includes or editing private interfaces will not break the bots.
98Bookmaker detects that comments edited in includes do not match comments in docs; it will generate an updated include in the
99directory where it is run.
100
101If
102#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
103bot is red, the error is usually related to an edit to an include which has not been reflected in docs.
Cary Clark7cfcbca2018-01-04 16:11:51 -0500104
105To fix this, edit the docs file corresponding to the changed include file.
106
107For instance, if the change was made to SkIRect, edit docs/SkIRect_Reference.bmh.
108Checking in the edited docs/SkIRect_Reference.bmh will fix the bot.
109
Cary Clarkac47b882018-01-11 10:35:44 -0500110If the interface is deprecated, but still present in the interface, mark-up the
111documentation to be deprecated as well.
112
113#Code
114###$
115#Method void someMethodThatIsNowDeprecated()
Cary Clarkac47b882018-01-11 10:35:44 -0500116#Deprecated
117##
Cary Clark4855f782018-02-06 09:41:53 -0500118$$
Cary Clarkac47b882018-01-11 10:35:44 -0500119
Cary Clark4855f782018-02-06 09:41:53 -0500120Use
121
122$Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400123#Deprecated soon
Cary Clark4855f782018-02-06 09:41:53 -0500124$$
125
126if the change is soon to be deprecated.
127
Cary Clarkac47b882018-01-11 10:35:44 -0500128$$$#
Cary Clarkac47b882018-01-11 10:35:44 -0500129
Cary Clarke8161dd2018-09-06 12:47:04 -0400130If
Cary Clarkf5404bb2018-01-05 12:10:09 -0500131#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
132 bot is red, one of several things may have gone wrong:
133
134#List
135# A change to include broke documentation examples. ##
136# Something changed the examples that output text. ##
137# Some interface was added, deleted, edited. ##
138# Documentation is malformed. ##
139##
140
141The bot output describes what changed, and includes the file and line
142where the error occurred.
Cary Clark7cfcbca2018-01-04 16:11:51 -0500143
144To regenerate the documentation, follow the Installing and Regenerate steps below.
145
146#Subtopic Broken_Build ##
147
148#Subtopic Editing_Comments
149
150Edit docs instead of include/core files to update comments if possible.
151
152The Bookmaker bots do not complain if the docs file does not match the
153corresponding include comments. Running Bookmaker include generation will
154report when docs and includes comments do not match.
155
156For instance, if include/core/SkSurface.h comments do not match
157docs/SkSurface_Reference.bmh, running:
158
159#Code
160$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
161##
162
163generates
164
165#Code
166wrote updated SkSurface.h
167##
168
169The updated SkSurface.h is written to the root to avoid subsequent runs of
170Bookmaker from recompiling. if SkSurface.h was not changed, it is not written,
171and Bookmaker will not generate any output.
172
173#Subtopic Editing_Comments ##
174
Cary Clarkac47b882018-01-11 10:35:44 -0500175#Subtopic Broken_Example
176
Cary Clarke8161dd2018-09-06 12:47:04 -0400177An example may cause Bookmaker or a bot running Bookmaker to fail if it fails to compile.
178
179Fix the example by pasting it into #A Skia Fiddle # https://fiddle.skia.org ##
180and editing it until it runs successfully.
181
182If the example cannot be fixed, it can be commented out by changing
Cary Clarkac47b882018-01-11 10:35:44 -0500183###$
184$Code
185$Literal
186#Example
187$Code $$
188to
189$Code
190#NoExample
191$Code $$
192$$$#
Cary Clarke8161dd2018-09-06 12:47:04 -0400193. The disabled example can contain additional markup, which will be ignored.
Cary Clarkac47b882018-01-11 10:35:44 -0500194
195#Subtopic Broken_Example ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400196
Cary Clark7cfcbca2018-01-04 16:11:51 -0500197#Subtopic Regenerate
198
199Complete rebuilding of all bookmaker output looks like:
200
201#Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400202$ ./out/dir/bookmaker -a docs/status.json -e fiddle.json
Cary Clarkab2621d2018-01-30 10:08:57 -0500203$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
Cary Clarke8161dd2018-09-06 12:47:04 -0400204$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
205$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api
206$ ./out/dir/bookmaker -a docs/status.json -x
207$ ./out/dir/bookmaker -a docs/status.json -p
Cary Clark7cfcbca2018-01-04 16:11:51 -0500208##
209
210#Subtopic Regenerate ##
211
212#Subtopic New_Documentation
213
Ben Wagner29380bd2017-10-09 14:43:00 -0400214Generate an starter Bookmaker file from an existing include.
215
216#Code
217$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
218##
219
220If a method or function has an unnamed parameter, bookmaker generates an error:
221
222#Code
223###$
224C:/puregit/include/core/SkPixmap.h(208): error: #Method missing param name
225bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const
226 ^
227$$$#
228##
229
230All parameters require names to allow markdown and doxygen documents to refer to
231them. After naming all parameters, check in the include before continuing.
232
233A successful run generates
234#Code
235docs/SkXXX_Reference.bmh
236##
237.
238
239Next, use your favorite editor to fill out
240#Code
241docs/SkXXX_Reference.bmh
242##
243.
244
Cary Clark7cfcbca2018-01-04 16:11:51 -0500245##
246
Ben Wagner29380bd2017-10-09 14:43:00 -0400247#Subtopic Style
248
249Documentation consists of cross references, descriptions, and examples.
250All structs, classes, enums, their members and methods, functions, and so on,
251require descriptions. Most also require examples.
252
253All methods and functions should include examples if practical.
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500254It's difficult to think of a meaningful example for class destructors.
255In cases like these, change the placeholder:
256
257###$
258$Code
259#Example
260$$
261
262to:
263
264$Code
265#NoExample
266$$
267$$$#
Ben Wagner29380bd2017-10-09 14:43:00 -0400268
269Descriptions start with an active verb. Descriptions are complete, punctuated
270sentences unless they describe parameters or return values. Parameters and
271returned values are described by phrases that start lower case and do not
272include trailing punctuation.
273
274Descriptions are not self-referential; they do not include the thing they
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500275describe. Descriptions may contain upper case or camel case references to
276definitions but otherwise should be free of jargon.
Ben Wagner29380bd2017-10-09 14:43:00 -0400277
278Descriptions may contain code and formulas, each bracketed by markup.
279
280Similar items may be grouped into topics. Topics may include subtopics.
281
282Each document begins with one or more indices that include the contents of
Cary Clark7cfcbca2018-01-04 16:11:51 -0500283that file. A class reference includes an index listing contained topics,
Ben Wagner29380bd2017-10-09 14:43:00 -0400284a separate listing for constructors, one for methods, and so on.
285
286Class methods contain a description, any parameters, any return value,
287an example, and any cross references.
288
289Each method must contain either one or more examples or markup indicating
290that there is no example.
291
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500292After editing is complete, searching for "incomplete" should fail,
293assuming "incomplete" is not the perfect word to use in a description or
294example!
295
Cary Clark7cfcbca2018-01-04 16:11:51 -0500296#Subtopic Style ##
297
298#Subtopic Adding_Documentation
Ben Wagner29380bd2017-10-09 14:43:00 -0400299
300Generate fiddle.json from all examples, including the ones you just wrote.
301Error checking is syntatic: starting keywords are closed, keywords have the
302correct parents.
303If you run Bookmaker inside Visual_Studio, you can click on errors and it
304will take you to the source line in question.
305
306#Code
307$ ./out/dir/bookmaker -e fiddle.json -b docs
308##
309
310Once complete, run fiddlecli to generate the example hashes.
311Errors are contained by the output but aren't reported yet.
312
313#Code
314$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
315##
316
Cary Clark7cfcbca2018-01-04 16:11:51 -0500317Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
Ben Wagner29380bd2017-10-09 14:43:00 -0400318Error checking includes: undefined references, fiddle compiler errors,
319missing or mismatched printf output.
320Again, you can click on any errors inside Visual_Studio.
321
322#Code
323$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
324##
325
326The original include may have changed since you started creating the markdown.
327Check to see if it is up to date.
328This reports if a method no longer exists or its parameters have changed.
329
330#Code
331$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
332##
333
334Generate an updated include header. Run:
335
336#Code
337$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
338##
339
340to write the updated SkXXX.h to the current directory.
341
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500342Once adding the file is complete, add the file to status.json in the
343Completed section. You may add it to the InProgress section during
344development, or leave status.json unchanged.
345
346If the new file has been added to status.json, you can run
347any of the above commands with -a docs/status.json in place of
348-b docs or -i includes.
349
Cary Clark7cfcbca2018-01-04 16:11:51 -0500350#Subtopic Adding_Documentation ##
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500351
Ben Wagner29380bd2017-10-09 14:43:00 -0400352#Subtopic Bugs
353
354Bookmaker bugs are tracked
Cary Clark682c58d2018-05-16 07:07:07 -0400355#A here # https://bug.skia.org/6898 ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400356.
357
358##
359
360#Topic Bookmaker ##