In fact the code is already in epydoc documentation but nowhere in the sources, even in the SVN repository ! I wrote this patch myself, using the code I found in the documentation.
To use it, you have to specify your google analytics Id like this :
epydoc --google-analytics "UA-XXXXXXXX-X" ...You can download the .patch file at the end.
diff -ru epydoc.orig/cli.py epydoc/cli.py
--- epydoc.orig/cli.py 2008-01-29 14:21:23.000000000 +0100
+++ epydoc/cli.py 2011-08-22 13:30:24.282587800 +0200
@@ -292,6 +292,11 @@
help=("Include values in the details lists even if all info "
"about them is already provided by the summary table."))
+ # ASX
+ generation_group.add_option('--google-analytics',
+ action='store', dest='google_analytics',
+ help="Tracker code for google analytics (eg UA-427085-11).")
+
output_group = OptionGroup(optparser, 'Output Options')
optparser.add_option_group(output_group)
diff -ru epydoc.orig/docwriter/html.py epydoc/docwriter/html.py
--- epydoc.orig/docwriter/html.py 2009-02-24 16:21:57.000000000 +0100
+++ epydoc/docwriter/html.py 2011-08-22 13:18:35.280492448 +0200
@@ -370,6 +370,10 @@
"""If true, then include objects in the details list even if all
info about them is already provided by the summary table."""
+ # ASX
+ self._google_analytics = kwargs.get('google_analytics', None)
+ """A tracker code for google analytics; or None"""
+
# For use with select_variables():
if self._show_private:
self._public_filter = None
@@ -1793,6 +1797,23 @@
checkCookie();
// -->
</script>
+ >>> # ASX
+ >>> if self._google_analytics:
+ <!-- Begin google analytics tracking code -->
+ <script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ?
+ "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost +
+ "google-analytics.com/ga.js' " +
+ "type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript">
+ var pageTracker = _gat._getTracker("$self._google_analytics$");
+ pageTracker._initData();
+ pageTracker._trackPageview();
+ </script>
+ <!-- End google analytics tracking code -->
+ >>> #endif
</body>
</html>
''')
Add new comment