nbcollection/converter.py
def make_html_index(self, template_file, output_filename='index.html'):
        """
        Generates an html index page for a set of notebooks

        Parameters
        ----------
        converted_files : list
            The list of paths to the notebooks
        template_file : str
            A path to the template file to be used for generating the index. The
            template should be in jinja2 format and have a loop over
            ``notebook_html_paths`` to populate with the links
        output_filename : str or None
            the output file name, or None to not write the file

        Returns
        -------
        content : str
            The content of the index file
        """

        if isinstance(template_file, str):
            # Load jinja2 template for index page:
            path, fn = os.path.split(template_file)
            env = jinja2.Environment(
                loader=jinja2.FileSystemLoader(path),
                autoescape=jinja2.select_autoescape(['html', 'xml']))
            templ = env.get_template(fn)

        elif isinstance(template_file, jinja2.Template):
            templ = template_file

        else:
            raise TypeError("Unknown template file type "
                            f"'{type(template_file)}'. Must be either a string "
                            "path or a jinja2 template instance.")

        out_path = os.path.dirname(output_filename)
        if out_path == '':
            # By default, write the index file to the _build/ path
            out_path = self.build_path

        notebook_metadata = []
        for nb in self.notebooks:
            relpath = os.path.relpath(nb.html_path, out_path)

            notebook_metadata.append({
                'html_path': relpath,
                'name': get_title(nb.exec_path)
            })

        content = templ.render(notebooks=notebook_metadata)
        with open(os.path.join(out_path, output_filename), 'w') as f:
            f.write(content)

        return content

        Generates an html index page for a set of notebooks

        Parameters
        ----------
        converted_files : list
            The list of paths to the notebooks
        template_file : str
            A path to the template file to be used for generating the index. The
            template should be in jinja2 format and have a loop over
            ``notebook_html_paths`` to populate with the links
        output_filename : str or None
            the output file name, or None to not write the file

        Returns
        -------
        content : str
            The content of the index file
        
Generates an html index page for a set of notebooks
Parameters

converted_files : list
The list of paths to the notebooks
template_file : str
A path to the template file to be used for generating the index. The
template should be in jinja2 format and have a loop over
``notebook_html_paths`` to populate with the links
output_filename : str or None
the output file name, or None to not write the file

Returns

content : str
The content of the index file
Generates an html index page for a set of notebooks Parameters converted_files : list The list of paths to the notebooks template_file : str A path to the template file to be used for generating the index . The template should be in jinja2 format and have a loop over ` ` notebook_html_paths ` ` to populate with the links output_filename : str or None the output file name or None to not write the file Returns content : str The content of the index file
def make_html_index(self, template_file, output_filename='index.html'):
        if isinstance(template_file, str):
            path, fn = os.path.split(template_file)
            env = jinja2.Environment(
                loader=jinja2.FileSystemLoader(path),
                autoescape=jinja2.select_autoescape(['html', 'xml']))
            templ = env.get_template(fn)
        elif isinstance(template_file, jinja2.Template):
            templ = template_file
        else:
            raise TypeError("Unknown template file type "
                            f"'{type(template_file)}'. Must be either a string "
                            "path or a jinja2 template instance.")
        out_path = os.path.dirname(output_filename)
        if out_path == '':
            out_path = self.build_path
        notebook_metadata = []
        for nb in self.notebooks:
            relpath = os.path.relpath(nb.html_path, out_path)
            notebook_metadata.append({
                'html_path': relpath,
                'name': get_title(nb.exec_path)
            })
        content = templ.render(notebooks=notebook_metadata)
        with open(os.path.join(out_path, output_filename), 'w') as f:
            f.write(content)
        return content
def make_html_index ( self , template_file , output_filename = 'index.html' ) : if isinstance ( template_file , str ) : path , fn = os . path . split ( template_file ) env = jinja2 . Environment ( loader = jinja2 . FileSystemLoader ( path ) , autoescape = jinja2 . select_autoescape ( [ 'html' , 'xml' ] ) ) templ = env . get_template ( fn ) elif isinstance ( template_file , jinja2 . Template ) : templ = template_file else : raise TypeError ( "Unknown template file type " f"'{type(template_file)}'. Must be either a string " "path or a jinja2 template instance." ) out_path = os . path . dirname ( output_filename ) if out_path == '' : out_path = self . build_path notebook_metadata = [ ] for nb in self . notebooks : relpath = os . path . relpath ( nb . html_path , out_path ) notebook_metadata . append ( { 'html_path' : relpath , 'name' : get_title ( nb . exec_path ) } ) content = templ . render ( notebooks = notebook_metadata ) with open ( os . path . join ( out_path , output_filename ) , 'w' ) as f : f . write ( content ) return content
Generates an html index page for a set of notebooks
Parameters
Generates an html index page for a set of notebooks Parameters
"""
        Generates an html index page for a set of notebooks

        Parameters
        ----------
        converted_files : list
            The list of paths to the notebooks
        template_file : str
            A path to the template file to be used for generating the index. The
            template should be in jinja2 format and have a loop over
            ``notebook_html_paths`` to populate with the links
        output_filename : str or None
            the output file name, or None to not write the file

        Returns
        -------
        content : str
            The content of the index file
        """ # Load jinja2 template for index page: # By default, write the index file to the _build/ path
self
template_file
output_filename