[IMP] doc: indexify index

* opt-in toc navification
* unhide index toctree, it's now back to a list of documents
* remove text thing
This commit is contained in:
Xavier Morel 2014-11-17 14:07:36 +01:00
parent 956bb08433
commit f302c123ea
5 changed files with 22 additions and 52 deletions

View File

@ -32,7 +32,7 @@
<div class="sphinxsidebar"> <div class="sphinxsidebar">
<div class="sphinxsidebarwrapper"> <div class="sphinxsidebarwrapper">
{{ toctree(maxdepth=4, collapse=False, includehidden=True, {{ toctree(maxdepth=4, collapse=False, includehidden=True,
main_navbar=False, titles_only=False) }} navbar='side', titles_only=False) }}
{% if github_link %} {% if github_link %}
<p><a href="{{ github_link(mode='edit') }}" class="github"> <p><a href="{{ github_link(mode='edit') }}" class="github">
Edit on GitHub Edit on GitHub
@ -72,7 +72,8 @@
{% endif %} {% endif %}
</div> </div>
<nav class="collapse navbar-collapse navbar-main" role="navigation"> <nav class="collapse navbar-collapse navbar-main" role="navigation">
{{ toctree(titles_only=True, maxdepth=2, includehidden=True, collapse=False) }} {{ toctree(titles_only=True, maxdepth=2, includehidden=True,
collapse=False, navbar='main') }}
</nav> </nav>
</div> </div>
</header> </header>

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sphinx.roles import sphinx.roles
import sphinx.environment import sphinx.environment
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.writers.html import HTMLTranslator from sphinx.writers.html import HTMLTranslator
from docutils.writers.html4css1 import HTMLTranslator as DocutilsTranslator from docutils.writers.html4css1 import HTMLTranslator as DocutilsTranslator
@ -9,27 +8,17 @@ def patch():
# navify toctree (oh god) # navify toctree (oh god)
@monkey(sphinx.environment.BuildEnvironment) @monkey(sphinx.environment.BuildEnvironment)
def resolve_toctree(old_resolve, self, *args, **kwargs): def resolve_toctree(old_resolve, self, *args, **kwargs):
""" If main_navbar, bootstrapify TOC to yield a navbar """ If navbar, bootstrapify TOC to yield a navbar
""" """
main_navbar = kwargs.pop('main_navbar', False) navbar = kwargs.pop('navbar', None)
toc = old_resolve(self, *args, **kwargs) toc = old_resolve(self, *args, **kwargs)
if toc is None: if toc is None:
return None return None
navbarify(toc[0], main_navbar=main_navbar) navbarify(toc[0], navbar=navbar)
return toc return toc
@monkey(StandaloneHTMLBuilder)
def _get_local_toctree(old_local, self, *args, **kwargs):
""" _get_local_toctree generates a documentation toctree for the local
document (?), called from handle_page
"""
# 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 # monkeypatch visit_table to remove border and add .table
HTMLTranslator.visit_table = visit_table HTMLTranslator.visit_table = visit_table
# disable colspec crap # disable colspec crap
@ -37,11 +26,18 @@ def patch():
# copy data- attributes straight from source to dest # copy data- attributes straight from source to dest
HTMLTranslator.starttag = starttag_data HTMLTranslator.starttag = starttag_data
def navbarify(node, main_navbar=False): def navbarify(node, navbar=None):
# add classes to toplevel """
if not main_navbar: :param node: toctree node to navbarify
navify([node]) :param navbar: Whether this toctree is a 'main' navbar, a 'side' navbar or
else: not a navbar at all
"""
if navbar == 'side':
for n in node.traverse():
if n.tagname == 'bullet_list':
n['classes'].append('nav')
elif navbar == 'main':
# add classes to just toplevel
node['classes'].extend(['nav', 'navbar-nav', 'navbar-right']) node['classes'].extend(['nav', 'navbar-nav', 'navbar-right'])
for list_item in node.children: for list_item in node.children:
# bullet_list # bullet_list
@ -59,11 +55,6 @@ def navbarify(node, main_navbar=False):
link.attributes['data-toggle'] = 'dropdown' link.attributes['data-toggle'] = 'dropdown'
# list_item.bullet_list # list_item.bullet_list
list_item.children[1]['classes'].append('dropdown-menu') 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): def visit_table(self, node):
""" """

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -4,34 +4,12 @@ odoo developer documentation
Welcome to the Odoo developer documentation. Welcome to the Odoo developer documentation.
This documentation is incomplete and may contain errors, if you wish to
contribute, every page should have a :guilabel:`View on Github` link:
.. image:: images/view-on-github.*
:align: center
Through this link you can edit documents and submit changes for review using
`github's web interface
<https://help.github.com/articles/editing-files-in-your-repository/>`_.
Contributions are welcome and appreciated.
.. todo:: what's the documentation's license? .. todo:: what's the documentation's license?
The documentation is currently organized in four sections: .. titlesonly breaks level 3 (~in-document) toc of left navbar, so use
maxdepth instead
* :doc:`tutorials`, aimed at introducing the primary areas of developing Odoo
modules
* :doc:`reference`, which ought be the complete and canonical documentation
for Odoo subsystems
* :doc:`modules`, documenting useful specialized modules and integration
methods (and currently empty)
.. hidden toctree w/o titlesonly otherwise the titlesonly "sticks" to
in-document toctrees and we can't have a toctree showing both "sibling"
pages and current document sections
.. toctree:: .. toctree::
:hidden: :maxdepth: 2
tutorials tutorials
reference reference

View File

@ -71,7 +71,7 @@ Scaffolding is available via the :command:`odoo.py scaffold` subcommand.
.. option:: -t <template> .. option:: -t <template>
a template directory, files are passed through jinja2_ then copied to a template directory, files are passed through jinja2_ then copied to
the :option:`destination` directory the ``destination`` directory
.. option:: name .. option:: name