diff options
-rwxr-xr-x | make_guides.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/make_guides.py b/make_guides.py index 42ce90b..d55d8e5 100755 --- a/make_guides.py +++ b/make_guides.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import argparse, os -#import docutils +import docutils.core def basename(fname): '''Returns the name of the guide from either its name or its directory''' @@ -42,11 +42,31 @@ def build_latex(guide): if not rebuild: return None # Build the LaTeX source - # DEBUG - print('Building LaTeX...') + s_files = [] + for dirpath, dirnames, filenames in os.walk(src_dir): + s_files += [os.path.join(dirpath,fn) + for fn in filenames + if fn.endswith(('.txt','.rst'))] + s_files.sort() + source = "" + for fname in s_files: + fp = open(fname,'rt') + try: + source += fp.read() + except IOError: + pass + finally: + fp.close() if not os.path.isdir(build_dir): os.mkdir(build_dir) - fp = open(os.path.join(build_dir,tex_name),'w') + fp = open(os.path.join(build_dir,tex_name),'wt') + fp.write(docutils.core.publish_string(source, + writer_name='latex', + settings_overrides={'language': 'it', + 'documentoptions': 'a6paper,twoside', + 'stylesheet': 'lmodern', + 'hyperlink-color': '0', + 'output_encoding': 'unicode'})) fp.close() def build_pdf(guide): |