我想在生成的 Javadoc HTML 输出的 head 元素中包含 Google Analytics Javascript 代码。我该怎么做?
我认为我可能需要编写自定义 Doclet,但这可能会成为学习曲线的噩梦。有没有更简单的方法?
最佳答案
使用 CData
<configuration>
<!-- GA Tracking code -->
<header>
<![CDATA[
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
]]>
</header>
</configuration>
关于java - 如何在 Javadoc 中包含 Google Analytics 片段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8520337/