vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
6.2 KiB

  1. # Command line usage example
  2. ```
  3. jsdoc -c jsdoc.json -r -t docs -d gen/docs lib
  4. ```
  5. - `-c`: use this config file for `jsdoc`
  6. - `-r`: Recurse into subdirectories of the specified source directories
  7. - `-t`: Use template in path `docs`
  8. - `-d`: Generated html files put in `gen/docs`
  9. - Source files to parse are taken from directory `lib`
  10. ## Notes
  11. The template generation is set up so that:
  12. - Files ending in `.tmpl` are skipped
  13. - All non-html files are plain copied
  14. - html-files *can* contain `<?js ?>` tags, but this is not required
  15. ## Intention
  16. The `docs` directory is treated as a `jsdoc` template, in which the html-files are the template files. This allows for a gradual adaptation of the html-files to templates; unchanged html-files will pass through `jsdoc` unchanged.
  17. The added value of using `jsdoc` for documentation generation, is that the complete documentation information, as collected by `jsdoc` from the source, is available for usage. This way, it's possible to insert technical notes from the source code into the documentation.
  18. ----
  19. # Usage of and Notes on Source Code
  20. This section contains notes on the usage of `jsdoc` functionality, to aid with the handling of its generated data.
  21. ## Parameters of `publish()`
  22. ### Parameter `taffyData`
  23. A table containing *all* data collected from the source code, related to jsdoc generation. See below for more info and example outputs.
  24. ### Parameter `opt`
  25. Example of `opt` variable:
  26. ```js
  27. {
  28. "_":["../github/vis/lib/network/"],
  29. "configure":"jsdoc.json",
  30. "recurse":true,
  31. "template":"/home/wim/projects/jsdoc/default",
  32. "destination":"./out/",
  33. "encoding":"utf8"
  34. }
  35. ```
  36. ### Parameter `tutorial`
  37. This does not appear to be of use for the generation of `vis.js` documentation.
  38. Example of `tutorial` variable:
  39. ```js
  40. {
  41. "longname":"",
  42. "name":"",
  43. "title":"",
  44. "content":"",
  45. "parent":null,
  46. "children":[],
  47. "_tutorials":{}
  48. }
  49. ```
  50. ## Global variable `env`
  51. This contains addition info for the current execution of `jsdoc`. Example of `env` variable:
  52. ```js
  53. {
  54. "run":{"start":"2017-09-16T05:06:45.621Z","finish":null},
  55. "args":["-c","jsdoc.json","-r","-t","default","../github/vis/lib/network/"],
  56. "conf":{
  57. "plugins":["/usr/lib/node_modules/jsdoc/plugins/markdown.js"],
  58. "recurseDepth":10,
  59. "source":{"includePattern":".+\\.js(doc|x)?$","excludePattern":""},
  60. "sourceType":"module",
  61. "tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},
  62. "templates":{"monospaceLinks":false,"cleverLinks":false}
  63. },
  64. "dirname":"/usr/lib/node_modules/jsdoc",
  65. "pwd":"/home/wim/projects/jsdoc",
  66. "opts":{ <<same as parameter 'opt' above>> },
  67. "sourceFiles":[ <<list of full path names of all js-source files used as input>> ],
  68. "version":{"number":"3.5.4","revision":"Fri, 04 Aug 2017 22:05:27 GMT"}
  69. }
  70. ```
  71. ## taffyData
  72. This is a parameter to `publish()`. It's a table containing *all* data collected from the source code, related to jsdoc generation.
  73. I can't find any way to return a list of fields for the data items in the taffyDB docs, therefore below there are examples of items, for better understanding of usage.
  74. Example usage:
  75. ```js
  76. var data = taffyData;
  77. var tmp = data().filter({name:'Label'}).get();
  78. ```
  79. Returns an array with all items with `name === 'Label'`. Example output of one of these items, for a class:
  80. *In these examples, block comment endings are redacted to ' * /'*
  81. ```js
  82. {
  83. "comment":"/**\n * A Label to be used for Nodes or Edges.\n * /",
  84. "meta":{
  85. "range":[3770,41303],
  86. "filename":"Label.js",
  87. "lineno":167,
  88. "columnno":0,
  89. "path":"/home/wim/projects/github/vis/lib/network/modules/components/shared",
  90. "code":{
  91. "id":"astnode100065034",
  92. "name":"Label",
  93. "type":"ClassDeclaration",
  94. "paramnames":["body","options","edgelabel"]
  95. }
  96. },
  97. "classdesc":"
  98. A Label to be used for Nodes or Edges.
  99. ",
  100. "name":"Label",
  101. "longname":"Label",
  102. "kind":"class",
  103. "scope":"global",
  104. "params":[
  105. {"type":{"names":["Object"]},"name":"body"},
  106. {"type":{"names":["Object"]},"name":"options"},
  107. {"type":{"names":["boolean"]},"optional":true,"defaultvalue":false,"name":"edgelabel"}
  108. ],
  109. "___id":"T000002R005289",
  110. "___s":true
  111. }
  112. ```
  113. Example of item for an instance method:
  114. ```js
  115. var tmp = data().filter({name:'_drawText'}).get();
  116. ```
  117. Full output returned:
  118. ```js
  119. [{
  120. "comment":"/**\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {boolean} selected\n * @param {boolean} hover\n * @param {number} x\n * @param {number} y\n * @param {string} [baseline='middle']\n * @private\n * /",
  121. "meta":{
  122. "range":[20060,22269],
  123. "filename":"Label.js",
  124. "lineno":652,
  125. "columnno":2,
  126. "path":"/home/wim/projects/github/vis/lib/network/modules/components/shared",
  127. "code":{
  128. "id":"astnode100066427",
  129. "name":"Label#_drawText",
  130. "type":"MethodDefinition",
  131. "paramnames":["ctx","selected","hover","x","y","baseline"]
  132. },
  133. "vars":{"":null}
  134. },
  135. "params":[
  136. {"type":{"names":["CanvasRenderingContext2D"]},"name":"ctx"},
  137. {"type":{"names":["boolean"]},"name":"selected"},
  138. {"type":{"names":["boolean"]},"name":"hover"},
  139. {"type":{"names":["number"]},"name":"x"},
  140. {"type":{"names":["number"]},"name":"y"},
  141. {"type":{"names":["string"]},"optional":true,"defaultvalue":"'middle'","name":"baseline"}
  142. ],
  143. "access":"private",
  144. "name":"_drawText",
  145. "longname":"Label#_drawText",
  146. "kind":"function",
  147. "memberof":"Label",
  148. "scope":"instance",
  149. "___id":"T000002R005388",
  150. "___s":true
  151. }]
  152. ```
  153. ## `jsdoc` template rendering
  154. See `function createRenderer(fromDir, data)` in code for usage.
  155. There are two calls for rendering templates:
  156. - `var html = renderer.render(inFile, docData);`
  157. - `var html = renderer.partial(inFile, docData);`
  158. The difference is that `render()` will use a default layout template, if present, which will encapsulate all html. This can be set by:
  159. ```js
  160. renderer.layout = 'path/to/default/layout.tmpl';
  161. ```
  162. Parameter `docData` is a hash which is used to pass parameters into a template. The standard way of using this appear to be:
  163. ```
  164. <?js
  165. var data = obj; // Whatever docData is
  166. var self = this;
  167. ?>
  168. ```
  169. But it also appear to be possible to use the elements of docData directly:
  170. ```js
  171. var docData = {
  172. myTitle: 'Hello, pussycat!'
  173. };
  174. ```
  175. Within the template:
  176. ```
  177. <?js= myTitle ?>
  178. ```