Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: native_client_sdk/src/doc/_sphinxext/chromesite_builder.py

Issue 146203002: [NaCl SDK Docs] Remove table-of-contents from generated pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add .gitignore for .buildinfo Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/doc_generated/rest-devsite-examples.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # 5 #
6 # This is a Sphinx extension. 6 # This is a Sphinx extension.
7 # 7 #
8 8
9 from __future__ import print_function 9 from __future__ import print_function
10 import codecs 10 import codecs
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 SmartyPantsHTMLTranslator to use its quote and dash-formatting 46 SmartyPantsHTMLTranslator to use its quote and dash-formatting
47 capabilities. It's a subclass of the HTMLTranslator provided by docutils, 47 capabilities. It's a subclass of the HTMLTranslator provided by docutils,
48 with Sphinx-specific features added. Here we provide chromesite-specific 48 with Sphinx-specific features added. Here we provide chromesite-specific
49 behavior by overriding some of the visiting methods. 49 behavior by overriding some of the visiting methods.
50 """ 50 """
51 def __init__(self, builder, *args, **kwds): 51 def __init__(self, builder, *args, **kwds):
52 # HTMLTranslator is an old-style Python class, so 'super' doesn't work: use 52 # HTMLTranslator is an old-style Python class, so 'super' doesn't work: use
53 # direct parent invocation. 53 # direct parent invocation.
54 HTMLTranslator.__init__(self, builder, *args, **kwds) 54 HTMLTranslator.__init__(self, builder, *args, **kwds)
55 55
56 self.within_toc = False
57
56 def visit_bullet_list(self, node): 58 def visit_bullet_list(self, node):
57 # Use our own class attribute for <ul>. Don't care about compacted lists. 59 # Use our own class attribute for <ul>. Don't care about compacted lists.
58 self.body.append(self.starttag(node, 'ul', **{'class': 'small-gap'})) 60 self.body.append(self.starttag(node, 'ul', **{'class': 'small-gap'}))
59 61
60 def depart_bullet_list(self, node): 62 def depart_bullet_list(self, node):
61 # Override to not pop anything from context 63 # Override to not pop anything from context
62 self.body.append('</ul>\n') 64 self.body.append('</ul>\n')
63 65
64 def visit_literal(self, node): 66 def visit_literal(self, node):
65 # Don't insert "smart" quotes here 67 # Don't insert "smart" quotes here
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 pass 123 pass
122 else: 124 else:
123 HTMLTranslator.visit_reference(self, node) 125 HTMLTranslator.visit_reference(self, node)
124 126
125 def depart_reference(self, node): 127 def depart_reference(self, node):
126 if self.builder.chromesite_kill_internal_links and node.get('internal'): 128 if self.builder.chromesite_kill_internal_links and node.get('internal'):
127 pass 129 pass
128 else: 130 else:
129 HTMLTranslator.depart_reference(self, node) 131 HTMLTranslator.depart_reference(self, node)
130 132
133 def visit_topic(self, node):
134 if 'contents' in node['classes']:
135 # TODO(binji):
136 # Detect a TOC: we want to hide these from chromesite, but still keep
137 # them in devsite. An easy hack is to add display: none to the element
138 # here.
139 # When we remove devsite support, we can remove this hack.
140 self.within_toc = True
141 attrs = {'style': 'display: none'}
142 self.body.append(self.starttag(node, 'div', **attrs))
143 else:
144 HTMLTranslator.visit_topic(self, node)
145
146 def depart_topic(self, node):
147 if self.within_toc:
148 self.body.append('\n</div>')
149 else:
150 HTMLTranslator.visit_topic(self, node)
151
131 def write_colspecs(self): 152 def write_colspecs(self):
132 # Override this method from docutils to do nothing. We don't need those 153 # Override this method from docutils to do nothing. We don't need those
133 # pesky <col width=NN /> tags in our markup. 154 # pesky <col width=NN /> tags in our markup.
134 pass 155 pass
135 156
136 def visit_admonition(self, node, name=''): 157 def visit_admonition(self, node, name=''):
137 self.body.append(self.starttag(node, 'aside', CLASS=node.get('class', ''))) 158 self.body.append(self.starttag(node, 'aside', CLASS=node.get('class', '')))
138 159
139 def depart_admonition(self, node=''): 160 def depart_admonition(self, node=''):
140 self.body.append('\n</aside>\n') 161 self.body.append('\n</aside>\n')
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 from sphinx.builders import linkcheck 288 from sphinx.builders import linkcheck
268 import urllib2 289 import urllib2
269 linkcheck.HeadRequest = urllib2.Request 290 linkcheck.HeadRequest = urllib2.Request
270 291
271 app.add_directive('naclcode', NaclCodeDirective) 292 app.add_directive('naclcode', NaclCodeDirective)
272 app.add_builder(ChromesiteBuilder) 293 app.add_builder(ChromesiteBuilder)
273 294
274 # "Production mode" for local testing vs. on-server documentation. 295 # "Production mode" for local testing vs. on-server documentation.
275 app.add_config_value('chromesite_kill_internal_links', default='0', 296 app.add_config_value('chromesite_kill_internal_links', default='0',
276 rebuild='html') 297 rebuild='html')
OLDNEW
« no previous file with comments | « native_client_sdk/doc_generated/rest-devsite-examples.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698