summaryrefslogtreecommitdiff
path: root/doc/_themes/odoodoc/sphinx_monkeypatch.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2014-09-02 10:51:46 +0200
committerXavier Morel <xmo@openerp.com>2014-09-03 14:53:40 +0200
commitc0373318d95c4b2c50786bcb381ff4e459a4015c (patch)
tree669d2efef51d609e739148339cf789aa8e20e158 /doc/_themes/odoodoc/sphinx_monkeypatch.py
parent6b8764c2ef561fdd559412f4ba0884019c008abb (diff)
[IMP] display sibling documents in affixed menu
Diffstat (limited to 'doc/_themes/odoodoc/sphinx_monkeypatch.py')
-rw-r--r--doc/_themes/odoodoc/sphinx_monkeypatch.py52
1 files changed, 31 insertions, 21 deletions
diff --git a/doc/_themes/odoodoc/sphinx_monkeypatch.py b/doc/_themes/odoodoc/sphinx_monkeypatch.py
index 60b8b115b66..13c3a305988 100644
--- a/doc/_themes/odoodoc/sphinx_monkeypatch.py
+++ b/doc/_themes/odoodoc/sphinx_monkeypatch.py
@@ -17,8 +17,7 @@ def patch():
if toc is None:
return None
- if main_navbar:
- navbarify(toc[0])
+ navbarify(toc[0], main_navbar=main_navbar)
return toc
@monkey(StandaloneHTMLBuilder)
@@ -26,7 +25,10 @@ def patch():
""" _get_local_toctree generates a documentation toctree for the local
document (?), called from handle_page
"""
- return old_local(self, *args, main_navbar=True, **kwargs)
+ # so can call toctree(main_navbar=False)
+ d = {'main_navbar': True}
+ d.update(kwargs)
+ return old_local(self, *args, **d)
# monkeypatch visit_table to remove border and add .table
HTMLTranslator.visit_table = visit_table
@@ -35,25 +37,33 @@ def patch():
# copy data- attributes straight from source to dest
HTMLTranslator.starttag = starttag_data
-def navbarify(node):
+def navbarify(node, main_navbar=False):
# add classes to toplevel
- node['classes'].extend(['nav', 'navbar-nav', 'navbar-right'])
- for list_item in node.children:
- # bullet_list
- # list_item
- # compact_paragraph
- # reference
- # bullet_list
- # list_item
- # compact_paragraph
- # reference
- list_item['classes'].append('dropdown')
- # list_item.compact_paragraph.reference
- link = list_item.children[0].children[0]
- link['classes'].append('dropdown-toggle')
- link.attributes['data-toggle'] = 'dropdown'
- # list_item.bullet_list
- list_item.children[1]['classes'].append('dropdown-menu')
+ if not main_navbar:
+ navify([node])
+ else:
+ node['classes'].extend(['nav', 'navbar-nav', 'navbar-right'])
+ for list_item in node.children:
+ # bullet_list
+ # list_item
+ # compact_paragraph
+ # reference
+ # bullet_list
+ # list_item
+ # compact_paragraph
+ # reference
+ list_item['classes'].append('dropdown')
+ # list_item.compact_paragraph.reference
+ link = list_item.children[0].children[0]
+ link['classes'].append('dropdown-toggle')
+ link.attributes['data-toggle'] = 'dropdown'
+ # list_item.bullet_list
+ list_item.children[1]['classes'].append('dropdown-menu')
+def navify(nodes):
+ for node in nodes:
+ if node.tagname == 'bullet_list':
+ node['classes'].append('nav')
+ navify(node.children)
def visit_table(self, node):
"""