Chris McDonough
2010-07-04 4dc529e4bbc36b7e5e2bd3ea199a7929e407a267
commit | author | age
f70c23 1 # -*- coding: utf-8 -*-
CM 2 #
3 # repoze.bfg documentation build configuration file, created by
4 # sphinx-quickstart on Wed Jul 16 13:18:14 2008.
5 #
6 # This file is execfile()d with the current directory set to its containing dir.
7 #
8 # The contents of this file are pickled, so don't put values in the namespace
9 # that aren't pickleable (module imports are okay, they're removed automatically).
10 #
11 # All configuration values have a default value; values that are commented out
12 # serve to show the default value.
13
14 import sys, os
15
6cdedf 16 # skip raw nodes
CM 17 from sphinx.writers.text import TextTranslator
18 from docutils import nodes
19 def raw(*arg):
20     raise nodes.SkipNode
21 TextTranslator.visit_raw = raw
22
d22e8d 23 book = os.environ.get('BOOK')
274778 24
f70c23 25 # If your extensions are in another directory, add it here. If the directory
CM 26 # is relative to the documentation root, use os.path.abspath to make it
27 # absolute, like shown here.
9974be 28 parent = os.path.dirname(os.path.dirname(__file__))
CM 29 sys.path.append(os.path.abspath(parent))
30 wd = os.getcwd()
31 os.chdir(parent)
32 os.system('%s setup.py test -q' % sys.executable)
33 os.chdir(wd)
34
35 for item in os.listdir(parent):
36     if item.endswith('.egg'):
37         sys.path.append(os.path.join(parent, item))
f70c23 38
CM 39 # General configuration
40 # ---------------------
41
42 # Add any Sphinx extension module names here, as strings. They can be extensions
43 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
44 extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
45
46 # Add any paths that contain templates here, relative to this directory.
47 templates_path = ['.templates']
48
49 # The suffix of source filenames.
50 source_suffix = '.rst'
51
52 # The master toctree document.
53 master_doc = 'index'
54
55 # General substitutions.
878328 56 project = 'The repoze.bfg Web Application Framework'
67bfd8 57 copyright = '2008-2010, Agendaless Consulting'
f70c23 58
CM 59 # The default replacements for |version| and |release|, also used in various
60 # other places throughout the built documents.
61 #
62 # The short X.Y version.
4dc529 63 version = '1.3a4'
f70c23 64 # The full version, including alpha/beta/rc tags.
c0114e 65 release = version
f70c23 66
CM 67 # There are two options for replacing |today|: either, you set today to some
68 # non-false value, then it is used:
69 #today = ''
70 # Else, today_fmt is used as the format for a strftime call.
71 today_fmt = '%B %d, %Y'
72
73 # List of documents that shouldn't be included in the build.
74 #unused_docs = []
75
76 # List of directories, relative to source directories, that shouldn't be searched
77 # for source files.
78 #exclude_dirs = []
79
80 # The reST default role (used for this markup: `text`) to use for all documents.
81 #default_role = None
82
83 # If true, '()' will be appended to :func: etc. cross-reference text.
84 #add_function_parentheses = True
85
86 # If true, the current module name will be prepended to all description
87 # unit titles (such as .. function::).
e4e3aa 88 add_module_names = False
f70c23 89
CM 90 # If true, sectionauthor and moduleauthor directives will be shown in the
91 # output. They are ignored by default.
92 #show_authors = False
93
94 # The name of the Pygments (syntax highlighting) style to use.
274778 95 pygments_style = book and 'bw' or 'sphinx'
f70c23 96
CM 97 # Options for HTML output
98 # -----------------------
99
100 # The style sheet to use for HTML and HTML Help pages. A file of that name
101 # must exist either in Sphinx' static/ path, or in one of the custom paths
102 # given in html_static_path.
edf621 103 html_style = 'repoze.css'
f70c23 104
CM 105 # The name for this set of Sphinx documents.  If None, it defaults to
106 # "<project> v<release> documentation".
878328 107 #html_title = 'The repoze.bfg Web Application Framework v%release%'
f70c23 108
CM 109 # A shorter title for the navigation bar.  Default is the same as html_title.
110 #html_short_title = None
111
112 # The name of an image file (within the static path) to place at the top of
113 # the sidebar.
67bfd8 114 html_logo = '.static/logo_hi.png'
f70c23 115
CM 116 # The name of an image file (within the static path) to use as favicon of the
117 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
118 # pixels large.
119 #html_favicon = None
120
121 # Add any paths that contain custom static files (such as style sheets) here,
122 # relative to this directory. They are copied after the builtin static files,
123 # so a file named "default.css" will overwrite the builtin "default.css".
124 html_static_path = ['.static']
125
126 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
127 # using the given strftime format.
128 html_last_updated_fmt = '%b %d, %Y'
129
130 # If true, SmartyPants will be used to convert quotes and dashes to
131 # typographically correct entities.
132 #html_use_smartypants = True
133
134 # Custom sidebar templates, maps document names to template names.
135 #html_sidebars = {}
136
137 # Additional templates that should be rendered to pages, maps page names to
138 # template names.
139 #html_additional_pages = {}
140
141 # If false, no module index is generated.
142 #html_use_modindex = True
143
144 # If false, no index is generated.
145 #html_use_index = True
146
147 # If true, the index is split into individual pages for each letter.
148 #html_split_index = False
149
150 # If true, the reST sources are included in the HTML build as _sources/<name>.
151 #html_copy_source = True
152
153 # If true, an OpenSearch description file will be output, and all pages will
154 # contain a <link> tag referring to it.  The value of this option must be the
155 # base URL from which the finished HTML is served.
156 #html_use_opensearch = ''
157
158 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
159 #html_file_suffix = ''
160
161 # Output file base name for HTML help builder.
878328 162 htmlhelp_basename = 'repozebfg'
f70c23 163
CM 164 # Options for LaTeX output
165 # ------------------------
166
167 # The paper size ('letter' or 'a4').
67bfd8 168 latex_paper_size = 'letter'
f70c23 169
CM 170 # The font size ('10pt', '11pt' or '12pt').
67bfd8 171 latex_font_size = '10pt'
f70c23 172
CM 173 # Grouping the document tree into LaTeX files. List of tuples
174 # (source start file, target name, title, author, document class [howto/manual]).
175 latex_documents = [
878328 176   ('latexindex', 'repozebfg.tex', 'The repoze.bfg Web Application Framework',
8be78e 177    'Chris McDonough', 'manual'),
CM 178     ]
f70c23 179
CM 180 # The name of an image file (relative to this directory) to place at the top of
181 # the title page.
67bfd8 182 latex_logo = '.static/logo_hi.png'
f70c23 183
CM 184 # For "manual" documents, if this is true, then toplevel headings are parts,
185 # not chapters.
67bfd8 186 latex_use_parts = True
f70c23 187
CM 188 # Additional stuff for the LaTeX preamble.
189 #latex_preamble = ''
190
191 # Documents to append as an appendix to all manuals.
192 #latex_appendices = []
193
194 # If false, no module index is generated.
7a3985 195 latex_use_modindex = False
125e97 196
CM 197 ## Say, for a moment that you have a twoside document that needs a 3cm
198 ## inner margin to allow for binding and at least two centimetres the
199 ## rest of the way around. You've been using the a4wide package up until
200 ## now, because you like the amount of text it places on the
201 ## page. Perhaps try something like this in your preamble:
202
203 ## \usepackage[bindingoffset=1cm,textheight=22cm,hdivide={2cm,*,2cm},vdivide={*,22cm,*}]{geometry}
204
f2086c 205 ## _PREAMBLE = r"""\usepackage[bindingoffset=0.45in,textheight=7.25in,hdivide={0.5in,*,0.75in},vdivide={1in,7.25in,1in},papersize={7.5in,9.25in}]{geometry}"""
125e97 206
f2086c 207 _PREAMBLE = r"""
CM 208 \usepackage[]{geometry}
209 \geometry{bindingoffset=0.45in,textheight=7.25in,hdivide={0.5in,*,0.75in},vdivide={1in,7.25in,1in},papersize={7.5in,9.25in}}
210 \hypersetup{
211     colorlinks=true,
212     linkcolor=black,
213     citecolor=black,
214     filecolor=black,
215     urlcolor=black
216 }
274778 217 \fvset{frame=single,xleftmargin=9pt,numbersep=4pt}
f2086c 218
CM 219 \pagestyle{fancy}
220
9ec2d6 221 % header and footer styles
f2086c 222 \renewcommand{\chaptermark}[1]%
9ec2d6 223   {\markboth{\MakeUppercase{\thechapter.\ #1}}{}
CM 224   }
f2086c 225 \renewcommand{\sectionmark}[1]%
9ec2d6 226   {\markright{\MakeUppercase{\thesection.\ #1}}
CM 227   }
228
229 % defaults for fancy style
230 \renewcommand{\headrulewidth}{0pt}
f2086c 231 \renewcommand{\footrulewidth}{0pt}
CM 232 \fancyhf{}
233 \fancyfoot[C]{\thepage}
234
9ec2d6 235 % plain style
f2086c 236 \fancypagestyle{plain}{
CM 237   \renewcommand{\headrulewidth}{0pt} % ho header line
9ec2d6 238   \renewcommand{\footrulewidth}{0pt}% no footer line
CM 239   \fancyhf{} % empty header and footer
240   \fancyfoot[C]{\thepage}
f2086c 241 }
3a4e6f 242
9ec2d6 243 % title page styles
3a4e6f 244 \makeatletter
CM 245 \def\@subtitle{\relax}
246 \newcommand{\subtitle}[1]{\gdef\@subtitle{#1}}
247 \renewcommand{\maketitle}{
248   \begin{titlepage}
249     {\rm\Huge\@title\par}
250     {\em\large\py@release\releaseinfo\par}
251     \if\@subtitle\relax\else\large\@subtitle\par\fi
252     {\large\@author\par}
253   \end{titlepage}
254 }
255 \makeatother
256
9ec2d6 257 % Redefine link and title colors
793425 258 \definecolor{TitleColor}{rgb}{0,0,0}
CM 259 \definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486}
260 \definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388}
261 % Redefine these colors to something not white if you want to have colored
262 % background and border for code examples.
263 \definecolor{VerbatimColor}{rgb}{1,1,1}
264 \definecolor{VerbatimBorderColor}{rgb}{1,1,1}
265
266 \makeatletter
dc0ba7 267 \renewcommand{\py@noticestart@warning}{\py@heavybox}
CM 268 \renewcommand{\py@noticeend@warning}{\py@endheavybox}
793425 269 \renewcommand{\py@noticestart@note}{\py@heavybox}
CM 270 \renewcommand{\py@noticeend@note}{\py@endheavybox}
271 \makeatother
272
9ec2d6 273 % icons in note and warning boxes
dc0ba7 274 \usepackage{ifthen}
CM 275 % Keep a copy of the original notice environment
276 \let\origbeginnotice\notice
277 \let\origendnotice\endnotice
278
279 % Redefine the notice environment so we can add our own code to it
280 \renewenvironment{notice}[2]{%
281   \origbeginnotice{#1}{}% equivalent to original \begin{notice}{#1}{#2}
282   % load graphics
283   \ifthenelse{\equal{#1}{warning}}{\includegraphics{exclaim.png}}{}
284   \ifthenelse{\equal{#1}{note}}{\includegraphics{info.png}}{}
285   % etc.
286 }{%
287   \origendnotice% equivalent to original \end{notice}
288 }
289
9ec2d6 290 % try to prevent code-block boxes from splitting across pages
44f1df 291 \sloppy
9ec2d6 292 \widowpenalty=300
CM 293 \clubpenalty=300
294 \setlength{\parskip}{3ex plus 2ex minus 2ex}
295
296 % suppress page numbers on pages showing part title
297 \makeatletter
298 \let\sv@endpart\@endpart
299 \def\@endpart{\thispagestyle{empty}\sv@endpart}
300 \makeatother
301
302 % prevent page numbers in TOC (reset to fancy by frontmatter directive)
303 \pagestyle{empty}
f2086c 304 """
125e97 305
CM 306 latex_elements = {
f2086c 307     'preamble': _PREAMBLE,
CM 308     'wrapperclass':'book',
d22e8d 309     'date':'',
3a4e6f 310     'releasename':'Version',
CM 311     'title':r'The repoze.bfg Web Application \newline Framework',
9544d0 312 #    'pointsize':'12pt', # uncomment for 12pt version
f2086c 313 }
CM 314
315 from docutils import nodes
316
9ec2d6 317 # secnumdepth counter reset to 2 causes numbering in related matter;
CM 318 # reset to -1 causes chapters to not be numbered, reset to -2 causes
319 # parts to not be numbered.
320
321 #part          -1
322 #chapter       0
323 #section       1
324 #subsection    2
325 #subsubsection 3
326 #paragraph     4
327 #subparagraph  5
328
f2086c 329 def frontmatter(name, arguments, options, content, lineno,
CM 330                 content_offset, block_text, state, state_machine):
9ec2d6 331     return [nodes.raw(
CM 332         '',
333         r"""
334 \frontmatter
335 % prevent part/chapter/section numbering
336 \setcounter{secnumdepth}{-2}
337 % suppress headers
338 \pagestyle{plain}
339 % reset page counter
340 \setcounter{page}{1}
341 % suppress first toc pagenum
342 \addtocontents{toc}{\protect\thispagestyle{empty}} 
343 """,
344         format='latex')]
f2086c 345
CM 346 def mainmatter(name, arguments, options, content, lineno,
347                content_offset, block_text, state, state_machine):
9ec2d6 348     return [nodes.raw(
CM 349         '',
350         r"""
351 \mainmatter
352 % allow part/chapter/section numbering
353 \setcounter{secnumdepth}{2}
354 % get headers back
355 \pagestyle{fancy} 
356 \fancyhf{}
357 \renewcommand{\headrulewidth}{0.5pt}
358 \renewcommand{\footrulewidth}{0pt}
359 \fancyfoot[C]{\thepage}
360 \fancyhead[RO]{\rightmark}
361 \fancyhead[LE]{\leftmark}
362 """,
363         format='latex')]
f2086c 364
CM 365 def backmatter(name, arguments, options, content, lineno,
366               content_offset, block_text, state, state_machine):
9ec2d6 367     return [nodes.raw('', '\\backmatter\n\\setcounter{secnumdepth}{-1}\n',
CM 368                       format='latex')]
f2086c 369
CM 370 def setup(app):
371     app.add_directive('frontmatter', frontmatter, 1, (0, 0, 0))
372     app.add_directive('mainmatter', mainmatter, 1, (0, 0, 0))
373     app.add_directive('backmatter', backmatter, 1, (0, 0, 0))
016a1f 374
274778 375 # strip "repoze.bfg." from all inline literals
016a1f 376
CM 377 from sphinx.writers.latex import LaTeXTranslator
378
379 def visit_literal(self, node):
380         self.no_contractions += 1
381         content = self.encode(node.astext().strip())
382         self.no_contractions -= 1
383         if self.in_title:
384             self.body.append(r'\texttt{%s}' % content)
385         elif node.has_key('role') and node['role'] == 'samp':
386             self.body.append(r'\samp{%s}' % content)
387         else:
388             # XXX special treatment of overlong ``repoze.bfg.foo``
389             # literals.
390             if 'repoze.bfg.' in content:
391                 content = content.replace('repoze.bfg.', '')
392             self.body.append(r'\code{%s}' % content)
393         raise nodes.SkipNode
394     
395 LaTeXTranslator.visit_literal = visit_literal
396
274778 397 # turn off all line numbers in latex formatting
CM 398
399 ## from pygments.formatters import LatexFormatter
400 ## from sphinx.highlighting import PygmentsBridge
401
402 ## class NoLinenosLatexFormatter(LatexFormatter):
403 ##     def __init__(self, **options):
404 ##         LatexFormatter.__init__(self, **options)
405 ##         self.linenos = False
406
407 ## PygmentsBridge.latex_formatter = NoLinenosLatexFormatter
6d47bc 408
CM 409 # -- Options for Epub output ---------------------------------------------------
410
411 # Bibliographic Dublin Core info.
4c8f4d 412 epub_title = 'The repoze.bfg Web Application Framework, Version 1.3'
6d47bc 413 epub_author = 'Chris McDonough'
CM 414 epub_publisher = 'Agendaless Consulting'
415 epub_copyright = '2008-2010'
416
417 # The language of the text. It defaults to the language option
418 # or en if the language is not set.
419 epub_language = 'en'
420
421 # The scheme of the identifier. Typical schemes are ISBN or URL.
422 epub_scheme = 'ISBN'
423
424 # The unique identifier of the text. This can be a ISBN number
425 # or the project homepage.
426 epub_identifier = '0615345379'
427
428 # A unique identification for the text.
4c8f4d 429 epub_uid = 'The repoze.bfg Web Application Framework, Version 1.3-v0'
6d47bc 430
CM 431 # HTML files that should be inserted before the pages created by sphinx.
432 # The format is a list of tuples containing the path and title.
433 #epub_pre_files = []
434
435 # HTML files shat should be inserted after the pages created by sphinx.
436 # The format is a list of tuples containing the path and title.
437 #epub_post_files = []
438
439 # A list of files that should not be packed into the epub file.
440 #epub_exclude_files = []
441
442 # The depth of the table of contents in toc.ncx.
443 epub_tocdepth = 3