github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0074.yml (about) 1 doc_meta: | 2 folder: object-oriented 3 title: parse yml to object 4 head: | 5 Showcase you can load a yml file and parse the content to object 6 7 sections: 8 - title: How to use 9 content: | 10 Simply use dvar ref to load the content and also flag it to be converted toObj 11 12 The print cmd shows how to use the object and reference in golang template to iterate through the elements 13 14 - title: Relavant 15 content: toObj cmd 16 refs: 17 - title: toObj cmd 18 link: ../../cmd-func/c0095 19 20 - title: Demo 21 log: yes 22 23 docs: 24 goal: 25 - to test that I can parse this file to an object and use it in templating 26 - use the format like this to automate the docs generation 27 28 usecase: 29 - used to generate auto document for up project 30 31 usage: 32 - use docs as root element to document a functest or a test case 33 - two layers structure 34 35 dvars: 36 - name: usecase 37 ref: c0074.yml 38 flags: [toObj,] 39 40 tasks: 41 - 42 name: task 43 desc: 44 task: 45 - 46 func: cmd 47 do: 48 - 49 name: print 50 cmd: "{{.usecase_object}}" 51 52 - 53 name: print 54 cmd: "{{.usecase_object.docs}}" 55 56 - 57 name: print 58 cmd: |- 59 {{range $case :=.usecase_object.docs}} 60 {{$case}} 61 {{end}} 62 63 - 64 name: print 65 cmd: |- 66 {{range $head,$items :=.usecase_object.docs}} 67 {{$head}}: 68 {{range $idx,$item :=$items}} 69 * {{$idx|add1}}: {{$item}} 70 {{end}} 71 {{end}}