docs: more formatting

This commit is contained in:
jean-emmanuel 2018-08-30 20:19:05 +02:00
parent 9a9af0e854
commit 8d0f8080dd

View file

@ -36,8 +36,32 @@ LANG = 'en'
// Here we go
var widgets = require('../src/browser/js/app/widgets'),
doc = '',
first
base = require('../src/browser/js/app/widgets/common/widget').defaults(),
doc = ''
doc += '\n\n'
doc += '## Generic properties'
doc += '\n\n'
doc += '| property | type |default | description |'
doc += '\n'
doc += '| --- | --- | --- | --- |'
for (var propName in base) {
var prop = base[propName],
permalink = propName
if (propName === '_props' || propName[0] === '_') continue
var help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || ''
doc += '\n'
doc += `| <h4 id="${permalink}">${propName}<a class="headerlink" href="#${permalink}" title="Permanent link">¶</a></h4> | \`${prop.type.replace(/\|/g,'\`\\|<br/>\`')}\` | <code>${(JSON.stringify(prop.value, null, '&nbsp;') || '').replace(/\n/g,'<br/>')}</code> | ${help} |`
}
for (var k in widgets.categories) {
var category = widgets.categories[k]
@ -62,12 +86,12 @@ for (var k in widgets.categories) {
var prop = defaults[propName],
permalink = type + '_' + propName
if (propName === '_props' || propName === 'type' || propName[0] === '_') continue
if (propName === '_props' || propName[0] === '_' || JSON.stringify(prop) == JSON.stringify(base[propName])) continue
var help = Array.isArray(prop.help) ? prop.help.join('<br/>') : prop.help || ''
var help = Array.isArray(prop.help) ? prop.help.join('<br/><br/>').replace(/<br\/>-/g, '-') : prop.help || ''
doc += '\n'
doc += `| <h4 id="${permalink}">${propName}<a class="headerlink" href="#${permalink}" title="Permanent link">¶</a></h4> | \`${prop.type.replace(/\|/g,'\`\\|<br/>\`')}\` | <code>${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,'<br/>')}</code> | ${help} |`
doc += `| <h4 id="${permalink}">${propName}<a class="headerlink" href="#${permalink}" title="Permanent link">¶</a></h4> | \`${prop.type.replace(/\|/g,'\`\\|<br/>\`')}\` | <code>${(JSON.stringify(prop.value, null, '&nbsp;') || '').replace(/\n/g,'<br/>')}</code> | ${help} |`
}