Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(5 edits) (+2)

lilDoc

 A mini, Decker-fied documentation utility inspired by YUI/JSDoc. Add comments to your scripts, and this contraption will be able to generate documentation for their functions automatically. You can create multiple widgets and/or download the formatting guide by clicking on the 'lilDoc' button.

%%WGT0{"w":[{"name":"lilDocFactory","type":"contraption","size":[72,32],"pos":[211,52],"script":"###\n# Displays the 'alert' modal with information about lilDoc and a list of options.\n#\n# @function menuz\n# @return {Dictionary} menu_option A dictionary containing functions.\n##\n\n###\n# Find every formatted comment within a script, then generate documentation.\n#\n# @function gendocz\n# @param {String} x The script to search.\n# @param {String} y The name of the interface that contains the script.\n##\n\n###\n# Create, format and populate a field widget with generated documentation.\n#\n# @function genwidgetz\n# @param {Dictionary} x A dictionary generated with gendocz[]\n# @param {String} y The name provided to gendocz[], used as the title for the documentation.\n##","show":"transparent","def":"lilDocFactory","widgets":{"main1":{},"main2":{},"main_alert":{},"format_guide":{},"fieldscript_template":{}}}],"d":{"lilDocFactory":{"name":"lilDocFactory","size":[72,32],"margin":[5,5,5,6],"description":"Generates documentation for any script available within a deck, using specially formatted comments. ","version":2,"script":"on view do card.show:\"transparent\" end\n\n# Assigning all the different menu options to a dictionary...\nmenu.ds:on x do gendocz[deck.script deck.name] end\nmenu.cs:on x do gendocz[deck.card.script deck.card.name] end\nmenu.sw:on x do\n w:alert[\"Select Widget\" \"choose\" deck.card.widgets]\n gendocz[w.script w.name]\nend\nmenu.sm:on x do\n w:alert[\"Select Module\" \"choose\" deck.modules]\n gendocz[w.script w.name]\nend\nmenu.fg:on x do write[format_guide.text] end\n\non menuz do\n d:(\"Use Deck Script\",\"Use Card Script\",\"Select Widget\",\"Select Module\",\"Download Formatting Guide\",\"Exit\") dict (\"ds\",\"cs\",\"sw\",\"sm\",\"fg\",\"ex\")\n r:alert[main_alert.value \"choose\" d]\n menu[r][]\nend\n\non gendocz x y do\n s:\"\\n\" split x\n i:0\n w:0\n r:() dict ()\n each v k in s\n  if v[2]=\"#\" w:1\n  elseif v[1]=\"#\"\n   r[i].comments:1 drop r[i].comments\n   i:i+1\n   w:0\n  elseif (v[0]=\"#\")&(w)\n   e:\" \" split v\n   if (e[1] like \"@*\")\n    r[i].tags[\" \" fuse (e[1],e[2],e[3])]:\" \" fuse 3 drop e\n   elseif e[2]\n    r[i].comments:r[i].comments,\" \" fuse 1 drop e\n   end\n  end\n end\n genwidgetz[r y]\nend\n\n# Outputs a field widget containing generated documentation.\non genwidgetz x y do\nshow[x]\n r:deck.card.add[\"field\" \"\" fuse y,\"_doc\"]\n r.size:(card.size[0]*3),(card.size[1]*5)\n r.pos:(card.pos[0]-(r.size[0]/2)-(card.size[0]/2)),((card.pos[1]+card.size[1])+3)\n on rtm x y do rtext.make[x y] end\n r.value:rtext.cat[rtm[y \"menu\"],rtm[\"\\nDocumentation generated using lilDoc\\n\\n\" \"mono\"],rtm[\"Function Index\\n\" \"menu\"]]\n r.locked:1\n r.scrollbar:1\n r.script:fieldscript_template.text\n \n on appendr x do r.value:rtext.cat[r.value x] end\n on nline do appendr[\"\\n\"] end\n \n indx:()\n each entry in x\n  each v k in entry.tags\n   if k like \"@function*\"\n   n:\" \" split k\n   indx:indx,n[1]\n   r.value:rtext.cat[r.value rtext.make[n[1] \"body\" n[1]] \"\\n\"]\n   end\n  end\n end\n nline[]\n \n each entry i in x\n  r.value:rtext.cat[r.value \"-\" rtext.make[indx[i] \"menu\"] \"\\n\"]\n  each v k in entry.comments\n   r.value:rtext.cat[r.value v \"\\n\"]\n  end\n  nline[]\n  r.value:rtext.cat[r.value rtext.make[\"\" fuse \"usage:\\n\",indx[i],\"[\" \"mono\"]]\n  pinx:()\n  each v k in entry.tags\n   if k like \"@param*\"\n    pn:\" \" split v\n    pinx:pinx,pn[0]\n   end\n  end\n  appendr[rtext.make[(\" \" fuse pinx) \"mono\" \"\" colors.magenta]]\n  appendr[\"]\\n\\n\"]\n  each v k in entry.tags\n   pn:(\" \" split k),(\" \" split v)\n   if !(pn[0]=\"@function\")\n    fc:(\"@param\",\"@return\") dict (colors.magenta,colors.orange)\n    if pn[0]=\"@return\" appendr[rtext.make[\"returns:\\n\" \"mono\"]] end\n    r.value:rtext.cat[r.value rtext.make[pn[2] \"mono\" \"\" fc[pn[0]]] \" - \" 1 drop -1 drop pn[1] \"\\n\"]\n    appendr[\" \" fuse 4 drop pn]\n    appendr[\"\\n\\n\"]\n   end\n  end\n end\nend","template":"###\n# Displays the 'alert' modal with information about lilDoc and a list of options.\n#\n# @function menuz\n# @return {Dictionary} menu_option A dictionary containing functions.\n##\n\n###\n# Find every formatted comment within a script, then generate documentation.\n#\n# @function gendocz\n# @param {String} x The script to search.\n# @param {String} y The name of the interface that contains the script.\n##\n\n###\n# Create, format and populate a field widget with generated documentation.\n#\n# @function genwidgetz\n# @param {Dictionary} x A dictionary generated with gendocz[]\n# @param {String} y The name provided to gendocz[], used as the title for the documentation.\n##","image":"%%IMG3AEgAIAUgIAJBaZ5oqq5sy44wOc10bd94ru94EIslnnBIFJZiwaJyWTySksyotGeaWq81KHbL1HK/Qy94nBOTzzQz+qxej9vuLzy+ndOv9vs0r4/y+0t/gE0Bg2+FhnKIiXWLjHiOj3uRkn6UlYFVmJkom4ROmp47JkiXolk+Py6rrK2tP0CusrOuMCE=","attributes":{"name":[],"label":[],"type":[]},"widgets":{"main1":{"type":"canvas","size":[56,16],"pos":[8,8],"locked":1,"script":"on click pos do\n \nend\n\non drag pos do\n \nend\n\non release pos do\n \nend","border":1,"image":"%%IMG3ADgAEAKEj6nL7Q+jnLTai3HYiqMdfGDWeJAJcCh5rGOCeiYYtu+zprXI64ZcA552tg5R6EvmHLnmMTQLSn/EBU0Uu12xzyXrCw6Lx+Sy+YwoAA==","scale":1},"main2":{"type":"button","size":[56,16],"pos":[8,8],"script":"on click do menuz[] end","style":"invisible"},"main_alert":{"type":"field","size":[56,16],"pos":[0,-16],"locked":1,"script":"on change val do\n \nend","show":"none","value":{"text":["","lilDoc\n","Generates documentation for any script available within a deck, using specially formatted comments. "],"font":["","menu","mono"],"arg":["","",""]}},"format_guide":{"type":"field","size":[16,16],"pos":[56,-16],"locked":1,"show":"none","style":"plain","value":"Formatting Guide for lilDoc\n~\nSince lilDoc is based on YUIDoc,  it follows similar formatting conventions. \n\nEach comment block starts with a triple octothorp (###) and ends with a double (##)\n\nThe description that will appear when the documentation is generated should be written underneath the (###) header, followed by a single (#) to close it off.\n\nAfter the description, you can add @ tags, which will appear in the documentation with special formatting. As of now, lilDoc recognizes three tags, which should be included in this order:\n@function\nusage: # @function functionName\n\n@param\nusage: @param {paramtype} paramName Description of param variable\nCan include multiple @param tags.\n\n@return\nusage: @return {paramtype} returnName Description of return variable\n\nComment example:\n###\n# The main comment goes here,\n# it can span multiple lines!\n# All tags other than @function are optional.\n#\n# @function coolFunctionName\n# @param {Boolean} bool 0 or 1\n# @param {Number} aNumber Any integer\n# @return {Boolean} isTrue Returns 1 on success\n##\n\nExample params:\n# @param {Boolean} \n# @param {Number} \n# @param {String} \n# @param {List} \n# @param {Dictionary} \n# @param {Table} "},"fieldscript_template":{"type":"field","size":[72,24],"pos":[0,32],"locked":1,"show":"none","value":"on link x do\n me.scrollto[first (rtext.find[me.value (\"\" fuse \"-\",x) 1])]\nend"}}}}}
(+2)

That’s really cool!

I have a suggestion, though: put the format guide into the prototype’s “Template Script”, so that it gets automatically populated when you paste the widget, and you tell the contraption to document itself to read the docs and see the results of formatting.

(+3)

Put out an edit when I woke up today - now there's a template script included with information about the prototype functions. It's also possible to select modules now when importing scripts. At the same time, I discovered a bug where duplicate parameter types would only display the most recent, so I fixed that too! Thank you for your feedback. ^^