1 | [[tags: egg]] |
---|
2 | == chicken-doc-admin |
---|
3 | |
---|
4 | chicken-doc-admin is a tool for generating and maintaining |
---|
5 | Chicken documentation for the [[chicken-doc]] egg. |
---|
6 | [[toc:]] |
---|
7 | === Overview |
---|
8 | |
---|
9 | [[chicken-doc-admin]] provides facilities to create and modify a Chicken |
---|
10 | documentation repository for [[chicken-doc]]. It includes a command-line |
---|
11 | tool to convert egg documentation and manual pages from the Chicken |
---|
12 | wiki for use with [[chicken-doc]]. It also provides an API for |
---|
13 | repository manipulation. |
---|
14 | |
---|
15 | The typical mode of using [[chicken-doc-admin]] is to check out a copy of |
---|
16 | the wiki using Subversion, then run the [[chicken-doc-admin]] command |
---|
17 | against the copy's egg and man directories. Optionally, process |
---|
18 | eggdocs by running [[chicken-doc-admin]] against an egg repository checkout. |
---|
19 | Repeat when either is updated; only changed files will be reexamined. |
---|
20 | |
---|
21 | Eggs can also include bundled documentation rather than sourcing it |
---|
22 | from the wiki; [[chicken-doc-admin]] can parse these automatically |
---|
23 | as well. Typically, though, official eggs use the wiki. |
---|
24 | |
---|
25 | === Quick start |
---|
26 | |
---|
27 | The default repository location is in the Chicken install tree and may |
---|
28 | not be writable by your user. If so, either use {{sudo}} or set an |
---|
29 | alternate writable location with: |
---|
30 | |
---|
31 | $ export CHICKEN_DOC_REPOSITORY=/path/to/some/writable/directory |
---|
32 | |
---|
33 | Initialize the repository if this is your first time: |
---|
34 | |
---|
35 | $ chicken-doc-admin -i |
---|
36 | |
---|
37 | Check out the wiki documentation: |
---|
38 | |
---|
39 | $ svn co --username anonymous --password "" \ |
---|
40 | https://code.call-cc.org/svn/chicken-eggs/wiki |
---|
41 | |
---|
42 | To import Chicken 5 documentation: |
---|
43 | |
---|
44 | $ chicken-doc-admin -m wiki/man/5 |
---|
45 | $ chicken-doc-admin -e wiki/eggref/5 |
---|
46 | |
---|
47 | To import Chicken 4 documentation, use 4 instead of 5: |
---|
48 | |
---|
49 | $ chicken-doc-admin -m wiki/man/4 |
---|
50 | $ chicken-doc-admin -e wiki/eggref/4 |
---|
51 | |
---|
52 | {{chicken-doc-admin}} is aware of the structure of both Chicken 4 and Chicken 5 |
---|
53 | manual pages and will automatically import them appropriately. Both Chicken 4 |
---|
54 | and 5 can serve either documentation version. |
---|
55 | |
---|
56 | |
---|
57 | ==== Locally installed egg documentation |
---|
58 | |
---|
59 | Certain eggs may install wiki documentation during a |
---|
60 | {{chicken-install}}. Although uncommon, this allows unofficial, |
---|
61 | private or experimental eggs to include documentation without making |
---|
62 | it public on the wiki. To do this with your own eggs, see [[#Local egg documentation for developers]]. |
---|
63 | |
---|
64 | Process all locally installed documentation: |
---|
65 | |
---|
66 | $ chicken-doc-admin -H |
---|
67 | |
---|
68 | Process docs just for the {{inane}} and {{pathfinder}} eggs: |
---|
69 | |
---|
70 | $ chicken-doc-admin -H inane pathfinder |
---|
71 | |
---|
72 | Working example: |
---|
73 | |
---|
74 | hg clone https://bitbucket.org/ursetto/inane |
---|
75 | cd inane |
---|
76 | chicken-install |
---|
77 | cd .. |
---|
78 | chicken-doc-admin -H inane |
---|
79 | |
---|
80 | The {{cd ..}} is only for illustrative purposes here to show you can |
---|
81 | process installed docs from any directory. (Since you checked out |
---|
82 | from source, you could instead have done {{chicken-doc-admin -E inane}} |
---|
83 | from the source directory to process {{./inane.wiki}}.) |
---|
84 | |
---|
85 | '''Note:''' If egg documentation is both on the wiki ''and'' locally |
---|
86 | installed, and you process both, then the latest file timestamp wins. |
---|
87 | Unfortunately, these timestamps reflect not the actual update time |
---|
88 | but rather the install time on your local system, and are of |
---|
89 | dubious value in this case. |
---|
90 | |
---|
91 | ==== Optional eggdoc processing |
---|
92 | |
---|
93 | ''Almost all users can skip this step'', because there are only a few |
---|
94 | remaining eggs that use eggdoc. The Chicken 5 version of this egg drops |
---|
95 | support for eggdoc. |
---|
96 | |
---|
97 | Download the egg repository and process any eggdocs: |
---|
98 | |
---|
99 | * '''Warning''': eggdocs are executable Scheme code, so if you are |
---|
100 | concerned about untrusted code, then skip this step or do not run |
---|
101 | it as root. This risk is reasonably low because anonymous uploads |
---|
102 | are not allowed. |
---|
103 | |
---|
104 | $ svn co --username anonymous --password "" \ |
---|
105 | http://code.call-cc.org/svn/chicken-eggs/release/4 eggs |
---|
106 | $ chicken-doc-admin -t eggdoc -e eggs |
---|
107 | |
---|
108 | === Upgrading |
---|
109 | |
---|
110 | After an upgrade of the egg, if you get a message informing you that |
---|
111 | the repository version is invalid, you will need to delete and |
---|
112 | recreate your repository. For example: |
---|
113 | |
---|
114 | $ chicken-doc-admin -D |
---|
115 | $ chicken-doc-admin -i |
---|
116 | $ chicken-doc-admin -m ... |
---|
117 | $ chicken-doc-admin -e ... |
---|
118 | |
---|
119 | === Command-line |
---|
120 | |
---|
121 | $ chicken-doc-admin COMMAND |
---|
122 | |
---|
123 | -l list repository information |
---|
124 | |
---|
125 | Print some information about the repository, such as its location |
---|
126 | and version. |
---|
127 | |
---|
128 | -i initialize repository non-destructively |
---|
129 | |
---|
130 | Initialize the repository in the current default location or as |
---|
131 | overridden by {{CHICKEN_DOC_REPOSITORY}}. The directory will be |
---|
132 | created if it does not exist. This command must be run before any |
---|
133 | documentation can be processed. You should usually initialize an |
---|
134 | empty directory; initializing a populated directory won't delete |
---|
135 | anything, and may confuse us. |
---|
136 | |
---|
137 | -t type document type |
---|
138 | |
---|
139 | Set the source document type, which may be {{eggdoc}} or {{svnwiki}}, |
---|
140 | defaulting to {{svnwiki}}. This option can be used before -e, -E, -m, -M. |
---|
141 | |
---|
142 | To process type {{eggdoc}}, you must install the {{eggdoc-svnwiki}} extension. |
---|
143 | |
---|
144 | -e dir process egg directory DIR |
---|
145 | |
---|
146 | Process a copy of egg directory DIR, adding each egg documentation page |
---|
147 | to a node at toplevel and the identifiers contained in the |
---|
148 | page to that node's children. Egg names are displayed as |
---|
149 | they are processed. |
---|
150 | |
---|
151 | * For '''svnwiki''' document types, directory is typically {{/path/to/wiki/eggref/4}}. The node name will be that of the file's basename, so file {{eggref/4/9p}} becomes node {{9p}}. |
---|
152 | * For '''eggdoc''' types, directory is typically {{/path/to/checkout/of/egg/repo}}, which is scanned for .meta files containing (eggdoc) attributes. The node name is taken from the eggdoc's (name) attribute. |
---|
153 | |
---|
154 | The timestamp of the source file is stored in each node, and files which |
---|
155 | have not changed since they were last processed are skipped. Use {{-f}} |
---|
156 | to disregard these timestamps and force reprocessing. |
---|
157 | |
---|
158 | -m dir process svnwiki manual directory DIR |
---|
159 | |
---|
160 | Process a copy of svnwiki Chicken manual directory DIR (usually |
---|
161 | {{/path/to/wiki/man/4}}). Adds unit documentation to |
---|
162 | nodes at toplevel (Unit posix -> posix) and Chicken core |
---|
163 | documentation to nodes under toplevel node chicken |
---|
164 | (Parameters -> chicken parameters). |
---|
165 | |
---|
166 | A copy of the manual is usually installed in `(chicken-home)` |
---|
167 | under `doc/manual` -- for example, `/usr/local/share/chicken/doc/manual` -- |
---|
168 | and you can use this copy instead of checking it out from SVN. |
---|
169 | |
---|
170 | {{chicken-doc-admin}} internally maps each manual page to a node path, |
---|
171 | based on its filename. |
---|
172 | |
---|
173 | -E file [path...] process egg file FILE |
---|
174 | |
---|
175 | Process an individual egg file FILE as in -e. The resulting node path |
---|
176 | is usually determined from context, but you may set it manually with PATH. |
---|
177 | |
---|
178 | FILE may reside anywhere on disk, not just in a repository checkout. |
---|
179 | |
---|
180 | -M file [path...] process svnwiki man file FILE |
---|
181 | |
---|
182 | Process an individual svnwiki manual page FILE as in -m. The node |
---|
183 | name is determined by an internal map of filenames to node paths. |
---|
184 | Alternatively, you can set it directly with PATH. |
---|
185 | |
---|
186 | -H process all installed egg documentation |
---|
187 | |
---|
188 | Process locally installed egg documentation. Most eggs will keep their |
---|
189 | documentation on the wiki, but it may also be contained within and |
---|
190 | installed with the egg itself. This is useful for unofficial, private or |
---|
191 | experimental eggs. |
---|
192 | |
---|
193 | -H egg1 egg2... process specified installed egg documentation |
---|
194 | |
---|
195 | Like {{-H}}, but only process the specified eggs. |
---|
196 | |
---|
197 | -T process all installed target egg documentation |
---|
198 | -T egg1 egg2... process specified installed target egg documentation |
---|
199 | |
---|
200 | Like {{-H}}, but when Chicken is built as a cross-compiler, it will process |
---|
201 | eggs installed for the target. When a regular compiler instead, this has the |
---|
202 | same effect as {{-H}}. |
---|
203 | |
---|
204 | -r regenerate indices |
---|
205 | |
---|
206 | Regenerate documentation indices; at the moment, this is just one |
---|
207 | index, the node -> path search map. Indexing is done automatically, |
---|
208 | so there is no need to use this option unless your index is somehow |
---|
209 | broken. |
---|
210 | |
---|
211 | -f force processing (ignore timestamp checks) |
---|
212 | |
---|
213 | The timestamp of the source file is stored in each node, and normally |
---|
214 | files which have not changed since they were last processed are |
---|
215 | skipped. Use {{-f}} to disregard these timestamps and force |
---|
216 | reprocessing. This option can be used before {{-e}}, {{-m}}, {{-E}} and {{-M}}, |
---|
217 | which all consider stored timestamps by default. |
---|
218 | |
---|
219 | -d path delete node path recursively |
---|
220 | |
---|
221 | Delete node path PATH and everything under it. Useful for removing, |
---|
222 | for example, an entire egg from the repository. |
---|
223 | |
---|
224 | '''WARNING''': If you do not provide a path, the root path () is used, |
---|
225 | which will delete the contents of the entire repository and leave |
---|
226 | a clean repository in its place. |
---|
227 | |
---|
228 | -D destroy repository |
---|
229 | |
---|
230 | Recursively deletes the repository base directory. You must use |
---|
231 | {{-i}} to recreate the repository. |
---|
232 | |
---|
233 | === Repository |
---|
234 | |
---|
235 | The repository layout produced by chicken-doc-admin's automatic egg |
---|
236 | and man parser is detailed in the documentation for the |
---|
237 | [[chicken-doc]] egg. |
---|
238 | |
---|
239 | To recap, documentation for each egg and unit is placed in a toplevel |
---|
240 | node named after that egg or unit, with procedure, macro, |
---|
241 | etc. identifiers for that unit as the node's children. Chicken core |
---|
242 | man pages not corresponding to a particular unit are placed |
---|
243 | individually under the "chicken" toplevel node; for example, |
---|
244 | [[Non-standard macros and special forms]] resides under the path |
---|
245 | {{(chicken macros)}}. |
---|
246 | |
---|
247 | As with [[chicken-doc]], you can override the repository location |
---|
248 | by setting an environment variable: |
---|
249 | |
---|
250 | export CHICKEN_DOC_REPOSITORY=/path/to/repository |
---|
251 | |
---|
252 | This is useful for testing and also if the default location, which is |
---|
253 | located in {{(chicken-home)}}, is not writable by you. You can verify |
---|
254 | the current repository location with {{chicken-doc-admin -l}}. |
---|
255 | |
---|
256 | ==== Low-level repository structure |
---|
257 | |
---|
258 | This structure is subject to change. |
---|
259 | |
---|
260 | |-- .chicken-doc-repo Repository magic file; contains repository info |
---|
261 | |-- id.idx Alist mapping node identifiers to paths |
---|
262 | |-- lock Lock file to prevent write conflicts |
---|
263 | |-- root/ Documentation root node () |
---|
264 | |-- 9p/ Documentation node (9p) |
---|
265 | | |- ,meta (9p) metadata alist (signature "9p egg", type 'egg) |
---|
266 | | |- ,sxml (9p) sxml document |
---|
267 | | |- ,defs (9p) definitions (index ...) (def ...) (def ...) |
---|
268 | | |
---|
269 | |-- foreign/ Documentation node (foreign) |
---|
270 | |- ,meta (foreign) metadata alist + sxml document |
---|
271 | |- access/ Documentation node (foreign access) |
---|
272 | |- ,meta (foreign access) metadata |
---|
273 | |- ,sxml (foreign access) sxml document |
---|
274 | |- ,defs (foreign access) definitions, |
---|
275 | e.g. for (foreign access foreign-code) |
---|
276 | |
---|
277 | Certain characters are %-escaped in filenames, such as / and period. |
---|
278 | |
---|
279 | When the {{,sxml}} document is under 3KB, it is packed into the {{,meta}} file. |
---|
280 | |
---|
281 | {{,defs}} nodes are virtual nodes containing definition sexprs extracted |
---|
282 | from the parent sxml document at parse time, plus an index. They cannot |
---|
283 | be created, modified or destroyed except via their containing document, |
---|
284 | but are otherwise accessed as regular nodes. {{,defs}} nodes first appeared |
---|
285 | in version 0.4.0; prior to that, they were "real" nodes and one directory |
---|
286 | was created per definition. |
---|
287 | |
---|
288 | Each node contains a timestamp corresponding to that of the source file. |
---|
289 | |
---|
290 | === Proper wiki documentation |
---|
291 | |
---|
292 | ''This section is a work in progress.'' |
---|
293 | |
---|
294 | ==== The short and skinny |
---|
295 | |
---|
296 | * Use svnwiki type tags (procedure, macro) around all identifiers |
---|
297 | to be documented. See [[wiki-syntax-chicken|Chicken-specific wiki syntax]]. |
---|
298 | * Place related tagged identifiers on consecutive, non-blank lines; |
---|
299 | the text description below is then used for all of them. eggdocs |
---|
300 | must use the proper grouping form, described below. |
---|
301 | * Ensure all identifier signatures can be read with a call to (read). |
---|
302 | Don't use characters such as {{|}} (pipe). |
---|
303 | * Ensure open and close tags for bold, italic, links, code and |
---|
304 | identifiers are located on the same line. |
---|
305 | |
---|
306 | ==== svnwiki identifier type tags |
---|
307 | |
---|
308 | Each identifier is assigned a type (such as 'procedure, 'macro) |
---|
309 | corresponding to svnwiki tags "procedure", "macro" etc. It is also |
---|
310 | assigned a signature which is taken verbatim from the svnwiki tag |
---|
311 | content. Finally, the identifier name also comes from the signature; |
---|
312 | the signature is parsed using {{(read)}}, and the result may be a |
---|
313 | symbol (for example, a constant), or a list --- typically, a procedure |
---|
314 | or macro signature, in which case the first element of the list is |
---|
315 | used. With rare exception, as when the signature contains an |
---|
316 | illegal character such as {{|}} (pipe), this strategy works well. |
---|
317 | |
---|
318 | If a signature cannot be parsed as above, the definition is discarded. |
---|
319 | As a special exception, read syntax signatures are used verbatim, so |
---|
320 | that you can look up read syntax like {{#u8}}. |
---|
321 | |
---|
322 | The currently recognized svnwiki tags are: |
---|
323 | |
---|
324 | (define +identifier-tags+ |
---|
325 | (list "procedure" "macro" "read" "parameter" |
---|
326 | "record" "string" "class" "method" "constant" "setter")) |
---|
327 | |
---|
328 | ==== Identifier descriptions |
---|
329 | |
---|
330 | When creating an identifier description, the svnwiki parser takes all text |
---|
331 | from after the occurrence of the identifier tag up until the next |
---|
332 | section marker, or the next identifier tag. This follows the informal |
---|
333 | standard for Chicken documentation on the wiki, and is a natural |
---|
334 | way to separate descriptions logically. Some points to note: |
---|
335 | |
---|
336 | * The description stops even if the section marker denotes a nested |
---|
337 | section. This works well in general, although there are a few eggs |
---|
338 | which do contain important identifier info in nested sections. |
---|
339 | To get this information, you have to read the full documentation, |
---|
340 | or rearrange the structure. |
---|
341 | * If several identifier signatures occur on consecutive lines, without |
---|
342 | any blank lines between them, they are considered part of a "group" |
---|
343 | of identifiers. The following text description then applies to |
---|
344 | every identifier in the group. Again, this corresponds to common |
---|
345 | practice on the wiki. |
---|
346 | * If you look up one identifier in a group, they will all appear, |
---|
347 | along with the single text description. |
---|
348 | |
---|
349 | ==== Eggdoc notes |
---|
350 | |
---|
351 | Identifier groups in eggdocs use the somewhat verbose form |
---|
352 | |
---|
353 | (definition |
---|
354 | (signatures |
---|
355 | (signature "procedure" "(foo bar)") |
---|
356 | (signature "procedure" "(baz bat)") |
---|
357 | (signature "macro" "(quux phlox)")) |
---|
358 | (p "This describes foo, baz and quux.")) |
---|
359 | |
---|
360 | Separating the definitions like {{(procedure ...) (procedure ...)}} |
---|
361 | instead defines independent, non-grouped procedures. Nesting |
---|
362 | {{(procedure ... (procedure ...))}} is illegal. |
---|
363 | |
---|
364 | === Local egg documentation for developers |
---|
365 | |
---|
366 | To include local egg documentation, create a text file in svnwiki |
---|
367 | format, call it ''{{<eggname>}}''{{.wiki}}, and place it in your |
---|
368 | toplevel source directory. |
---|
369 | |
---|
370 | foo.setup |
---|
371 | foo.meta |
---|
372 | foo.scm |
---|
373 | foo.wiki |
---|
374 | |
---|
375 | Then in your {{.setup}} file, add the {{.wiki}} file to your |
---|
376 | {{install-extension}} clause: |
---|
377 | |
---|
378 | (install-extension |
---|
379 | 'foo |
---|
380 | '("foo.so" "foo.import.so" "foo.wiki") ;; add "foo.wiki" here |
---|
381 | '((version "0.0.0"))) |
---|
382 | |
---|
383 | '''Note:''' Egg documentation that is obtained from the wiki ''and'' |
---|
384 | from installed eggs may cause confusing results for users. The latest |
---|
385 | file timestamp wins out, but the timestamp reflects local install |
---|
386 | time, not remote change time. Therefore, the active doc may depend on |
---|
387 | the user's order of execution of {{svn co}} on the wiki, |
---|
388 | {{chicken-install}} of the egg, {{chicken-doc-admin -e}}, and |
---|
389 | {{chicken-doc-admin -H}}. In this case, the user may want to run |
---|
390 | {{chicken-doc-admin -H eggname}} explicitly instead of processing |
---|
391 | all eggs. |
---|
392 | |
---|
393 | === API |
---|
394 | |
---|
395 | To be documented. |
---|
396 | |
---|
397 | === About this egg |
---|
398 | |
---|
399 | ==== Source |
---|
400 | |
---|
401 | [[https://github.com/ursetto/chicken-doc-admin]] |
---|
402 | |
---|
403 | ==== Author |
---|
404 | |
---|
405 | Jim Ursetto |
---|
406 | |
---|
407 | ==== Version history |
---|
408 | |
---|
409 | ; 0.5.0 : Support running on Chicken 5. Workaround file locking bug in Chicken 5.0.0. Repo version 4 for r/w invariance; see [[chicken-doc]] 0.6.0. Drop eggdoc support for Chicken 5. |
---|
410 | ; 0.4.8 : Support Chicken 5 man page layout |
---|
411 | ; 0.4.7 : Summarize errors, warn (don't crash) if svnwiki parser raises exception. |
---|
412 | ; 0.4.6 : Fix ID cache bug in 0.4.5 with directory recursion |
---|
413 | ; 0.4.5 : Recurse into directories. Nicer output format (A/M/?) and summary. |
---|
414 | ; 0.4.4 : Process locally-installed (host or target) egg documentation |
---|
415 | ; 0.4.2 : Recognize 'Cross development' manpage |
---|
416 | ; 0.4.1 : Ensure old definitions are removed from index when updating a node |
---|
417 | ; 0.4.0 : Repository version 3; dedicated ,defs nodes (saves 80% or more space) |
---|
418 | ; 0.3.12 : Eliminate manual reindexing; pack page ,sxml into ,meta when < 3072 bytes |
---|
419 | ; 0.3.11 : Read syntax signatures are used verbatim (requires Chicken 4.4.2 or later) |
---|
420 | ; 0.3.9 : process only new or modified nodes; display statistics |
---|
421 | ; 0.3.7 : pack definition ,sxml into ,meta when < 3072 bytes; saves 20+MB |
---|
422 | ; 0.3.4 : shared repository cache |
---|
423 | ; 0.3.0 : store pages as SXML; improve parse; repo version 2 |
---|
424 | ; 0.2.2 : Improve manpage handling |
---|
425 | ; 0.2 : Support eggdoc |
---|
426 | ; 0.1.1 : Initial release |
---|
427 | |
---|
428 | ==== License |
---|
429 | |
---|
430 | Copyright (c) 2010-2019 Jim Ursetto. License: 3-clause BSD. |
---|
431 | |
---|
432 | |
---|