Skip to content

Commit

Permalink
fixing search sequence to not include directory structure from os.walk()
Browse files Browse the repository at this point in the history
Change-Id: Id2763e224671c0dc75bbb00feb7318205192eae8
  • Loading branch information
heckj authored and dolph committed Nov 4, 2011
1 parent daa4930 commit bf4f0b1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions doc/generate_autodoc_index.py
Expand Up @@ -11,24 +11,29 @@

base_dir = os.path.dirname(os.path.abspath(__file__))
RSTDIR=os.path.join(base_dir, "source", "sourcecode")
SOURCE=os.path.join(base_dir, "..", "keystone")
SOURCEDIR=os.path.join(base_dir, "..")


def find_autodoc_modules():
def find_autodoc_modules(module_name, sourcedir):
"""returns a list of modules in the SOURCE directory"""
modlist = []
for root, dirs, files in os.walk(SOURCE):
os.chdir(os.path.join(sourcedir, module_name))
print "SEARCHING %s" % os.path.join(sourcedir, module_name)
for root, dirs, files in os.walk("."):
for filename in files:
if filename.endswith(".py"):
# root = ../keystone/test/unit
# root = ./keystone/test/unit
# filename = base.py
# remove the first two pieces of the root
elements = root.split(os.path.sep)[1:]
elements = root.split(os.path.sep)
# replace the leading "." with the module name
elements[0] = module_name
# and get the base module name
base, extension = os.path.splitext(filename)
if not (base == "__init__"):
elements.append(base)
modlist.append(".".join(elements))
result = (".".join(elements))
print result
modlist.append(result)
return modlist

if not(os.path.exists(RSTDIR)):
Expand All @@ -41,7 +46,7 @@ def find_autodoc_modules():
INDEXOUT.write(" :maxdepth: 1\n")
INDEXOUT.write("\n")

for module in find_autodoc_modules():
for module in find_autodoc_modules('keystone', SOURCEDIR):
generated_file = "%s/%s.rst" % (RSTDIR, module)
print "Generating %s" % generated_file

Expand Down

0 comments on commit bf4f0b1

Please sign in to comment.