added doc printing to .getHandlerDocStr(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-10-30 22:00:24 +03:00
parent 29854ef2fe
commit b658859723
2 changed files with 30 additions and 22 deletions

View File

@ -677,8 +677,8 @@ function Action(name, doc, ldoc, attrs, func){
Object.defineProperty(meth, 'name', { Object.defineProperty(meth, 'name', {
value: name, value: name,
}) })
meth.doc = doc func.doc = meth.doc = doc
meth.long_doc = ldoc func.long_doc = meth.long_doc = ldoc
meth.func = func meth.func = func
@ -1459,6 +1459,11 @@ module.MetaActions = {
res.post = a.post_handler res.post = a.post_handler
} }
a.doc
&& (res.doc = a.doc)
a.long_doc
&& (res.long_doc = a.long_doc)
return res return res
}) })
}, },
@ -2004,10 +2009,28 @@ module.MetaActions = {
// XXX would be nice to make these prop of the action itself but I // XXX would be nice to make these prop of the action itself but I
// do not see a way to do this properly yet -- we can't get to // do not see a way to do this properly yet -- we can't get to
// the action context from the action dynamically... // the action context from the action dynamically...
// XXX add doc per action...
getHandlerDocStr: function(name){ getHandlerDocStr: function(name){
var lst = this.getHandlers(name) var lst = this.getHandlers(name)
var str = '' var str = ''
var getTags = function(handler, p){
return (handler.event_tag ?
normalizeTabs('// Event tag: ' + handler.event_tag) + p
: '')
+ (handler.source_tag ?
normalizeTabs('// Source tag: ' + handler.source_tag) + p
: '') }
var getDoc = function(cur, p){
return (cur.doc ?
'// --- .doc ---'+p
+'// '+ normalizeTabs(cur.doc).replace(/\n/g, p+'// ') +p
: '')
+ (cur.long_doc ?
'// --- .long_doc ---'+p
+'// '+ normalizeTabs(cur.long_doc).replace(/\n/g, p+'// ') + p
: '') }
var handler = function(p){ var handler = function(p){
if(lst.length == 0){ if(lst.length == 0){
//str += p + '---' //str += p + '---'
@ -2021,22 +2044,10 @@ module.MetaActions = {
if(cur.pre){ if(cur.pre){
str += p str += p
// meta... + getTags(cur.pre, p)
+ (cur.pre.event_tag ? + getDoc(cur, p)
normalizeTabs('// Event tag: ' + cur.pre.event_tag) + p : '')
+ (cur.pre.source_tag ?
normalizeTabs('// Source tag: ' + cur.pre.source_tag) + p : '')
// code... // code...
+ normalizeTabs(cur.pre.toString()).replace(/\n/g, p) + normalizeTabs(cur.pre.toString()).replace(/\n/g, p)
/*
+ normalizeTabs(
!cur.pre.alias ?
cur.pre.toString()
: typeof(cur.pre.alias) == typeof('str') ?
cur.pre.alias
: cur.pre.alias.code
).replace(/\n/g, p)
*/
+ p + p
} }
@ -2046,11 +2057,8 @@ module.MetaActions = {
if(cur.post){ if(cur.post){
str += p + p str += p + p
// meta... + getTags(cur.post, p)
+ (cur.post.event_tag ? + getDoc(cur, p)
normalizeTabs('// Event source tag: ' + cur.post.event_tag) + p : '')
+ (cur.post.source_tag ?
normalizeTabs('// Source tag: ' + cur.post.source_tag) + p : '')
// code... // code...
+ normalizeTabs(cur.post.toString()).replace(/\n/g, p) + normalizeTabs(cur.post.toString()).replace(/\n/g, p)
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-actions", "name": "ig-actions",
"version": "3.21.0", "version": "3.21.1",
"description": "", "description": "",
"main": "actions.js", "main": "actions.js",
"scripts": { "scripts": {