chiark / gitweb /
doxygen: ability to specify favicon.
authorVladimír Vondruš <mosra@centrum.cz>
Tue, 16 Jan 2018 22:30:30 +0000 (23:30 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 17 Jan 2018 00:46:31 +0000 (01:46 +0100)
doc/doxygen.rst
doxygen/dox2html5.py
doxygen/templates/base.html
doxygen/test/layout/Doxyfile
doxygen/test/layout/pages.html
doxygen/test/test_doxyfile.py

index f1b9bc6e231319dd0b5d88e1b96aef18e59a6b10..6ccf093cb88ee4d24621a143aaa0b4f8e04c1ff7 100644 (file)
@@ -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:`<meta name="theme-color"/>`,
+:ini:`M_THEME_COLOR`                Color for :html:`<meta name="theme-color" />`,
                                     corresponding to the CSS style. If empty,
                                     no :html:`<meta>` tag is rendered. See
                                     `Theme selection`_ for more information.
+:ini:`M_FAVICON`                    Favicon URL, used to populate
+                                    :html:`<link rel="icon" />`. If empty, no
+                                    :html:`<link>` 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:`<link rel="favicon" />`.
 
  and in addition the following variables:
 
index 510f86fe3f60d17c5d7749c73cf9f9f18dae1cd6..7d9d0a61c620e45a138b0491889637eeae81dc36 100755 (executable)
@@ -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
index deb57d09fc4fad4c5138a66a72c252e0710a1ed5..46963d0afbfbd7b05ccad404889722d72c8feb5f 100644 (file)
@@ -6,6 +6,9 @@
   {% for css in HTML_EXTRA_STYLESHEET %}
   <link rel="stylesheet" href="{{ css|basename_or_url|e }}" />
   {% endfor %}
+  {% if M_FAVICON %}
+  <link rel="icon" href="{{ M_FAVICON[0] }}" type="{{ M_FAVICON[1] }}" />
+  {% endif %}
   {% block header_links %}
   {% endblock %}
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
index cbe5515256a1fe9a78be53865200fcd099f90163..8cc3d14932570aa28628cd7afa8ba844949f6a00 100644 (file)
@@ -4,6 +4,7 @@ PROJECT_NAME = "A project"
 PROJECT_BRIEF = "is cool"
 
 M_THEME_COLOR = 00ffff
+M_FAVICON = favicon.png
 M_PAGE_HEADER = "<p><a href=\"{filename}\">A self link</a>.</p>"
 M_PAGE_FINE_PRINT = "<p><a href=\"http://doxygen.org\">Doxygen</a> version {doxygen_version}.</p>"
 M_LINKS_NAVBAR1 = "files pages namespaces" \
index 860be68750e4356062d426c2088864845579e443..3bd44cd3a072383b77fc0a3cea67f6fafd793696 100644 (file)
@@ -5,6 +5,7 @@
   <title>A project is cool</title>
   <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
   <link rel="stylesheet" href="m-dark+doxygen.compiled.css" />
+  <link rel="icon" href="favicon.png" type="image/png" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <meta name="theme-color" content="00ffff" />
 </head>
index c236b3684701d0e76324b080e45af780962bca9f..fa8915bd0e5f892da41d26bfd26a57acee6e6a32 100644 (file)
@@ -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'],