Use highlight.js for syntax highlighting in Doxygen generated documentation
highlight.js is a nice Javascript library for syntax highlighting. It works with a lot of languages and have nice themes, including Solarized. This is how you can use it with Doxygen generated documentation replacing default coloring.
Download highlight.js and extract it next to your Doxygen configuration file.
Now create a custom header.html (doxygen -w html header.html
) and include this code in <head>:
<link rel="stylesheet"
href="$relpath^solarized_light.css">
<script src="$relpath^highlight.pack.js"></script>
<script>
$(function() {
$(".fragment").each(function(i,node) {
var $node = $(node);
$node.html("<pre><code class='" +
$node.attr("class")+"'>" +
$node.text()+"</code></pre>");
hljs.highlightBlock(node);
});
});
</script>
Finaly, add new options to your Doxygen configuration file:
HTML_HEADER = header.html
HTML_EXTRA_FILES = highlight.js/highlight.pack.js \
highlight.js/styles/solarized_light.css
The result, showing Doxygen generated documentation with PHP syntax coloring. Much better than a default.
Written by Goran Rakić
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#