{"action":"created","issue":{"url":"https://api.github.com/repos/esdoc/esdoc/issues/305","repository_url":"https://api.github.com/repos/esdoc/esdoc","labels_url":"https://api.github.com/repos/esdoc/esdoc/issues/305/labels{/name}","comments_url":"https://api.github.com/repos/esdoc/esdoc/issues/305/comments","events_url":"https://api.github.com/repos/esdoc/esdoc/issues/305/events","html_url":"https://github.com/esdoc/esdoc/issues/305","id":164042651,"number":305,"title":"Documenting dynamically attached properties","user":{"login":"damirka","id":8008055,"avatar_url":"https://avatars.githubusercontent.com/u/8008055?v=3","gravatar_id":"","url":"https://api.github.com/users/damirka","html_url":"https://github.com/damirka","followers_url":"https://api.github.com/users/damirka/followers","following_url":"https://api.github.com/users/damirka/following{/other_user}","gists_url":"https://api.github.com/users/damirka/gists{/gist_id}","starred_url":"https://api.github.com/users/damirka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damirka/subscriptions","organizations_url":"https://api.github.com/users/damirka/orgs","repos_url":"https://api.github.com/users/damirka/repos","events_url":"https://api.github.com/users/damirka/events{/privacy}","received_events_url":"https://api.github.com/users/damirka/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-06T10:11:06Z","updated_at":"2016-12-31T06:13:55Z","closed_at":"2016-12-31T06:13:55Z","body":"Hello, is there a way to document dynamically attached properties of the class? Maybe there's a way with `@typedef` tag or any other?\n\nHere's an example\n\n``` JavaScript\n// parent model, somehow takes data from redis hash and assigns\n// selected data to current class\nclass Model {\n  get hashName () {\n    return null;\n  }\n\n  // data - taken from redis storage\n  constructor (data) {\n    // properties are different for every model \n    Object.assign(this, data);\n  }\n}\n\n// takes json from cars storage\nclass Car extends Model {\n  get hashName () {\n    return 'cars';\n  }\n}\n\n// ... more classes ...\n```\n"},"comment":{"url":"https://api.github.com/repos/esdoc/esdoc/issues/comments/269851751","html_url":"https://github.com/esdoc/esdoc/issues/305#issuecomment-269851751","issue_url":"https://api.github.com/repos/esdoc/esdoc/issues/305","id":269851751,"user":{"login":"h13i32maru","id":985170,"avatar_url":"https://avatars.githubusercontent.com/u/985170?v=3","gravatar_id":"","url":"https://api.github.com/users/h13i32maru","html_url":"https://github.com/h13i32maru","followers_url":"https://api.github.com/users/h13i32maru/followers","following_url":"https://api.github.com/users/h13i32maru/following{/other_user}","gists_url":"https://api.github.com/users/h13i32maru/gists{/gist_id}","starred_url":"https://api.github.com/users/h13i32maru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h13i32maru/subscriptions","organizations_url":"https://api.github.com/users/h13i32maru/orgs","repos_url":"https://api.github.com/users/h13i32maru/repos","events_url":"https://api.github.com/users/h13i32maru/events{/privacy}","received_events_url":"https://api.github.com/users/h13i32maru/received_events","type":"User","site_admin":false},"created_at":"2016-12-31T06:13:55Z","updated_at":"2016-12-31T06:13:55Z","body":"ESDoc does not support it. Because ESDoc generates doc from concrete codes. A Dynamically codes (aka meta programming) is not targeted of ESDoc.\r\n\r\nHowever [Plugin API](https://esdoc.org/manual/advanced/api.html#plugin-feature) may help you.\r\n\r\nA rough code:\r\n`Foo.js`\r\n```js\r\n/**\r\n * this is Foo.\r\n * @dynamic {number} p1 - this is instance member\r\n */\r\nexport default class Foo{}\r\n```\r\n\r\n`esdoc.json`\r\n```json\r\n{\r\n  \"source\": \"./src\",\r\n  \"destination\": \"./doc\",\r\n  \"plugins\": [\r\n    {\"name\": \"./dynamic-property-plugin.js\"}\r\n  ]\r\n}\r\n```\r\n\r\n`dynamic-property-plugin.js`\r\n```js\r\nfunction supportDynamic(tag){\r\n  const results = [];\r\n\r\n  for (const item of tag.unknown) {\r\n    if (item.tagName === '@dynamic') {\r\n      const matched = item.tagValue.match(/^\\{(.*?)\\} ([\\w0-9_]+) -?(.*)$/m);\r\n      const type = matched[1];\r\n      const name = matched[2];\r\n      const desc = matched[3].trim();\r\n\r\n      results.push({\r\n        kind: 'member',\r\n        name: name,\r\n        memberof: tag.longname,\r\n        static: false,\r\n        longname:`${tag.longname}#${name}`,\r\n        access: 'public',\r\n        description: desc,\r\n        lineNumber: tag.lineNumber,\r\n        type: {types: [type]}\r\n      });\r\n    }\r\n  }\r\n\r\n  return results;\r\n}\r\n\r\nexports.onHandleTag = function(ev) {\r\n  const tags = ev.data.tag;\r\n\r\n  for (const tag of tags) {\r\n    if (tag.kind === 'class') {\r\n      const dynamicTags = supportDynamic(tag);\r\n      ev.data.tag.push(...dynamicTags);\r\n    }\r\n  }\r\n};\r\n```"}}
{"actor":{"display_login":"h13i32maru"}}