Change epydoc's favicon - how to?

72 Views Asked by At

Everything is in the question : How would I do to change epydoc's generated html pages favicon ?

Note : I saw how to customize the css content, but nothing about customizing output html files...

Many thanks.

1

There are 1 best solutions below

1
Gauthier Boaglio On

Ok, so after a littel brainstorming (with myself), I found a way :

Since we can inject some html using --navlink option to epydoc (initially designed to customize project's link in the navigation bar), I used a javascript trick to add the following dynamically in the tag of the document.

Here is the javascript code :

var link = parent.document.createElement('link'); 
link.id = 'dynamic-favicon'; 
link.type = 'image/png'; 
link.rel = 'shortcut icon'; 
link.href = '../logo-fav.png'; parent.document.head.appendChild(link);
parent.document.head = parent.document.head || 
                           parent.document.getElementsByTagName('head')[0];

And here is the full epydoc command line :

epydoc -v --name "My Project" -o ./html \
--css epydoc.css --url http://www.my-project.org --inheritance listed \
--graph all --no-private --docformat epytext \
    --navlink "<a href=\"http://www.my-project.org\"><img src=\"../logo.png\" style=\"margin:10px;\" /></a>
        <script>
            var link = parent.document.createElement('link'); 
            link.id = 'dynamic-favicon'; 
            link.type = 'image/png'; 
            link.rel = 'shortcut icon'; 
            link.href = '../logo-fav.png'; 
            parent.document.head.appendChild(link); 
            parent.document.head = parent.document.head || parent.document.getElementsByTagName('head')[0];
        </script>
        " \
    my_py_module

This can be used to customize the whole documentation, but is still hacky. Still strange that their is no way to use some templates in such a mature tool like epydoc...