blob: a3413b20d47a7fdd6352ee1006efdf48a0072989 [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 Clarkabaffd82018-11-15 08:25:12 -0500110If the interface is deprecated, private, or experimental, documentation is not
111required. Put the word "Deprecated", "Private", or "Experimental"; upper or lower
112case, in a comment just before the symbol to be ignored.
Cary Clarkac47b882018-01-11 10:35:44 -0500113
Cary Clarke8161dd2018-09-06 12:47:04 -0400114If
Cary Clarkf5404bb2018-01-05 12:10:09 -0500115#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
116 bot is red, one of several things may have gone wrong:
117
118#List
119# A change to include broke documentation examples. ##
120# Something changed the examples that output text. ##
121# Some interface was added, deleted, edited. ##
122# Documentation is malformed. ##
123##
124
125The bot output describes what changed, and includes the file and line
126where the error occurred.
Cary Clark7cfcbca2018-01-04 16:11:51 -0500127
128To regenerate the documentation, follow the Installing and Regenerate steps below.
129
130#Subtopic Broken_Build ##
131
132#Subtopic Editing_Comments
133
134Edit docs instead of include/core files to update comments if possible.
135
136The Bookmaker bots do not complain if the docs file does not match the
137corresponding include comments. Running Bookmaker include generation will
138report when docs and includes comments do not match.
139
140For instance, if include/core/SkSurface.h comments do not match
141docs/SkSurface_Reference.bmh, running:
142
143#Code
144$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
145##
146
147generates
148
149#Code
150wrote updated SkSurface.h
151##
152
153The updated SkSurface.h is written to the root to avoid subsequent runs of
154Bookmaker from recompiling. if SkSurface.h was not changed, it is not written,
155and Bookmaker will not generate any output.
156
157#Subtopic Editing_Comments ##
158
Cary Clarkac47b882018-01-11 10:35:44 -0500159#Subtopic Broken_Example
160
Cary Clarke8161dd2018-09-06 12:47:04 -0400161An example may cause Bookmaker or a bot running Bookmaker to fail if it fails to compile.
162
163Fix the example by pasting it into #A Skia Fiddle # https://fiddle.skia.org ##
164and editing it until it runs successfully.
165
166If the example cannot be fixed, it can be commented out by changing
Cary Clarkac47b882018-01-11 10:35:44 -0500167###$
168$Code
169$Literal
170#Example
171$Code $$
172to
173$Code
174#NoExample
175$Code $$
176$$$#
Cary Clarke8161dd2018-09-06 12:47:04 -0400177. The disabled example can contain additional markup, which will be ignored.
Cary Clarkac47b882018-01-11 10:35:44 -0500178
179#Subtopic Broken_Example ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400180
Cary Clark7cfcbca2018-01-04 16:11:51 -0500181#Subtopic Regenerate
182
183Complete rebuilding of all bookmaker output looks like:
184
185#Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400186$ ./out/dir/bookmaker -a docs/status.json -e fiddle.json
Cary Clarkab2621d2018-01-30 10:08:57 -0500187$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
Cary Clarke8161dd2018-09-06 12:47:04 -0400188$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
189$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api
190$ ./out/dir/bookmaker -a docs/status.json -x
191$ ./out/dir/bookmaker -a docs/status.json -p
Cary Clark7cfcbca2018-01-04 16:11:51 -0500192##
193
194#Subtopic Regenerate ##
195
196#Subtopic New_Documentation
197
Ben Wagner29380bd2017-10-09 14:43:00 -0400198Generate an starter Bookmaker file from an existing include.
199
200#Code
201$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
202##
203
204If a method or function has an unnamed parameter, bookmaker generates an error:
205
206#Code
207###$
208C:/puregit/include/core/SkPixmap.h(208): error: #Method missing param name
209bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const
210 ^
211$$$#
212##
213
214All parameters require names to allow markdown and doxygen documents to refer to
215them. After naming all parameters, check in the include before continuing.
216
217A successful run generates
218#Code
219docs/SkXXX_Reference.bmh
220##
221.
222
223Next, use your favorite editor to fill out
224#Code
225docs/SkXXX_Reference.bmh
226##
227.
228
Cary Clark7cfcbca2018-01-04 16:11:51 -0500229##
230
Ben Wagner29380bd2017-10-09 14:43:00 -0400231#Subtopic Style
232
233Documentation consists of cross references, descriptions, and examples.
234All structs, classes, enums, their members and methods, functions, and so on,
235require descriptions. Most also require examples.
236
237All methods and functions should include examples if practical.
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500238It's difficult to think of a meaningful example for class destructors.
239In cases like these, change the placeholder:
240
241###$
242$Code
243#Example
244$$
245
246to:
247
248$Code
249#NoExample
250$$
251$$$#
Ben Wagner29380bd2017-10-09 14:43:00 -0400252
253Descriptions start with an active verb. Descriptions are complete, punctuated
254sentences unless they describe parameters or return values. Parameters and
255returned values are described by phrases that start lower case and do not
256include trailing punctuation.
257
258Descriptions are not self-referential; they do not include the thing they
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500259describe. Descriptions may contain upper case or camel case references to
260definitions but otherwise should be free of jargon.
Ben Wagner29380bd2017-10-09 14:43:00 -0400261
262Descriptions may contain code and formulas, each bracketed by markup.
263
264Similar items may be grouped into topics. Topics may include subtopics.
265
266Each document begins with one or more indices that include the contents of
Cary Clark7cfcbca2018-01-04 16:11:51 -0500267that file. A class reference includes an index listing contained topics,
Ben Wagner29380bd2017-10-09 14:43:00 -0400268a separate listing for constructors, one for methods, and so on.
269
270Class methods contain a description, any parameters, any return value,
271an example, and any cross references.
272
273Each method must contain either one or more examples or markup indicating
274that there is no example.
275
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500276After editing is complete, searching for "incomplete" should fail,
277assuming "incomplete" is not the perfect word to use in a description or
278example!
279
Cary Clark7cfcbca2018-01-04 16:11:51 -0500280#Subtopic Style ##
281
282#Subtopic Adding_Documentation
Ben Wagner29380bd2017-10-09 14:43:00 -0400283
284Generate fiddle.json from all examples, including the ones you just wrote.
285Error checking is syntatic: starting keywords are closed, keywords have the
286correct parents.
287If you run Bookmaker inside Visual_Studio, you can click on errors and it
288will take you to the source line in question.
289
290#Code
291$ ./out/dir/bookmaker -e fiddle.json -b docs
292##
293
294Once complete, run fiddlecli to generate the example hashes.
295Errors are contained by the output but aren't reported yet.
296
297#Code
298$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
299##
300
Cary Clark7cfcbca2018-01-04 16:11:51 -0500301Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
Ben Wagner29380bd2017-10-09 14:43:00 -0400302Error checking includes: undefined references, fiddle compiler errors,
303missing or mismatched printf output.
304Again, you can click on any errors inside Visual_Studio.
305
306#Code
307$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
308##
309
310The original include may have changed since you started creating the markdown.
311Check to see if it is up to date.
312This reports if a method no longer exists or its parameters have changed.
313
314#Code
315$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
316##
317
318Generate an updated include header. Run:
319
320#Code
321$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
322##
323
324to write the updated SkXXX.h to the current directory.
325
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500326Once adding the file is complete, add the file to status.json in the
327Completed section. You may add it to the InProgress section during
328development, or leave status.json unchanged.
329
330If the new file has been added to status.json, you can run
331any of the above commands with -a docs/status.json in place of
332-b docs or -i includes.
333
Cary Clark7cfcbca2018-01-04 16:11:51 -0500334#Subtopic Adding_Documentation ##
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500335
Ben Wagner29380bd2017-10-09 14:43:00 -0400336#Subtopic Bugs
337
338Bookmaker bugs are tracked
Cary Clark682c58d2018-05-16 07:07:07 -0400339#A here # https://bug.skia.org/6898 ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400340.
341
342##
343
344#Topic Bookmaker ##