Commits

Mattijs Hoitink committed 54c6392

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.

Comments (0)

Files changed (1)

 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 = '''\
 <!DOCTYPE html>
     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']:
         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]