summaryrefslogtreecommitdiffstats
path: root/native_client_sdk/src/doc/_sphinxext/chromesite_builder.py
diff options
context:
space:
mode:
Diffstat (limited to 'native_client_sdk/src/doc/_sphinxext/chromesite_builder.py')
-rw-r--r--native_client_sdk/src/doc/_sphinxext/chromesite_builder.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/native_client_sdk/src/doc/_sphinxext/chromesite_builder.py b/native_client_sdk/src/doc/_sphinxext/chromesite_builder.py
index 4b3cac3..5a54369 100644
--- a/native_client_sdk/src/doc/_sphinxext/chromesite_builder.py
+++ b/native_client_sdk/src/doc/_sphinxext/chromesite_builder.py
@@ -53,6 +53,8 @@ class ChromesiteHTMLTranslator(HTMLTranslator):
# direct parent invocation.
HTMLTranslator.__init__(self, builder, *args, **kwds)
+ self.within_toc = False
+
def visit_bullet_list(self, node):
# Use our own class attribute for <ul>. Don't care about compacted lists.
self.body.append(self.starttag(node, 'ul', **{'class': 'small-gap'}))
@@ -128,6 +130,25 @@ class ChromesiteHTMLTranslator(HTMLTranslator):
else:
HTMLTranslator.depart_reference(self, node)
+ def visit_topic(self, node):
+ if 'contents' in node['classes']:
+ # TODO(binji):
+ # Detect a TOC: we want to hide these from chromesite, but still keep
+ # them in devsite. An easy hack is to add display: none to the element
+ # here.
+ # When we remove devsite support, we can remove this hack.
+ self.within_toc = True
+ attrs = {'style': 'display: none'}
+ self.body.append(self.starttag(node, 'div', **attrs))
+ else:
+ HTMLTranslator.visit_topic(self, node)
+
+ def depart_topic(self, node):
+ if self.within_toc:
+ self.body.append('\n</div>')
+ else:
+ HTMLTranslator.visit_topic(self, node)
+
def write_colspecs(self):
# Override this method from docutils to do nothing. We don't need those
# pesky <col width=NN /> tags in our markup.