blob: d3a07c3b75b116a6b271a5e380a5cd151b8c8d1d [file] [log] [blame]
Ben Wagner29380bd2017-10-09 14:43:00 -04001#External
2SkXXX
Cary Clark09d80c02018-10-31 12:14:03 -04003docs/SkIRect_Reference
4docs/SkSurface_Reference
5include/core/SkSurface
Cary Clark7cfcbca2018-01-04 16:11:51 -05006SkSurface.h
Ben Wagner29380bd2017-10-09 14:43:00 -04007CL
8Go
9Visual_Studio
Cary Clarkc7924c92017-12-14 08:28:46 -050010Completed InProgress
Ben Wagner29380bd2017-10-09 14:43:00 -040011##
12
13#Topic Bookmaker
14
Cary Clarke8161dd2018-09-06 12:47:04 -040015Bookmaker generates markdown files to view documentation on skia.org, and generates includes for use in C++.
16Bookmaker reads canonical documentation from files suffixed with bmh in the docs directory. These bmh
17files describe how public interfaces work, and generate Skia fiddle examples to illustrate them.
18
19The docs files must be manually edited to stay current with Skia as it evolves.
Cary Clarkac47b882018-01-11 10:35:44 -050020
Cary Clark983f8de2018-11-01 10:53:54 -040021#Subtopic Installing
22
23Install
24#A Go # https://golang.org/doc/install ##
25 if needed.
26Check the version. The results should be 1.10 or greater.
27
28#Code
29$ go version
30##
31
32Get the fiddle command line interface tool.
33By default this will appear in your home directory.
34
35#Code
36$ go get go.skia.org/infra/fiddlek/go/fiddlecli
37##
38
39Check the version. The command should work and the result should be 1.0 or greater.
40
41#Code
42$ ~/go/bin/fiddlecli --version
43##
44
45If fiddlecli is already installed but out of date, update with:
46
47#Code
48$ go get -u go.skia.org/infra/fiddlek/go/fiddlecli
49##
50
51Build Bookmaker.
52
53#Code
54$ ninja -C out/skia bookmaker
55##
56
57#Subtopic Installing ##
58
59#Subtopic Running
60
61Bookmaker extracts examples, generates example hashes with fiddle, and generates web markdown
62and c++ includes.
63
64#Code
65$ ./out/skia/bookmaker -E && ~/go/bin/fiddlecli --quiet && ./out/skia/bookmaker
66##
67
68A successful run generates:
69
70#Code
71cross-check...................
72##
73
74#Subtopic Running ##
75
Cary Clark7cfcbca2018-01-04 16:11:51 -050076#Subtopic Broken_Build
77
Cary Clarke8161dd2018-09-06 12:47:04 -040078The bots
Cary Clark7cfcbca2018-01-04 16:11:51 -050079#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
Cary Clarke8161dd2018-09-06 12:47:04 -040080and
81#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
82verify that Bookmaker data in docs builds without error and is consistent with include files it documents.
Cary Clark7cfcbca2018-01-04 16:11:51 -050083
Cary Clarke8161dd2018-09-06 12:47:04 -040084Possible failures include:
85#List
86# Public interface in include directory does not match documented interface in docs directory. ##
87# Example in bookmaker bmh file does not compile, or does not produce expected output. ##
88# Undocumented but referenced interface is missing from undocumented bookmaker file in docs directory. ##
89##
90
91Editing comments in includes or editing private interfaces will not break the bots.
92Bookmaker detects that comments edited in includes do not match comments in docs; it will generate an updated include in the
93directory where it is run.
94
95If
96#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
97bot 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 -050098
99To fix this, edit the docs file corresponding to the changed include file.
100
101For instance, if the change was made to SkIRect, edit docs/SkIRect_Reference.bmh.
102Checking in the edited docs/SkIRect_Reference.bmh will fix the bot.
103
Cary Clarkac47b882018-01-11 10:35:44 -0500104If the interface is deprecated, but still present in the interface, mark-up the
105documentation to be deprecated as well.
106
107#Code
108###$
109#Method void someMethodThatIsNowDeprecated()
Cary Clarkac47b882018-01-11 10:35:44 -0500110#Deprecated
111##
Cary Clark4855f782018-02-06 09:41:53 -0500112$$
Cary Clarkac47b882018-01-11 10:35:44 -0500113
Cary Clark4855f782018-02-06 09:41:53 -0500114Use
115
116$Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400117#Deprecated soon
Cary Clark4855f782018-02-06 09:41:53 -0500118$$
119
120if the change is soon to be deprecated.
121
Cary Clarkac47b882018-01-11 10:35:44 -0500122$$$#
Cary Clarkac47b882018-01-11 10:35:44 -0500123
Cary Clarke8161dd2018-09-06 12:47:04 -0400124If
Cary Clarkf5404bb2018-01-05 12:10:09 -0500125#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
126 bot is red, one of several things may have gone wrong:
127
128#List
129# A change to include broke documentation examples. ##
130# Something changed the examples that output text. ##
131# Some interface was added, deleted, edited. ##
132# Documentation is malformed. ##
133##
134
135The bot output describes what changed, and includes the file and line
136where the error occurred.
Cary Clark7cfcbca2018-01-04 16:11:51 -0500137
138To regenerate the documentation, follow the Installing and Regenerate steps below.
139
140#Subtopic Broken_Build ##
141
142#Subtopic Editing_Comments
143
144Edit docs instead of include/core files to update comments if possible.
145
146The Bookmaker bots do not complain if the docs file does not match the
147corresponding include comments. Running Bookmaker include generation will
148report when docs and includes comments do not match.
149
150For instance, if include/core/SkSurface.h comments do not match
151docs/SkSurface_Reference.bmh, running:
152
153#Code
154$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
155##
156
157generates
158
159#Code
160wrote updated SkSurface.h
161##
162
163The updated SkSurface.h is written to the root to avoid subsequent runs of
164Bookmaker from recompiling. if SkSurface.h was not changed, it is not written,
165and Bookmaker will not generate any output.
166
167#Subtopic Editing_Comments ##
168
Cary Clarkac47b882018-01-11 10:35:44 -0500169#Subtopic Broken_Example
170
Cary Clarke8161dd2018-09-06 12:47:04 -0400171An example may cause Bookmaker or a bot running Bookmaker to fail if it fails to compile.
172
173Fix the example by pasting it into #A Skia Fiddle # https://fiddle.skia.org ##
174and editing it until it runs successfully.
175
176If the example cannot be fixed, it can be commented out by changing
Cary Clarkac47b882018-01-11 10:35:44 -0500177###$
178$Code
179$Literal
180#Example
181$Code $$
182to
183$Code
184#NoExample
185$Code $$
186$$$#
Cary Clarke8161dd2018-09-06 12:47:04 -0400187. The disabled example can contain additional markup, which will be ignored.
Cary Clarkac47b882018-01-11 10:35:44 -0500188
189#Subtopic Broken_Example ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400190
Cary Clark7cfcbca2018-01-04 16:11:51 -0500191#Subtopic Regenerate
192
193Complete rebuilding of all bookmaker output looks like:
194
195#Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400196$ ./out/dir/bookmaker -a docs/status.json -e fiddle.json
Cary Clarkab2621d2018-01-30 10:08:57 -0500197$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
Cary Clarke8161dd2018-09-06 12:47:04 -0400198$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
199$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api
200$ ./out/dir/bookmaker -a docs/status.json -x
201$ ./out/dir/bookmaker -a docs/status.json -p
Cary Clark7cfcbca2018-01-04 16:11:51 -0500202##
203
204#Subtopic Regenerate ##
205
206#Subtopic New_Documentation
207
Ben Wagner29380bd2017-10-09 14:43:00 -0400208Generate an starter Bookmaker file from an existing include.
209
210#Code
211$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
212##
213
214If a method or function has an unnamed parameter, bookmaker generates an error:
215
216#Code
217###$
218C:/puregit/include/core/SkPixmap.h(208): error: #Method missing param name
219bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const
220 ^
221$$$#
222##
223
224All parameters require names to allow markdown and doxygen documents to refer to
225them. After naming all parameters, check in the include before continuing.
226
227A successful run generates
228#Code
229docs/SkXXX_Reference.bmh
230##
231.
232
233Next, use your favorite editor to fill out
234#Code
235docs/SkXXX_Reference.bmh
236##
237.
238
Cary Clark7cfcbca2018-01-04 16:11:51 -0500239##
240
Ben Wagner29380bd2017-10-09 14:43:00 -0400241#Subtopic Style
242
243Documentation consists of cross references, descriptions, and examples.
244All structs, classes, enums, their members and methods, functions, and so on,
245require descriptions. Most also require examples.
246
247All methods and functions should include examples if practical.
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500248It's difficult to think of a meaningful example for class destructors.
249In cases like these, change the placeholder:
250
251###$
252$Code
253#Example
254$$
255
256to:
257
258$Code
259#NoExample
260$$
261$$$#
Ben Wagner29380bd2017-10-09 14:43:00 -0400262
263Descriptions start with an active verb. Descriptions are complete, punctuated
264sentences unless they describe parameters or return values. Parameters and
265returned values are described by phrases that start lower case and do not
266include trailing punctuation.
267
268Descriptions are not self-referential; they do not include the thing they
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500269describe. Descriptions may contain upper case or camel case references to
270definitions but otherwise should be free of jargon.
Ben Wagner29380bd2017-10-09 14:43:00 -0400271
272Descriptions may contain code and formulas, each bracketed by markup.
273
274Similar items may be grouped into topics. Topics may include subtopics.
275
276Each document begins with one or more indices that include the contents of
Cary Clark7cfcbca2018-01-04 16:11:51 -0500277that file. A class reference includes an index listing contained topics,
Ben Wagner29380bd2017-10-09 14:43:00 -0400278a separate listing for constructors, one for methods, and so on.
279
280Class methods contain a description, any parameters, any return value,
281an example, and any cross references.
282
283Each method must contain either one or more examples or markup indicating
284that there is no example.
285
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500286After editing is complete, searching for "incomplete" should fail,
287assuming "incomplete" is not the perfect word to use in a description or
288example!
289
Cary Clark7cfcbca2018-01-04 16:11:51 -0500290#Subtopic Style ##
291
292#Subtopic Adding_Documentation
Ben Wagner29380bd2017-10-09 14:43:00 -0400293
294Generate fiddle.json from all examples, including the ones you just wrote.
295Error checking is syntatic: starting keywords are closed, keywords have the
296correct parents.
297If you run Bookmaker inside Visual_Studio, you can click on errors and it
298will take you to the source line in question.
299
300#Code
301$ ./out/dir/bookmaker -e fiddle.json -b docs
302##
303
304Once complete, run fiddlecli to generate the example hashes.
305Errors are contained by the output but aren't reported yet.
306
307#Code
308$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
309##
310
Cary Clark7cfcbca2018-01-04 16:11:51 -0500311Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
Ben Wagner29380bd2017-10-09 14:43:00 -0400312Error checking includes: undefined references, fiddle compiler errors,
313missing or mismatched printf output.
314Again, you can click on any errors inside Visual_Studio.
315
316#Code
317$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
318##
319
320The original include may have changed since you started creating the markdown.
321Check to see if it is up to date.
322This reports if a method no longer exists or its parameters have changed.
323
324#Code
325$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
326##
327
328Generate an updated include header. Run:
329
330#Code
331$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
332##
333
334to write the updated SkXXX.h to the current directory.
335
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500336Once adding the file is complete, add the file to status.json in the
337Completed section. You may add it to the InProgress section during
338development, or leave status.json unchanged.
339
340If the new file has been added to status.json, you can run
341any of the above commands with -a docs/status.json in place of
342-b docs or -i includes.
343
Cary Clark7cfcbca2018-01-04 16:11:51 -0500344#Subtopic Adding_Documentation ##
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500345
Ben Wagner29380bd2017-10-09 14:43:00 -0400346#Subtopic Bugs
347
348Bookmaker bugs are tracked
Cary Clark682c58d2018-05-16 07:07:07 -0400349#A here # https://bug.skia.org/6898 ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400350.
351
352##
353
354#Topic Bookmaker ##