From a25091e89f51b99bdee398ea5779b28b837e231e Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sat, 20 Sep 2014 03:56:02 +0900 Subject: [PATCH] Update doc/source/conf.py * Exclude test files from source code index * Add an index to jump to sub indexes in source code index * Ensure the order of source code index by using an array rather than a dict. Change-Id: I5c28a3e29c9c0b0332732d3f598030a77536563a --- doc/source/conf.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index bf47c230f0..3eb0e9815a 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -47,6 +47,8 @@ def write_autodoc_index(): print("SEARCHING %s" % sourcedir) for root, dirs, files in os.walk("."): for filename in files: + if filename == 'tests.py': + continue if filename.endswith(".py"): # remove the pieces of the root elements = root.split(os.path.sep) @@ -62,10 +64,14 @@ def write_autodoc_index(): return modlist RSTDIR = os.path.abspath(os.path.join(BASE_DIR, "sourcecode")) - SRCS = {'horizon': ROOT, - 'openstack_dashboard': ROOT} + SRCS = [('horizon', ROOT), + ('openstack_dashboard', ROOT)] - EXCLUDED_MODULES = ('horizon.tests', 'openstack_dashboard.tests',) + EXCLUDED_MODULES = ('horizon.test', + 'openstack_dashboard.enabled', + 'openstack_dashboard.test', + 'openstack_dashboard.openstack.common', + ) CURRENT_SOURCES = {} if not(os.path.exists(RSTDIR)): @@ -73,11 +79,18 @@ def write_autodoc_index(): CURRENT_SOURCES[RSTDIR] = ['autoindex.rst'] INDEXOUT = open(os.path.join(RSTDIR, "autoindex.rst"), "w") - INDEXOUT.write("=================\n") - INDEXOUT.write("Source Code Index\n") - INDEXOUT.write("=================\n") + INDEXOUT.write(""" +================= +Source Code Index +================= - for modulename, path in SRCS.items(): +.. contents:: + :depth: 1 + :local: + +""") + + for modulename, path in SRCS: sys.stdout.write("Generating source documentation for %s\n" % modulename) INDEXOUT.write("\n%s\n" % modulename.capitalize())