blob: 91d79ceb30b60afb6ee4f336c678da726c3d4d14 [file] [log] [blame]
Ben Wagner29380bd2017-10-09 14:43:00 -04001#External
2SkXXX
Cary Clark7cfcbca2018-01-04 16:11:51 -05003SkIRect_Reference
4SkSurface_Reference
5SkSurface.h
Ben Wagner29380bd2017-10-09 14:43:00 -04006CL
7Go
8Visual_Studio
Cary Clarkc7924c92017-12-14 08:28:46 -05009Completed InProgress
Ben Wagner29380bd2017-10-09 14:43:00 -040010##
11
12#Topic Bookmaker
13
Cary Clarke8161dd2018-09-06 12:47:04 -040014Bookmaker generates markdown files to view documentation on skia.org, and generates includes for use in C++.
15Bookmaker reads canonical documentation from files suffixed with bmh in the docs directory. These bmh
16files describe how public interfaces work, and generate Skia fiddle examples to illustrate them.
17
18The docs files must be manually edited to stay current with Skia as it evolves.
Cary Clarkac47b882018-01-11 10:35:44 -050019
Cary Clark7cfcbca2018-01-04 16:11:51 -050020#Subtopic Broken_Build
21
Cary Clarke8161dd2018-09-06 12:47:04 -040022The bots
Cary Clark7cfcbca2018-01-04 16:11:51 -050023#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
Cary Clarke8161dd2018-09-06 12:47:04 -040024and
25#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
26verify that Bookmaker data in docs builds without error and is consistent with include files it documents.
Cary Clark7cfcbca2018-01-04 16:11:51 -050027
Cary Clarke8161dd2018-09-06 12:47:04 -040028Possible failures include:
29#List
30# Public interface in include directory does not match documented interface in docs directory. ##
31# Example in bookmaker bmh file does not compile, or does not produce expected output. ##
32# Undocumented but referenced interface is missing from undocumented bookmaker file in docs directory. ##
33##
34
35Editing comments in includes or editing private interfaces will not break the bots.
36Bookmaker detects that comments edited in includes do not match comments in docs; it will generate an updated include in the
37directory where it is run.
38
39If
40#A Housekeeper-PerCommit-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-PerCommit-Bookmaker ##
41bot 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 -050042
43To fix this, edit the docs file corresponding to the changed include file.
44
45For instance, if the change was made to SkIRect, edit docs/SkIRect_Reference.bmh.
46Checking in the edited docs/SkIRect_Reference.bmh will fix the bot.
47
Cary Clarkac47b882018-01-11 10:35:44 -050048If the interface is deprecated, but still present in the interface, mark-up the
49documentation to be deprecated as well.
50
51#Code
52###$
53#Method void someMethodThatIsNowDeprecated()
Cary Clarkac47b882018-01-11 10:35:44 -050054#Deprecated
55##
Cary Clark4855f782018-02-06 09:41:53 -050056$$
Cary Clarkac47b882018-01-11 10:35:44 -050057
Cary Clark4855f782018-02-06 09:41:53 -050058Use
59
60$Code
Cary Clarke8161dd2018-09-06 12:47:04 -040061#Deprecated soon
Cary Clark4855f782018-02-06 09:41:53 -050062$$
63
64if the change is soon to be deprecated.
65
Cary Clarkac47b882018-01-11 10:35:44 -050066$$$#
Cary Clarkac47b882018-01-11 10:35:44 -050067
Cary Clarke8161dd2018-09-06 12:47:04 -040068If
Cary Clarkf5404bb2018-01-05 12:10:09 -050069#A Housekeeper-Nightly-Bookmaker # https://status.skia.org/repo/skia?filter=search&search_value=Housekeeper-Nightly-Bookmaker ##
70 bot is red, one of several things may have gone wrong:
71
72#List
73# A change to include broke documentation examples. ##
74# Something changed the examples that output text. ##
75# Some interface was added, deleted, edited. ##
76# Documentation is malformed. ##
77##
78
79The bot output describes what changed, and includes the file and line
80where the error occurred.
Cary Clark7cfcbca2018-01-04 16:11:51 -050081
82To regenerate the documentation, follow the Installing and Regenerate steps below.
83
84#Subtopic Broken_Build ##
85
86#Subtopic Editing_Comments
87
88Edit docs instead of include/core files to update comments if possible.
89
90The Bookmaker bots do not complain if the docs file does not match the
91corresponding include comments. Running Bookmaker include generation will
92report when docs and includes comments do not match.
93
94For instance, if include/core/SkSurface.h comments do not match
95docs/SkSurface_Reference.bmh, running:
96
97#Code
98$ ./out/dir/bookmaker -b docs -i include/core/SkSurface.h -p
99##
100
101generates
102
103#Code
104wrote updated SkSurface.h
105##
106
107The updated SkSurface.h is written to the root to avoid subsequent runs of
108Bookmaker from recompiling. if SkSurface.h was not changed, it is not written,
109and Bookmaker will not generate any output.
110
111#Subtopic Editing_Comments ##
112
Cary Clarkac47b882018-01-11 10:35:44 -0500113#Subtopic Broken_Example
114
Cary Clarke8161dd2018-09-06 12:47:04 -0400115An example may cause Bookmaker or a bot running Bookmaker to fail if it fails to compile.
116
117Fix the example by pasting it into #A Skia Fiddle # https://fiddle.skia.org ##
118and editing it until it runs successfully.
119
120If the example cannot be fixed, it can be commented out by changing
Cary Clarkac47b882018-01-11 10:35:44 -0500121###$
122$Code
123$Literal
124#Example
125$Code $$
126to
127$Code
128#NoExample
129$Code $$
130$$$#
Cary Clarke8161dd2018-09-06 12:47:04 -0400131. The disabled example can contain additional markup, which will be ignored.
Cary Clarkac47b882018-01-11 10:35:44 -0500132
133#Subtopic Broken_Example ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400134
Cary Clark7cfcbca2018-01-04 16:11:51 -0500135#Subtopic Installing
136
Ben Wagner29380bd2017-10-09 14:43:00 -0400137Install
138#A Go # https://golang.org/doc/install ##
Cary Clark7cfcbca2018-01-04 16:11:51 -0500139 if needed.
Cary Clarke8161dd2018-09-06 12:47:04 -0400140Check the version. The results should be 1.10 or greater.
Cary Clark80247e52018-07-11 16:18:41 -0400141
142#Code
143$ go version
144##
145
Ben Wagner29380bd2017-10-09 14:43:00 -0400146Get the fiddle command line interface tool.
147By default this will appear in your home directory.
148
149#Code
Ruiqi Mao94d57c42018-07-02 15:20:10 -0400150$ go get go.skia.org/infra/fiddlek/go/fiddlecli
Ben Wagner29380bd2017-10-09 14:43:00 -0400151##
152
153Build Bookmaker.
154
155#Code
156$ ninja -C out/dir bookmaker
157##
158
Cary Clark7cfcbca2018-01-04 16:11:51 -0500159#Subtopic Installing ##
160
161#Subtopic Regenerate
162
163Complete rebuilding of all bookmaker output looks like:
164
165#Code
Cary Clarke8161dd2018-09-06 12:47:04 -0400166$ ./out/dir/bookmaker -a docs/status.json -e fiddle.json
Cary Clarkab2621d2018-01-30 10:08:57 -0500167$ ~/go/bin/fiddlecli --input fiddle.json --output fiddleout.json
Cary Clarke8161dd2018-09-06 12:47:04 -0400168$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api -c
169$ ./out/dir/bookmaker -a docs/status.json -f fiddleout.json -r site/user/api
170$ ./out/dir/bookmaker -a docs/status.json -x
171$ ./out/dir/bookmaker -a docs/status.json -p
Cary Clark7cfcbca2018-01-04 16:11:51 -0500172##
173
174#Subtopic Regenerate ##
175
176#Subtopic New_Documentation
177
Ben Wagner29380bd2017-10-09 14:43:00 -0400178Generate an starter Bookmaker file from an existing include.
179
180#Code
181$ ./out/dir/bookmaker -i include/core/SkXXX.h -t docs
182##
183
184If a method or function has an unnamed parameter, bookmaker generates an error:
185
186#Code
187###$
188C:/puregit/include/core/SkPixmap.h(208): error: #Method missing param name
189bool erase(const SkColor4f&, const SkIRect* subset = nullptr) const
190 ^
191$$$#
192##
193
194All parameters require names to allow markdown and doxygen documents to refer to
195them. After naming all parameters, check in the include before continuing.
196
197A successful run generates
198#Code
199docs/SkXXX_Reference.bmh
200##
201.
202
203Next, use your favorite editor to fill out
204#Code
205docs/SkXXX_Reference.bmh
206##
207.
208
Cary Clark7cfcbca2018-01-04 16:11:51 -0500209##
210
Ben Wagner29380bd2017-10-09 14:43:00 -0400211#Subtopic Style
212
213Documentation consists of cross references, descriptions, and examples.
214All structs, classes, enums, their members and methods, functions, and so on,
215require descriptions. Most also require examples.
216
217All methods and functions should include examples if practical.
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500218It's difficult to think of a meaningful example for class destructors.
219In cases like these, change the placeholder:
220
221###$
222$Code
223#Example
224$$
225
226to:
227
228$Code
229#NoExample
230$$
231$$$#
Ben Wagner29380bd2017-10-09 14:43:00 -0400232
233Descriptions start with an active verb. Descriptions are complete, punctuated
234sentences unless they describe parameters or return values. Parameters and
235returned values are described by phrases that start lower case and do not
236include trailing punctuation.
237
238Descriptions are not self-referential; they do not include the thing they
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500239describe. Descriptions may contain upper case or camel case references to
240definitions but otherwise should be free of jargon.
Ben Wagner29380bd2017-10-09 14:43:00 -0400241
242Descriptions may contain code and formulas, each bracketed by markup.
243
244Similar items may be grouped into topics. Topics may include subtopics.
245
246Each document begins with one or more indices that include the contents of
Cary Clark7cfcbca2018-01-04 16:11:51 -0500247that file. A class reference includes an index listing contained topics,
Ben Wagner29380bd2017-10-09 14:43:00 -0400248a separate listing for constructors, one for methods, and so on.
249
250Class methods contain a description, any parameters, any return value,
251an example, and any cross references.
252
253Each method must contain either one or more examples or markup indicating
254that there is no example.
255
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500256After editing is complete, searching for "incomplete" should fail,
257assuming "incomplete" is not the perfect word to use in a description or
258example!
259
Cary Clark7cfcbca2018-01-04 16:11:51 -0500260#Subtopic Style ##
261
262#Subtopic Adding_Documentation
Ben Wagner29380bd2017-10-09 14:43:00 -0400263
264Generate fiddle.json from all examples, including the ones you just wrote.
265Error checking is syntatic: starting keywords are closed, keywords have the
266correct parents.
267If you run Bookmaker inside Visual_Studio, you can click on errors and it
268will take you to the source line in question.
269
270#Code
271$ ./out/dir/bookmaker -e fiddle.json -b docs
272##
273
274Once complete, run fiddlecli to generate the example hashes.
275Errors are contained by the output but aren't reported yet.
276
277#Code
278$ $GOPATH/bin/fiddlecli --input fiddle.json --output fiddleout.json
279##
280
Cary Clark7cfcbca2018-01-04 16:11:51 -0500281Generate SkXXX.md from SkXXX.bmh and fiddleout.json.
Ben Wagner29380bd2017-10-09 14:43:00 -0400282Error checking includes: undefined references, fiddle compiler errors,
283missing or mismatched printf output.
284Again, you can click on any errors inside Visual_Studio.
285
286#Code
287$ ./out/dir/bookmaker -r site/user/api -b docs -f fiddleout.json
288##
289
290The original include may have changed since you started creating the markdown.
291Check to see if it is up to date.
292This reports if a method no longer exists or its parameters have changed.
293
294#Code
295$ ./out/dir/bookmaker -x -b docs/SkXXX.bmh -i include/core/SkXXX.h
296##
297
298Generate an updated include header. Run:
299
300#Code
301$ ./out/dir/bookmaker -p -b docs -i include/core/SkXXX.h
302##
303
304to write the updated SkXXX.h to the current directory.
305
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500306Once adding the file is complete, add the file to status.json in the
307Completed section. You may add it to the InProgress section during
308development, or leave status.json unchanged.
309
310If the new file has been added to status.json, you can run
311any of the above commands with -a docs/status.json in place of
312-b docs or -i includes.
313
Cary Clark7cfcbca2018-01-04 16:11:51 -0500314#Subtopic Adding_Documentation ##
Cary Clarkca3ebcd2017-12-12 11:22:38 -0500315
Ben Wagner29380bd2017-10-09 14:43:00 -0400316#Subtopic Bugs
317
318Bookmaker bugs are tracked
Cary Clark682c58d2018-05-16 07:07:07 -0400319#A here # https://bug.skia.org/6898 ##
Ben Wagner29380bd2017-10-09 14:43:00 -0400320.
321
322##
323
324#Topic Bookmaker ##