docs: getting there
This commit is contained in:
parent
3c101c774d
commit
fcc850df5e
17 changed files with 729 additions and 759 deletions
|
|
@ -9,15 +9,12 @@ var widgets = require('../src/client/widgets'),
|
|||
|
||||
doc.push(`
|
||||
|
||||
## Common
|
||||
## Common
|
||||
|
||||
<div class="accordion" data-category="generic" markdown="1">
|
||||
??? api "<div id="generic_properties">Generic properties<a class="headerlink" href="#generic_properties" title="Permanent link">#</a></div>"
|
||||
Properties shared by all widgets
|
||||
|
||||
<h6 class="accordionlink" id="generic_properties"><a class="headerlink" href="#generic_properties">Generic properties</a></h3>
|
||||
<div class="accordion-description">Properties shared by all widgets</div>
|
||||
|
||||
| property | type |default | description |
|
||||
| --- | --- | --- | --- |`
|
||||
`
|
||||
)
|
||||
|
||||
for (var propName in base) {
|
||||
|
|
@ -26,8 +23,12 @@ for (var propName in base) {
|
|||
permalink = propName
|
||||
|
||||
if (propName[0] === '_' && propName !== '_props') {
|
||||
doc.push(`
|
||||
| <h6 class="thead2" id="${prop}">${prop}<a class="headerlink" href="#${prop}" title="Permanent link">#</a></h6> ||||`
|
||||
doc.push(`\n
|
||||
|
||||
=== "${prop}"
|
||||
|
||||
| property | type |default | description |
|
||||
| --- | --- | --- | --- |`
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -47,8 +48,6 @@ for (var propName in base) {
|
|||
|
||||
}
|
||||
|
||||
doc.push('</div>')
|
||||
|
||||
|
||||
for (var k in widgets.categories) {
|
||||
var category = widgets.categories[k]
|
||||
|
|
@ -58,8 +57,7 @@ for (var k in widgets.categories) {
|
|||
}
|
||||
|
||||
doc.push(`
|
||||
|
||||
## ${k}`
|
||||
## ${k}`
|
||||
)
|
||||
|
||||
for (var kk in category) {
|
||||
|
|
@ -71,14 +69,9 @@ for (var k in widgets.categories) {
|
|||
|
||||
doc.push(`
|
||||
|
||||
??? api "<div id="${type}">${type}<a class="headerlink" href="#${type}" title="Permanent link">#</a></div>"
|
||||
${description}`
|
||||
|
||||
<div class="accordion" data-category="${k}" markdown="1">
|
||||
|
||||
<h6 class="accordionlink" id="${type}"><a class="headerlink" href="#${type}">${type}</a></h3>
|
||||
<div class="accordion-description">${description}</div>
|
||||
|
||||
| property | type |default | description |
|
||||
| --- | --- | --- | --- |`
|
||||
)
|
||||
|
||||
for (var propName in defaults) {
|
||||
|
|
@ -88,8 +81,12 @@ for (var k in widgets.categories) {
|
|||
|
||||
if (propName[0] === '_' && propName !== '_props') {
|
||||
if (separator) doc.pop()
|
||||
doc.push(`
|
||||
| <h6 class="thead2" id="${type + '_' + prop}">${prop}<a class="headerlink" href="#${type + '_' + prop}" title="Permanent link">#</a></h6> ||||`
|
||||
if (doc[doc.length -1].trim()[0] === '=') doc.pop()
|
||||
doc.push(`\n
|
||||
=== "${prop}"
|
||||
|
||||
| property | type |default | description |
|
||||
| --- | --- | --- | --- |`
|
||||
)
|
||||
separator = true
|
||||
}
|
||||
|
|
@ -105,44 +102,16 @@ for (var k in widgets.categories) {
|
|||
}
|
||||
|
||||
doc.push(`
|
||||
| <h6 id="${permalink}" class="${dynamic? 'dynamic' : ''}">${propName}<a class="headerlink" href="#${permalink}" title="Permanent link">#</a></h6> | \`${prop.type.replace(/\|/g,'\`|<br/>\`')}\` | <code>${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,'<br/>').replace('{','\\{')}</code> | ${help} |`
|
||||
| <h6 id="${permalink}" class="${dynamic? 'dynamic' : ''}">${propName}<a class="headerlink" href="#${permalink}" title="Permanent link">#</a></h6> | \`${prop.type.replace(/\|/g,'\`|<br/>\`')}\` | <code>${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,'<br/>').replace('{','\\{')}</code> | ${help} |`
|
||||
)
|
||||
separator = false
|
||||
}
|
||||
|
||||
if (separator) doc.pop()
|
||||
|
||||
doc.push('</div>\n\n')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
doc.push(`\n\n
|
||||
<script>
|
||||
document.querySelectorAll('.thead2').forEach(function(item){
|
||||
item.classList.remove('thead2')
|
||||
item.closest('tr').classList.add('thead2')
|
||||
})
|
||||
document.querySelectorAll('.accordionlink').forEach(function(item){
|
||||
item.addEventListener('click', function(e){
|
||||
e.preventDefault()
|
||||
var node = item.parentNode
|
||||
node.classList.toggle('show')
|
||||
if (node.classList.contains('show')){
|
||||
history.replaceState(null, null, '#' + item.getAttribute('id'));
|
||||
} else {
|
||||
history.replaceState(null, null, ' ');
|
||||
}
|
||||
})
|
||||
})
|
||||
if (window.location.hash) {
|
||||
document.querySelectorAll('[id='+window.location.hash.split("#")[1]+']').forEach(function(item){
|
||||
item.click()
|
||||
})
|
||||
}
|
||||
</script>
|
||||
`)
|
||||
|
||||
console.log(doc.join('').replace(/^ +/gm,''))
|
||||
console.log(doc.join(''))
|
||||
|
||||
process.exit(0) // avoid setTimeout errors in required modules
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue