scripts/doc-generator/generate_sidebar_html.js
/**
 * Construct HTML element, as a string, which corresponds to the sidebar for
 * the chosen documentation page.
 * @param {Array.<Object>} pages
 * @param {Array.<number>} currentPageIndexes
 * @param {string} currentPath
 * @param {Object} logoInfo
 * @returns {string}
 */
Construct HTML element, as a string, which corresponds to the sidebar for
the chosen documentation page.
Construct HTML element as a string which corresponds to the sidebar for the chosen documentation page .
function generateSidebarHtml(
  pages,
  currentPageIndexes,
  currentPath,
  logoInfo
) {
  const sidebarHeaderHtml = constructSidebarHeaderHtml(logoInfo);
  const links = pages.map((p, i) => {
    const isActive = i === currentPageIndexes[0];
    if (!p.isPageGroup) {
      return generateLiForPage(p, isActive);
    } else {
      const lis = p.pages.map((sp, j) => {
        const isActiveSubPage = isActive && j === currentPageIndexes[1];
        return generateLiForPage(sp, isActiveSubPage);
      }).join("");
      return `<li class="sidebar-item">` +
        `<div class="sidebar-item sidebar-item-group${isActive ? " active opened" : ""}">` +
        encode(p.displayName) +
        "</div>" +
        `<ul>${lis}</ul>` +
        "</li>";
    }
  }).join("");
  return `<aside class="sidebar-parent">` +
    sidebarHeaderHtml +
    `<div class="sidebar-wrapper">` +
    `<div class="sidebar-items">${links}</div>` +
    "</div>" +
    "</aside>";
  function generateLiForPage(p, isActive) {
    const relativeUri = toUriCompatibleRelativePath(
      p.outputFile,
      path.dirname(currentPath)
    );
    const activeClass = isActive ? " active" : "";
    const cleanedHref = encode(relativeUri);
    return "<li class=\"sidebar-item\">" +
      `<a class="sidebar-link${activeClass}" href="` +
      cleanedHref +
      `">${encode(p.displayName)}</a>` +
      "</li>";
  }
}
function generateSidebarHtml ( pages , currentPageIndexes , currentPath , logoInfo ) { const sidebarHeaderHtml = constructSidebarHeaderHtml ( logoInfo ) ; const links = pages . map ( ( p , i ) => { const isActive = i === currentPageIndexes [ 0 ] ; if ( ! p . isPageGroup ) { return generateLiForPage ( p , isActive ) ; } else { const lis = p . pages . map ( ( sp , j ) => { const isActiveSubPage = isActive && j === currentPageIndexes [ 1 ] ; return generateLiForPage ( sp , isActiveSubPage ) ; } ) . join ( "" ) ; return ` ` + ` ${ isActive ? " active opened" : "" } ` + encode ( p . displayName ) + "</div>" + ` ${ lis } ` + "</li>" ; } } ) . join ( "" ) ; return ` ` + sidebarHeaderHtml + ` ` + ` ${ links } ` + "</div>" + "</aside>" ; function generateLiForPage ( p , isActive ) { const relativeUri = toUriCompatibleRelativePath ( p . outputFile , path . dirname ( currentPath ) ) ; const activeClass = isActive ? " active" : "" ; const cleanedHref = encode ( relativeUri ) ; return "<li class=\"sidebar-item\">" + ` ${ activeClass } ` + cleanedHref + ` ${ encode ( p . displayName ) } ` + "</li>" ; } }
Construct HTML element, as a string, which corresponds to the sidebar for
 the chosen documentation page.
Construct HTML element as a string which corresponds to the sidebar for the chosen documentation page .