3
import docutils.core as dc
5
from writer import writer
11
if len(sys.argv) != 3:
12
print "Usage: build_paper.py paper_directory target_directory"
15
in_path, out_path = sys.argv[1:]
16
for p in (in_path, out_path):
17
if not os.path.isdir(p):
18
print("Cannot open directory: %s" % p)
21
print "Building:", in_path
23
paper_id = os.path.basename(out_path)
26
% These preamble commands are from build_paper.py
30
\usepackage[scaled=.90]{helvet}
33
% Make verbatim environment smaller
35
\g@addto@macro\@verbatim\footnotesize
38
% Do not indent code sections
39
\renewcommand{\quote}{}
41
% Provide AMS mathematical commands such as "align"
46
% Define colours for hyperref
49
\definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
50
\definecolor{darkorange}{rgb}{.71,0.21,0.01}
51
\definecolor{darkblue}{rgb}{.01,0.21,0.71}
52
\definecolor{darkgreen}{rgb}{.1,.52,.09}
55
\hypersetup{pdftex, % needed for pdflatex
56
breaklinks=true, % so long urls are correctly broken across lines
63
% Include graphics for authors who raw-inlined figures
64
% (then docutils won't automatically add the package)
67
\ifthenelse{\isundefined{\longtable}}{}{
68
\renewenvironment{longtable}{\begin{center}\begin{tabular}}%
69
{\end{tabular}\end{center}\vspace{2mm}}
72
% Packages required for code highlighting
77
# Add the LaTeX commands required by Pygments to do syntax highlighting
83
warnings.warn(RuntimeWarning('Could not import Pygments. '
84
'Syntax highlighting will fail.'))
88
from pygments.formatters import LatexFormatter
89
from sphinx_highlight import SphinxStyle
91
preamble += LatexFormatter(style=SphinxStyle).get_style_defs()
94
settings = {'documentclass': 'IEEEtran',
95
'use_verbatim_when_possible': True,
96
'use_latex_citations': True,
97
'latex_preamble': preamble,
98
'documentoptions': 'letterpaper,compsoc,twoside'}
102
rst, = glob.glob(os.path.join(in_path, '*.rst'))
104
raise RuntimeError("Found more than one input .rst--not sure which one to use.")
106
content = open(rst, 'r').read()
114
\input{page_numbers.tex}
115
\newcommand*{\docutilsroleref}{\ref}
116
\newcommand*{\docutilsrolelabel}{\label}
120
tex = dc.publish_string(source=content, writer=writer,
121
settings_overrides=settings)
123
out = open(os.path.join(out_path, 'paper.tex'), 'w')
127
page_nr_f = os.path.join(out_path, 'page_numbers.tex')
128
if not os.path.exists(page_nr_f):
129
out = open(page_nr_f, 'w')