(fname_templ)
return tmpl_examples
Get all examples based on input template rst file
Get all examples based on input template rst file
Get all examples based on input template rst file
def get_tmpl_examples(fname_templ):
    """Get all examples based on input template rst file"""
    tmpl_examples = []
    with open(fname_templ, encoding='utf-8') as fin:
        doc = fin.readlines()

        while len(doc) > 0:
            # Parsing lines until ``.. sdc_toctree`` section is met
            while len(doc) > 0 and not doc[0].startswith('.. sdc_toctree'):
                line = doc[0]
                if line.startswith('.. currentmodule::'):
                    current_module_name = line[19:].strip()
                doc.pop(0)

            if len(doc) == 0:
                break

            doc.pop(0)  # Skipping ``.. sdc_toctree``

            # Parsing the list of APIs
            while len(doc) > 0 and doc[0].strip() != '':
                line = doc[0]
                line = line.strip()
                full_name = current_module_name + '.' + line
                doc.pop(0)

                obj_examples = get_obj_examples(full_name)
                if obj_examples:
                    tmpl_examples.append(obj_examples)

            if len(doc) == 0:
                break

    return tmpl_examples
def get_tmpl_examples ( fname_templ ) : tmpl_examples = [ ] with open ( fname_templ , encoding = 'utf-8' ) as fin : doc = fin . readlines ( ) while len ( doc ) > 0 : # Parsing lines until ``.. sdc_toctree`` section is met while len ( doc ) > 0 and not doc [ 0 ] . startswith ( '.. sdc_toctree' ) : line = doc [ 0 ] if line . startswith ( '.. currentmodule::' ) : current_module_name = line [ 19 : ] . strip ( ) doc . pop ( 0 ) if len ( doc ) == 0 : break doc . pop ( 0 ) # Skipping ``.. sdc_toctree`` # Parsing the list of APIs while len ( doc ) > 0 and doc [ 0 ] . strip ( ) != '' : line = doc [ 0 ] line = line . strip ( ) full_name = current_module_name + '.' + line doc . pop ( 0 ) obj_examples = get_obj_examples ( full_name ) if obj_examples : tmpl_examples . append ( obj_examples ) if len ( doc ) == 0 : break return tmpl_examples