MCPcopy Create free account
hub / github.com/SoftwareBrothers/better-docs / buildNav

Function buildNav

publish.js:446–477  ·  view source on GitHub ↗

* Create the navigation sidebar. * @param {object} members The members that will be used to create the sidebar. * @param {array } members.classes * @param {array } members.components * @param {array } members.externals * @param {array } members.globals * @param {arr

(members, navTypes = null, betterDocs)

Source from the content-addressed store, hash-verified

444 * @return {string} The HTML for the navigation sidebar.
445 */
446function buildNav(members, navTypes = null, betterDocs) {
447 const href = betterDocs.landing ? 'docs.html' : 'index.html'
448 var nav = navTypes ? '' : `<h2><a href="${href}">Documentation</a></h2>`
449
450 var categorised = {}
451 var rootScope = {}
452
453 var types = navTypes || ['modules', 'externals', 'namespaces', 'classes',
454 'components', 'interfaces', 'events', 'mixins', 'globals']
455 types.forEach(function(type) {
456 if (!members[type]) { return }
457 members[type].forEach(function(element) {
458 if (element.access && element.access === 'private') {
459 return
460 }
461 if (element.category) {
462 if (!categorised[element.category]){ categorised[element.category] = [] }
463 if (!categorised[element.category][type]){ categorised[element.category][type] = [] }
464 categorised[element.category][type].push(element)
465 } else {
466 rootScope[type] ? rootScope[type].push(element) : rootScope[type] = [element]
467 }
468 })
469 })
470
471 nav += buildGroupNav(rootScope)
472 Object.keys(categorised).sort().forEach(function (category) {
473 nav += buildGroupNav(categorised[category], category)
474 })
475
476 return nav
477}
478
479/**
480 @param {TAFFY} taffyData See <http://taffydb.com/>.

Callers 1

publish.jsFile · 0.85

Calls 1

buildGroupNavFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…