code: def generate_navbar(page_data):
      """Return a string. It is the navigation bar for ``page_data``."""
  
      def generate_top_navbar():
          # Create top of navbar. (Note this can be cached and not run within a loop.)
          top_navbar = """\\begin{abstract}
  \section{API and Documentation}
  \\begin{lstlisting}[raw=html]
  <div class="row" style="padding-bottom: 5%">
  <div class="row" style="padding-bottom: 1%">"""
          for page_data in PAGES:
              title = page_data["title"]
              page_name = page_data["page"]
              parent_pages = page_data["parent_pages"]
              if len(parent_pages) == 0 and page_name not in [
                  "index.tex",
                  "reference.tex",
              ]:
                  top_navbar += "\n"
                  top_navbar += '<a class="button3" href="/api/'
                  top_navbar += page_name.replace(".tex", "")
                  top_navbar += '">'
                  top_navbar += title
                  top_navbar += "</a>"
  
          top_navbar += "\n"
          top_navbar += "</div>"
          return top_navbar
  
      page_name = page_data["page"]
      title = page_data["title"]
      parent_pages = page_data["parent_pages"]
      child_pages = page_data["child_pages"]
  
      navbar = generate_top_navbar()
      # Create bottom of navbar if there are child pages for that section.
      if len(child_pages) > 0 or len(parent_pages) > 0:
          if len(parent_pages) > 0:
              parent = parent_pages[0]
              parent_page = [
                  page_data
                  for page_data in PAGES
                  if page_data["page"] == parent
              ][0]
              pgs = parent_page["child_pages"]
          else:
              pgs = child_pages
  
          navbar += "\n"
          navbar += '<div class="row">'
          for child_page in pgs:
              navbar += "\n"
              navbar += '<a class="button4" href="/api/'
              navbar += child_page.replace(".tex", "")
              navbar += '">'
              navbar += [
                  page_data
                  for page_data in PAGES
                  if page_data["page"] == child_page
              ][0]["title"]
              navbar += "</a>"
  
          navbar += "\n"
          navbar += "</div>"
  
      navbar += "\n"
      navbar += """</div>
  \end{lstlisting}
  \end{abstract}"""
  
      # Set primary button in navbar. If a child page, set primary buttons
      # for both top and bottom of navbar.
      search_term = (
          '" href="/api/' + page_name.replace(".tex", "") + '">'
      )
      navbar = navbar.replace(
          search_term, " button-primary" + search_term
      )
      if len(parent_pages) > 0:
          parent = parent_pages[0]
          search_term = (
              '" href="/api/' + parent.replace(".tex", "") + '">'
          )
          navbar = navbar.replace(
              search_term, " button-primary" + search_term
          )
  
      return navbar
  
file_path: edward/docs/generate_api_navbar_and_symbols.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import os
  import shutil
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: generate_navbar(page_data) and returns: navbar, top_navbar