Chirag Shah | 18b2555 | 2012-08-09 13:57:54 -0700 | [diff] [blame] | 1 | <?cs |
| 2 | |
| 3 | # walk the children pages and print them nested below the parent |
| 4 | page: the node to insert a label, link and check for children |
| 5 | whitespace: Whitespace to insert before any text in the structure, which helps |
| 6 | with nesting children on recursion. |
| 7 | isRoot: treat this node as if it has children and insert a section node. |
| 8 | |
| 9 | ?><?cs |
| 10 | def:write_child_nodes(page,whitespace,isRoot) ?> |
| 11 | <?cs var:whitespace ?>- title: "<?cs var:page.label ?>" |
| 12 | <?cs var:whitespace ?> path: <?cs var:page.link ?><?cs |
| 13 | if:subcount(page.children) || isRoot ?> |
| 14 | <?cs var:whitespace ?> section: <?cs |
| 15 | /if?><?cs |
| 16 | each:child = page.children?> |
| 17 | <?cs var:whitespace ?> - title: "<?cs var:child.label ?>" |
| 18 | <?cs var:whitespace ?> path: <?cs var:child.link ?><?cs |
| 19 | if:subcount(child.children) ?> |
| 20 | <?cs var:whitespace ?> section:<?cs |
| 21 | call:write_child_nodes(child) ?><?cs |
| 22 | /if ?><?cs |
| 23 | /each ?><?cs |
| 24 | /def ?><?cs |
| 25 | |
| 26 | |
| 27 | |
| 28 | # print out the yaml nav starting with the toc entry and using the first item, |
| 29 | which is generally the package summary as the root element with the rest of the |
| 30 | pages as children beneath the package summary. |
| 31 | |
| 32 | ?> |
| 33 | toc:<?cs each:page = docs.pages?><?cs |
| 34 | if:page.type == "package"?><?cs |
| 35 | call:write_child_nodes(page,"",1) ?><?cs |
| 36 | else?> |
| 37 | <?cs |
| 38 | call:write_child_nodes(page," ",0) ?><?cs |
| 39 | /if?><?cs |
| 40 | /each ?> |