# HG changeset patch # User Mattijs Hoitink # Date 1328538293 -3600 # Node ID 54c639244ddac879510e929e183d9c4cd2ca7f05 # Parent f97c78fac690e9e0e72257328402f2184caaf9ff Added SOURCE_LOC With both BUILD_LOC and SOURCE_LOC exposed d can be imported into other projects and configured to perform it's magic. SOURCE_LOC defaults to '.' as to not break default behaviour. diff -r f97c78fac690 -r 54c639244dda d/base.py --- a/d/base.py Sat Feb 04 14:34:42 2012 -0500 +++ b/d/base.py Mon Feb 06 15:24:53 2012 +0100 @@ -7,6 +7,7 @@ up = lambda p: j(*os.path.split(p)[:-1]) dirname = lambda p: os.path.basename(os.path.abspath(p)) +SOURCE_LOC = '.' BUILD_LOC = './build' INDEX_PRE = '''\ @@ -62,21 +63,21 @@ else: target = path - return j(BUILD_LOC, target.rsplit('.', 1)[0]) + return j(BUILD_LOC, target.rsplit(SOURCE_LOC, 1)[0]) def _get_project_title(): if os.path.isfile('title'): with open('title') as f: return f.read().strip() else: - current = dirname('.').lower() + current = dirname(SOURCE_LOC).lower() if current not in ['doc', 'docs', 'documentation']: return current else: - return dirname('..').lower() + return dirname(j(SOURCE_LOC, '..')).lower() def _find_chapters(): - for filename in os.listdir('.'): + for filename in os.listdir(SOURCE_LOC): name, ext = os.path.splitext(filename) if ext in ['.markdown', '.md', '.mdown']: if name not in ['footer', 'index']: @@ -144,7 +145,7 @@ os.makedirs(path) def _get_fallback_title(path): - title = path.split('.', 1)[0] + title = path.split(SOURCE_LOC, 1)[0] if '-' in title and all([c in '0123456789' for c in title.split('-', 1)[0]]): title = title.split('-', 1)[1]