[IMP] doc: indexify index
authorXavier Morel <xmo@openerp.com>
Mon, 17 Nov 2014 13:07:36 +0000 (14:07 +0100)
committerXavier Morel <xmo@openerp.com>
Mon, 17 Nov 2014 13:07:36 +0000 (14:07 +0100)
* opt-in toc navification
* unhide index toctree, it's now back to a list of documents
* remove text thing

doc/_themes/odoodoc/layout.html
doc/_themes/odoodoc/sphinx_monkeypatch.py
doc/images/view-on-github.png [deleted file]
doc/index.rst
doc/reference/cmdline.rst

index 7685d8a..1a68d31 100644 (file)
@@ -32,7 +32,7 @@
   <div class="sphinxsidebar">
     <div class="sphinxsidebarwrapper">
       {{ toctree(maxdepth=4, collapse=False, includehidden=True,
-                 main_navbar=False, titles_only=False) }}
+                 navbar='side', titles_only=False) }}
       {% if github_link %}
         <p><a href="{{ github_link(mode='edit') }}" class="github">
           Edit on GitHub
@@ -72,7 +72,8 @@
       {% endif %}
     </div>
     <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>
   </div>
 </header>
index 13c3a30..94e063e 100644 (file)
@@ -1,7 +1,6 @@
 # -*- coding: utf-8 -*-
 import sphinx.roles
 import sphinx.environment
-from sphinx.builders.html import StandaloneHTMLBuilder
 from sphinx.writers.html import HTMLTranslator
 from docutils.writers.html4css1 import HTMLTranslator as DocutilsTranslator
 
@@ -9,27 +8,17 @@ def patch():
     # navify toctree (oh god)
     @monkey(sphinx.environment.BuildEnvironment)
     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)
         if toc is None:
             return None
 
-        navbarify(toc[0], main_navbar=main_navbar)
+        navbarify(toc[0], navbar=navbar)
         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
     HTMLTranslator.visit_table = visit_table
     # disable colspec crap
@@ -37,11 +26,18 @@ def patch():
     # copy data- attributes straight from source to dest
     HTMLTranslator.starttag = starttag_data
 
-def navbarify(node, main_navbar=False):
-    # add classes to toplevel
-    if not main_navbar:
-        navify([node])
-    else:
+def navbarify(node, navbar=None):
+    """
+    :param node: toctree node to navbarify
+    :param navbar: Whether this toctree is a 'main' navbar, a 'side' navbar or
+                   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'])
         for list_item in node.children:
             # bullet_list
@@ -59,11 +55,6 @@ def navbarify(node, main_navbar=False):
             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):
     """
diff --git a/doc/images/view-on-github.png b/doc/images/view-on-github.png
deleted file mode 100644 (file)
index 65a8d42..0000000
Binary files a/doc/images/view-on-github.png and /dev/null differ
index 3c16960..0cd25cd 100644 (file)
@@ -4,34 +4,12 @@ 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?
 
-The documentation is currently organized in four sections:
-
-* :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
-
+.. titlesonly breaks level 3 (~in-document) toc of left navbar, so use
+   maxdepth instead
 .. toctree::
-    :hidden:
+    :maxdepth: 2
 
     tutorials
     reference
index 32c1ef4..1ec7d96 100644 (file)
@@ -71,7 +71,7 @@ Scaffolding is available via the :command:`odoo.py scaffold` subcommand.
 .. option:: -t <template>
 
     a template directory, files are passed through jinja2_ then copied to
-    the :option:`destination` directory
+    the ``destination`` directory
 
 .. option:: name