(fname_templ)
Parses input template rst file and outputs the final rst file
    Template document must have the following structure:

    Heading or subheading
    *********************

    Any text (if any)

    Another heading or subheading
    -----------------------------

    Any text (if any)

    .. currentmodule:: <module name>

    .. sdc_toctree
    <api1>
    <api2>
    <api3>
    ...

    Any text (if any)

    Any text (if any)

    Another heading or subheading
    -----------------------------

    Any text (if any)
    ...

    :param fname_templ:
Parses input template rst file and outputs the final rst file
    Template document must have the following structure:
Parses input template rst file and outputs the final rst file Template document must have the following structure :
def parse_templ_rst(fname_templ):
    """
    Parses input template rst file and outputs the final rst file
    Template document must have the following structure:

    Heading or subheading
    *********************

    Any text (if any)

    Another heading or subheading
    -----------------------------

    Any text (if any)

    .. currentmodule:: <module name>

    .. sdc_toctree
    <api1>
    <api2>
    <api3>
    ...

    Any text (if any)

    Any text (if any)

    Another heading or subheading
    -----------------------------

    Any text (if any)
    ...

    :param fname_templ:
    """
    path, fname_out = os.path.split(fname_templ)
    fname_out = fname_out.replace('_templ', '')
    fname_out = fname_out.replace('_', '', 1)
    fout = open_file_for_write(APIREF_REL_PATH + fname_out)
    with open(fname_templ, 'r', 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()
                fout.write(line)
                doc.pop(0)

            if len(doc) == 0:
                return

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

            # Parsing the list of APIs
            while len(doc) > 0 and doc[0].strip() != '':
                line = doc[0]
                indent = get_indent(line)
                line = line.strip()
                full_name = current_module_name + '.' + line
                short_description = generate_simple_object_doc(full_name, short_doc_flag=True).strip()
                new_line = reindent(':ref:`', indent) + line + ' <' + full_name + '>`\n' + \
                    reindent(short_description, indent+4) + '\n'
                fout.write(new_line)
                doc.pop(0)

                full_description = generate_simple_object_doc(full_name, short_doc_flag=False)
                f = open_file_for_write(APIREF_REL_PATH + full_name + '.rst')
                f.write('.. _' + full_name + ':\n\n:orphan:\n\n')
                f.write(create_heading_str(full_name, '*') + '\n\n')
                f.write(full_description)
                f.close()

            if len(doc) == 0:
                return

    fout.close()
def parse_templ_rst ( fname_templ ) : path , fname_out = os . path . split ( fname_templ ) fname_out = fname_out . replace ( '_templ' , '' ) fname_out = fname_out . replace ( '_' , '' , 1 ) fout = open_file_for_write ( APIREF_REL_PATH + fname_out ) with open ( fname_templ , 'r' , 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 ( ) fout . write ( line ) doc . pop ( 0 ) if len ( doc ) == 0 : return doc . pop ( 0 ) # Skipping ``.. sdc_toctree`` # Parsing the list of APIs while len ( doc ) > 0 and doc [ 0 ] . strip ( ) != '' : line = doc [ 0 ] indent = get_indent ( line ) line = line . strip ( ) full_name = current_module_name + '.' + line short_description = generate_simple_object_doc ( full_name , short_doc_flag = True ) . strip ( ) new_line = reindent ( ':ref:`' , indent ) + line + ' <' + full_name + '>`\n' + reindent ( short_description , indent + 4 ) + '\n' fout . write ( new_line ) doc . pop ( 0 ) full_description = generate_simple_object_doc ( full_name , short_doc_flag = False ) f = open_file_for_write ( APIREF_REL_PATH + full_name + '.rst' ) f . write ( '.. _' + full_name + ':\n\n:orphan:\n\n' ) f . write ( create_heading_str ( full_name , '*' ) + '\n\n' ) f . write ( full_description ) f . close ( ) if len ( doc ) == 0 : return fout . close ( )