docs: Update to generate proper google analytics code

This commit also includes minor doxygen style improvement.

Change-Id: I5ced859c0759a2fd0240068296949067f9ac4c46
diff --git a/docs/conf.py b/docs/conf.py
index 4a4ab93..c261a1d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -32,6 +32,21 @@
     'sphinx.ext.todo',
 ]
 
+def addExtensionIfExists(extension):
+    try:
+        __import__(extension)
+        extensions.append(extension)
+    except ImportError:
+        sys.stderr.write("Extension '%s' in not available. "
+                         "Some documentation may not build correctly.\n" % extension)
+        sys.stderr.write("To install, use \n"
+                         "  sudo pip install %s\n" % extension.replace('.', '-'))
+
+addExtensionIfExists('sphinxcontrib.doxylink')
+
+if os.getenv('GOOGLE_ANALYTICS', None):
+    addExtensionIfExists('sphinxcontrib.googleanalytics')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
@@ -243,3 +258,11 @@
 
 # If true, show URL addresses after external links.
 #man_show_urls = False
+
+doxylink = {
+  'NFD' : ('NFD.tag', 'doxygen/'),
+}
+
+if os.getenv('GOOGLE_ANALYTICS', None):
+    googleanalytics_id = os.environ['GOOGLE_ANALYTICS']
+    googleanalytics_enabled = True