From 77b602470c7faba83ccba004534c39c5ae46ad55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 16 Jan 2018 23:30:30 +0100 Subject: [PATCH] doxygen: ability to specify favicon. --- doc/doxygen.rst | 8 +++++++- doxygen/dox2html5.py | 9 ++++++++- doxygen/templates/base.html | 3 +++ doxygen/test/layout/Doxyfile | 1 + doxygen/test/layout/pages.html | 1 + doxygen/test/test_doxyfile.py | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/doxygen.rst b/doc/doxygen.rst index f1b9bc6e..6ccf093c 100644 --- a/doc/doxygen.rst +++ b/doc/doxygen.rst @@ -244,10 +244,13 @@ In addition, the m.css Doxygen theme recognizes the following extra options: =================================== ======================================= Variable Description =================================== ======================================= -:ini:`M_THEME_COLOR` Color for :html:``, +:ini:`M_THEME_COLOR` Color for :html:``, corresponding to the CSS style. If empty, no :html:`` tag is rendered. See `Theme selection`_ for more information. +:ini:`M_FAVICON` Favicon URL, used to populate + :html:``. If empty, no + :html:`` tag is rendered. :ini:`M_LINKS_NAVBAR1` Left navbar column links. See `Navbar links`_ for more information. :ini:`M_LINKS_NAVBAR2` Right navbar column links. See @@ -767,6 +770,9 @@ type, so either strings, booleans, or lists of strings. The exceptions are: active menu item) and :py:`sub` is a list optionally containing sub-menu items. The sub-menu items are in a similarly formed tuple, :py:`(title, url, id)`. +- The :py:`M_FAVICON` is converted to a tuple of :py:`(url, type)` where + :py:`url` is the favicon URL and :py:`type` is favicon MIME type to + populate the ``type`` attribute of :html:``. and in addition the following variables: diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 510f86fe..7d9d0a61 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -31,6 +31,7 @@ import re import html import os import glob +import mimetypes import shutil import subprocess import urllib.parse @@ -1236,6 +1237,10 @@ def postprocess_state(state: State): state.doxyfile[var] = navbar_links + # Guess MIME type of the favicon + if state.doxyfile['M_FAVICON']: + state.doxyfile['M_FAVICON'] = (state.doxyfile['M_FAVICON'], mimetypes.guess_type(state.doxyfile['M_FAVICON'])[0]) + def parse_xml(state: State, xml: str): # Reset counter for unique math formulas m.math.counter = 0 @@ -1806,6 +1811,7 @@ def parse_doxyfile(state: State, doxyfile, config = None): 'M_FILE_TREE_EXPAND_LEVELS': ['1'], 'M_EXPAND_INNER_TYPES': ['NO'], 'M_THEME_COLOR': ['#22272e'], + 'M_FAVICON': [], 'M_LINKS_NAVBAR1': ['pages', 'namespaces'], 'M_LINKS_NAVBAR2': ['annotated', 'files'], 'M_PAGE_FINE_PRINT': ['[default]'] @@ -1884,7 +1890,8 @@ def parse_doxyfile(state: State, doxyfile, config = None): 'XML_OUTPUT', 'M_PAGE_HEADER', 'M_PAGE_FINE_PRINT', - 'M_THEME_COLOR']: + 'M_THEME_COLOR', + 'M_FAVICON']: if i in config: state.doxyfile[i] = ' '.join(config[i]) # Int values that we want diff --git a/doxygen/templates/base.html b/doxygen/templates/base.html index deb57d09..46963d0a 100644 --- a/doxygen/templates/base.html +++ b/doxygen/templates/base.html @@ -6,6 +6,9 @@ {% for css in HTML_EXTRA_STYLESHEET %} {% endfor %} + {% if M_FAVICON %} + + {% endif %} {% block header_links %} {% endblock %} diff --git a/doxygen/test/layout/Doxyfile b/doxygen/test/layout/Doxyfile index cbe55152..8cc3d149 100644 --- a/doxygen/test/layout/Doxyfile +++ b/doxygen/test/layout/Doxyfile @@ -4,6 +4,7 @@ PROJECT_NAME = "A project" PROJECT_BRIEF = "is cool" M_THEME_COLOR = 00ffff +M_FAVICON = favicon.png M_PAGE_HEADER = "

A self link.

" M_PAGE_FINE_PRINT = "

Doxygen version {doxygen_version}.

" M_LINKS_NAVBAR1 = "files pages namespaces" \ diff --git a/doxygen/test/layout/pages.html b/doxygen/test/layout/pages.html index 860be687..3bd44cd3 100644 --- a/doxygen/test/layout/pages.html +++ b/doxygen/test/layout/pages.html @@ -5,6 +5,7 @@ A project is cool + diff --git a/doxygen/test/test_doxyfile.py b/doxygen/test/test_doxyfile.py index c236b368..fa8915bd 100644 --- a/doxygen/test/test_doxyfile.py +++ b/doxygen/test/test_doxyfile.py @@ -36,6 +36,7 @@ class Doxyfile(unittest.TestCase): 'HTML_OUTPUT': 'html', 'M_CLASS_TREE_EXPAND_LEVELS': 1, 'M_EXPAND_INNER_TYPES': False, + 'M_FAVICON': '', 'M_FILE_TREE_EXPAND_LEVELS': 1, 'M_LINKS_NAVBAR1': ['pages', 'namespaces'], 'M_LINKS_NAVBAR2': ['annotated', 'files'], -- 2.30.2