diff options
-rw-r--r-- | pycco/main.py | 21 | ||||
-rw-r--r-- | pycco/utils.py | 20 |
2 files changed, 20 insertions, 21 deletions
diff --git a/pycco/main.py b/pycco/main.py index c6d9054..7e2053b 100644 --- a/pycco/main.py +++ b/pycco/main.py @@ -35,7 +35,6 @@ import sys, os sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath( __file__ ) ) ) ) - # === Main Documentation Generation Functions === def generate_documentation(source, outdir=None, preserve_paths=True): @@ -399,7 +398,7 @@ def process(sources, preserve_paths=True, outdir=None): css = open(path.join(outdir, "pycco.css"), "w") css.write(pycco_styles) css.close() - + for s in sources: dest = destination(s.save_path(), preserve_paths=preserve_paths, outdir=outdir) @@ -460,7 +459,7 @@ def monitor(sources, opts): observer.join() -from utils import * +from utils import get_all_files, Source SOURCES=[] def main(): @@ -476,26 +475,26 @@ def main(): parser.add_option('-w', '--watch', action='store_true', help='Watch original files and re-generate documentation on changes') - + parser.add_option('-a', '--all', action='store_true', help='Get all files from subfolders') - + opts, sources = parser.parse_args() - + if not sources: return - + filepath = os.path.dirname(sources[0]) start, filetype = os.path.splitext(sources[0]) - + if start.endswith('*'): return - + start = os.path.dirname(os.path.dirname(os.path.abspath(start))) - + if opts.all: sources = [i for i in get_all_files(filepath or '.', filetype)] - + global SOURCES SOURCES = sorted([Source(name, start) for name in sources]) diff --git a/pycco/utils.py b/pycco/utils.py index 287f401..82854dc 100644 --- a/pycco/utils.py +++ b/pycco/utils.py @@ -18,18 +18,18 @@ def get_all_files(path, extension): class Source: def __init__(self, name, start): - self.name = name - self.title = os.path.basename(self.name) - self.dirpath = os.path.dirname(self.name) or '.' - self.dirname = os.path.relpath(self.dirpath, start) - self.start = start + self.name = name + self.title = os.path.basename(self.name) + self.dirpath = os.path.dirname(self.name) or '.' + self.dirname = os.path.relpath(self.dirpath, start) + self.start = start def save_path(self): return "docs/%s/%s" % (self.dirname, self.title) def relative_path(self, source): html = lambda x: "%s.html" % os.path.splitext(x)[0] - rel = os.path.relpath(source.dirpath, self.dirpath) + rel = os.path.relpath(source.dirpath, self.dirpath) return "%s/%s" % (rel, html(source.title)) def __cmp__(self, other): @@ -40,16 +40,16 @@ class Source: list_ = [] dict_ = {} id_ = 1 - title = lambda s: {'title': s.title, 'url': self.relative_path(s)} + title = lambda s: {'title': s.title, 'url': self.relative_path(s)} new_dict = lambda s: {'id': id_, 'dirname': s.dirname, 'display': 'none', 'titles': [title(s)]} for source in sources: if source.dirpath != root_: if dict_: list_.append(dict_) - root_ = source.dirpath - dict_ = new_dict(source) - id_ += 1 + root_ = source.dirpath + dict_ = new_dict(source) + id_ += 1 else: dict_['titles'].append(title(source)) |