def add_index()

in notebooks/notebook_template_review.py [0:0]


def add_index(path: str, 
              tags: List, 
              linkbacks: List,
              title : str, 
              desc: str, 
              uses: str, 
              steps: str, 
              git_link: str, 
              colab_link: str, 
              colab_enterprise_link: str,
              workbench_link: str
             ):
    """
    Add a discoverability index for this notebook
    
        path: The path to the notebook
        tags: The tags (if any) for the notebook
        title: The H1 title for the notebook
        desc: The notebook description
        uses: The resources/services used by the notebook
        steps: The steps specified by the notebook
        git_link: The link to the notebook in the git repo
        colab_link: Link to launch notebook in Colab
        colab_enterpise_link: Link to launch notebook in Colab Enterprise
        workbench_link: Link to launch notebook in Workbench
        linkbacks: The linkbacks per tag
    """
    global last_tag
    
    if not args.web and not args.repo:
        return
    
    title = title.split(':')[-1].strip()
    title = title[0].upper() + title[1:]
    if args.web:
        title = replace_cl(replace_backtick(title))
        
        print('    <tr>')
        print('        <td>')
        for tag in tags:
            tag = replace_cl(tag)
            print(f'            {tag.strip()}<br/>\n')
        print('        </td>')
        print('        <td>')
        print(f'            <b>{title}</b>. ')
        if args.desc:
            desc = replace_cl(replace_backtick(desc))
            print('<br/>')
            print(f'            {desc}\n')
            
            
        if args.linkback and linkbacks:
            num = len(tags)
            for _ in range(num):
                if linkbacks[_].startswith("vertex-ai"):
                    print(f' Learn more about <a href="https://cloud.google.com/{linkbacks[_]}" target="_blank">{replace_cl(tags[_])}</a>.\n')
                else:
                    print(f' Learn more about <a href="{linkbacks[_]}" target="_blank">{replace_cl(tags[_])}</a>.\n')
                    
        if args.steps:
            print("<devsite-expandable>\n")
            print('  <p class="showalways">Tutorial steps</p>\n')
            print('  <ul>\n')
            
            if ":" in steps:
                steps = replace_backtick(steps)
                steps = steps.split(':')[1].replace('*', '').replace('-', '').strip().split('\n')
            else:
                steps = []
              
            for step in steps:
                print(f'    <li>{replace_cl(step)}</li>\n')
            print('  </ul>\n')
            print("</devsite-expandable>\n")
                    
        print('        </td>')
        print('        <td>')
        if colab_link:
            print(f'            <a href="{colab_link}" target="_blank" track-type="notebookTutorial" track-name="colabLink">Colab</a><br/>\n')
        if colab_enterprise_link:
            print(f'            <a href="{colab_enterprise_link}" target="_blank" track-type="notebookTutorial" track-name="colabEnterpriseLink">Colab Enterprise</a><br/>\n')
        if git_link:
            print(f'            <a href="{git_link}" target="_blank" track-type="notebookTutorial" track-name="gitHubLink">GitHub</a><br/>\n')
        if workbench_link:
            print(f'            <a href="{workbench_link}" target="_blank" track-type="notebookTutorial" track-name="workbenchLink">Vertex AI Workbench</a><br/>\n')
        print('        </td>')
        print('    </tr>\n')
    elif args.repo:
        try:
            if tags != last_tag and tag != '':
                last_tag = tags
                flat_list = ''
                for item in tags:
                    flat_list += item.replace("'", '') + ' '
                print(f"\n### {flat_list}\n")
        except:
            pass
        print(f"\n[{title}]({git_link})\n")
    
        print("```")
        if args.desc:
            print(desc)

        if args.uses:
            print(uses)

        if args.steps:
            print(steps.rstrip() + '\n')
            
        print("```\n")
            
        if args.linkback and linkbacks:
            num = len(tags)
            for _ in range(num):
                if linkbacks[_].startswith("vertex-ai"):
                    print(f'&nbsp;&nbsp;&nbsp;Learn more about [{tags[_]}]({linkbacks[_]}).\n')
                else:
                    print(f'&nbsp;&nbsp;&nbsp;Learn more about [{tags[_]}]({linkbacks[_]}).\n')