Chris McDonough
2012-03-02 3a14206e0f03fe24fa9a6611097230607332184d
commit | author | age
f70c23 1 # -*- coding: utf-8 -*-
CM 2 #
edd915 3 # pyramid documentation build configuration file, created by
f70c23 4 # sphinx-quickstart on Wed Jul 16 13:18:14 2008.
CM 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
c8b363 14 import sys
M 15 import os
52d4fb 16 import datetime
be5f12 17 import inspect
50fb10 18 import warnings
CM 19
20 warnings.simplefilter('ignore', DeprecationWarning)
f70c23 21
6cdedf 22 # skip raw nodes
CM 23 from sphinx.writers.text import TextTranslator
43889a 24 from sphinx.writers.latex import LaTeXTranslator
CM 25
6cdedf 26 from docutils import nodes
fd5ae9 27 from docutils import utils
CM 28
6cdedf 29 def raw(*arg):
CM 30     raise nodes.SkipNode
31 TextTranslator.visit_raw = raw
32
43889a 33
CM 34 # make sure :app:`Pyramid` doesn't mess up LaTeX rendering
35 def nothing(*arg):
36     pass
37 LaTeXTranslator.visit_inline = nothing
38 LaTeXTranslator.depart_inline = nothing
39
d22e8d 40 book = os.environ.get('BOOK')
274778 41
f70c23 42 # General configuration
CM 43 # ---------------------
44
45 # Add any Sphinx extension module names here, as strings. They can be extensions
46 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
8864e0 47 extensions = [
CM 48     'sphinx.ext.autodoc',
49     'sphinx.ext.doctest',
50     'repoze.sphinx.autointerface',
288072 51 #    'sphinx.ext.intersphinx'
8864e0 52     ]
CM 53
54 # Looks for objects in other Pyramid projects
288072 55 ## intersphinx_mapping = {
CM 56 ##     'cookbook':
57 ##     ('http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/', None),
58 ##     'handlers':
59 ##     ('http://docs.pylonsproject.org/projects/pyramid_handlers/dev/', None),
60 ##     'zcml':
61 ##     ('http://docs.pylonsproject.org/projects/pyramid_zcml/dev/', None),
62 ##     'jinja2':
63 ##     ('http://docs.pylonsproject.org/projects/pyramid_jinja2/dev/', None),
64 ##     }
f70c23 65
CM 66 # Add any paths that contain templates here, relative to this directory.
785d2f 67 templates_path = ['_templates']
f70c23 68
CM 69 # The suffix of source filenames.
70 source_suffix = '.rst'
71
72 # The master toctree document.
73 master_doc = 'index'
74
75 # General substitutions.
edd915 76 project = 'The Pyramid Web Application Development Framework'
52d4fb 77 copyright = '%s, Agendaless Consulting' % datetime.datetime.now().year
f70c23 78
CM 79 # The default replacements for |version| and |release|, also used in various
80 # other places throughout the built documents.
81 #
82 # The short X.Y version.
3a1420 83 version = '1.3b2'
3ee102 84
f70c23 85 # The full version, including alpha/beta/rc tags.
c0114e 86 release = version
f70c23 87
CM 88 # There are two options for replacing |today|: either, you set today to some
89 # non-false value, then it is used:
90 #today = ''
91 # Else, today_fmt is used as the format for a strftime call.
92 today_fmt = '%B %d, %Y'
93
94 # List of documents that shouldn't be included in the build.
95 #unused_docs = []
96
4ac753 97 # List of patterns, relative to source directory, that match files and
M 98 # directories to ignore when looking for source files.
99 exclude_patterns = ['_themes/README.rst',]
100
f70c23 101 # List of directories, relative to source directories, that shouldn't be searched
CM 102 # for source files.
103 #exclude_dirs = []
104
105 # The reST default role (used for this markup: `text`) to use for all documents.
106 #default_role = None
107
108 # If true, '()' will be appended to :func: etc. cross-reference text.
109 #add_function_parentheses = True
110
111 # If true, the current module name will be prepended to all description
112 # unit titles (such as .. function::).
e4e3aa 113 add_module_names = False
f70c23 114
CM 115 # If true, sectionauthor and moduleauthor directives will be shown in the
116 # output. They are ignored by default.
117 #show_authors = False
118
119 # The name of the Pygments (syntax highlighting) style to use.
957548 120 #pygments_style = book and 'bw' or 'tango'
5845bc 121 if book:
CM 122     pygments_style = 'bw'
f70c23 123
002c0c 124 # The default language to highlight source code in.
cc19a8 125 #highlight_language = 'guess'
002c0c 126
f70c23 127 # Options for HTML output
CM 128 # -----------------------
129
957548 130 # Add and use Pylons theme
06f12a 131 if 'sphinx-build' in ' '.join(sys.argv): # protect against dumb importers
CM 132     from subprocess import call, Popen, PIPE
d0a257 133
06f12a 134     p = Popen('which git', shell=True, stdout=PIPE)
CM 135     git = p.stdout.read().strip()
136     cwd = os.getcwd()
137     _themes = os.path.join(cwd, '_themes')
d0a257 138
06f12a 139     if not os.path.isdir(_themes):
CM 140         call([git, 'clone', 'git://github.com/Pylons/pylons_sphinx_theme.git',
141                 '_themes'])
142     else:
143         os.chdir(_themes)
144         call([git, 'checkout', 'master'])
145         call([git, 'pull'])
146         os.chdir(cwd)
d0a257 147
06f12a 148     sys.path.append(os.path.abspath('_themes'))
CM 149
150     parent = os.path.dirname(os.path.dirname(__file__))
151     sys.path.append(os.path.abspath(parent))
152     wd = os.getcwd()
153     os.chdir(parent)
154     os.system('%s setup.py test -q' % sys.executable)
155     os.chdir(wd)
156
157     for item in os.listdir(parent):
158         if item.endswith('.egg'):
159             sys.path.append(os.path.join(parent, item))
160
957548 161 html_theme_path = ['_themes']
cc19a8 162 html_theme = 'pyramid'
d0a257 163 html_theme_options = dict(
862a26 164     github_url='https://github.com/Pylons/pyramid',
7e2ed7 165 #    in_progress='true'
d0a257 166     )
f70c23 167 # The style sheet to use for HTML and HTML Help pages. A file of that name
CM 168 # must exist either in Sphinx' static/ path, or in one of the custom paths
169 # given in html_static_path.
957548 170 #html_style = 'pyramid.css'
f70c23 171
CM 172 # The name for this set of Sphinx documents.  If None, it defaults to
173 # "<project> v<release> documentation".
785d2f 174 html_title = 'The Pyramid Web Application Development Framework v%s' % release
f70c23 175
CM 176 # A shorter title for the navigation bar.  Default is the same as html_title.
cc19a8 177 #html_short_title = 'Home'
f70c23 178
CM 179 # The name of an image file (within the static path) to place at the top of
180 # the sidebar.
cc19a8 181 #html_logo = '_static/pyramid.png'
f70c23 182
CM 183 # The name of an image file (within the static path) to use as favicon of the
184 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
185 # pixels large.
cc19a8 186 #html_favicon = '_static/pyramid.ico'
f70c23 187
CM 188 # Add any paths that contain custom static files (such as style sheets) here,
189 # relative to this directory. They are copied after the builtin static files,
190 # so a file named "default.css" will overwrite the builtin "default.css".
cc19a8 191 #html_static_path = ['_static']
f70c23 192
CM 193 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
194 # using the given strftime format.
195 html_last_updated_fmt = '%b %d, %Y'
196
197 # If true, SmartyPants will be used to convert quotes and dashes to
198 # typographically correct entities.
199 #html_use_smartypants = True
200
201 # Custom sidebar templates, maps document names to template names.
202 #html_sidebars = {}
203
204 # Additional templates that should be rendered to pages, maps page names to
205 # template names.
206 #html_additional_pages = {}
207
208 # If false, no module index is generated.
209 #html_use_modindex = True
210
211 # If false, no index is generated.
212 #html_use_index = True
213
214 # If true, the index is split into individual pages for each letter.
215 #html_split_index = False
216
217 # If true, the reST sources are included in the HTML build as _sources/<name>.
218 #html_copy_source = True
219
220 # If true, an OpenSearch description file will be output, and all pages will
221 # contain a <link> tag referring to it.  The value of this option must be the
222 # base URL from which the finished HTML is served.
223 #html_use_opensearch = ''
224
225 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
226 #html_file_suffix = ''
227
228 # Output file base name for HTML help builder.
71ff10 229 htmlhelp_basename = 'pyramid'
f70c23 230
CM 231 # Options for LaTeX output
232 # ------------------------
233
234 # The paper size ('letter' or 'a4').
67bfd8 235 latex_paper_size = 'letter'
f70c23 236
CM 237 # The font size ('10pt', '11pt' or '12pt').
67bfd8 238 latex_font_size = '10pt'
f70c23 239
CM 240 # Grouping the document tree into LaTeX files. List of tuples
241 # (source start file, target name, title, author, document class [howto/manual]).
242 latex_documents = [
71ff10 243   ('latexindex', 'pyramid.tex',
edd915 244    'The Pyramid Web Application Development Framework',
8be78e 245    'Chris McDonough', 'manual'),
CM 246     ]
f70c23 247
CM 248 # The name of an image file (relative to this directory) to place at the top of
249 # the title page.
cc19a8 250 #latex_logo = '_static/pylons_small.png'
f70c23 251
CM 252 # For "manual" documents, if this is true, then toplevel headings are parts,
253 # not chapters.
67bfd8 254 latex_use_parts = True
f70c23 255
CM 256 # Additional stuff for the LaTeX preamble.
257 #latex_preamble = ''
258
259 # Documents to append as an appendix to all manuals.
260 #latex_appendices = []
261
262 # If false, no module index is generated.
7a3985 263 latex_use_modindex = False
125e97 264
CM 265 ## Say, for a moment that you have a twoside document that needs a 3cm
266 ## inner margin to allow for binding and at least two centimetres the
267 ## rest of the way around. You've been using the a4wide package up until
268 ## now, because you like the amount of text it places on the
269 ## page. Perhaps try something like this in your preamble:
270
271 ## \usepackage[bindingoffset=1cm,textheight=22cm,hdivide={2cm,*,2cm},vdivide={*,22cm,*}]{geometry}
272
f2086c 273 ## _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 274
f2086c 275 _PREAMBLE = r"""
CM 276 \usepackage[]{geometry}
277 \geometry{bindingoffset=0.45in,textheight=7.25in,hdivide={0.5in,*,0.75in},vdivide={1in,7.25in,1in},papersize={7.5in,9.25in}}
278 \hypersetup{
279     colorlinks=true,
280     linkcolor=black,
281     citecolor=black,
282     filecolor=black,
283     urlcolor=black
284 }
274778 285 \fvset{frame=single,xleftmargin=9pt,numbersep=4pt}
f2086c 286
CM 287 \pagestyle{fancy}
288
9ec2d6 289 % header and footer styles
f2086c 290 \renewcommand{\chaptermark}[1]%
9ec2d6 291   {\markboth{\MakeUppercase{\thechapter.\ #1}}{}
CM 292   }
f2086c 293 \renewcommand{\sectionmark}[1]%
9ec2d6 294   {\markright{\MakeUppercase{\thesection.\ #1}}
CM 295   }
296
297 % defaults for fancy style
298 \renewcommand{\headrulewidth}{0pt}
f2086c 299 \renewcommand{\footrulewidth}{0pt}
CM 300 \fancyhf{}
301 \fancyfoot[C]{\thepage}
302
9ec2d6 303 % plain style
f2086c 304 \fancypagestyle{plain}{
CM 305   \renewcommand{\headrulewidth}{0pt} % ho header line
9ec2d6 306   \renewcommand{\footrulewidth}{0pt}% no footer line
CM 307   \fancyhf{} % empty header and footer
308   \fancyfoot[C]{\thepage}
f2086c 309 }
3a4e6f 310
9ec2d6 311 % title page styles
3a4e6f 312 \makeatletter
CM 313 \def\@subtitle{\relax}
314 \newcommand{\subtitle}[1]{\gdef\@subtitle{#1}}
315 \renewcommand{\maketitle}{
316   \begin{titlepage}
317     {\rm\Huge\@title\par}
318     {\em\large\py@release\releaseinfo\par}
319     \if\@subtitle\relax\else\large\@subtitle\par\fi
320     {\large\@author\par}
321   \end{titlepage}
322 }
323 \makeatother
324
9ec2d6 325 % Redefine link and title colors
793425 326 \definecolor{TitleColor}{rgb}{0,0,0}
CM 327 \definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486}
328 \definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388}
329 % Redefine these colors to something not white if you want to have colored
330 % background and border for code examples.
331 \definecolor{VerbatimColor}{rgb}{1,1,1}
332 \definecolor{VerbatimBorderColor}{rgb}{1,1,1}
333
334 \makeatletter
dc0ba7 335 \renewcommand{\py@noticestart@warning}{\py@heavybox}
CM 336 \renewcommand{\py@noticeend@warning}{\py@endheavybox}
793425 337 \renewcommand{\py@noticestart@note}{\py@heavybox}
CM 338 \renewcommand{\py@noticeend@note}{\py@endheavybox}
339 \makeatother
340
9ec2d6 341 % icons in note and warning boxes
dc0ba7 342 \usepackage{ifthen}
CM 343 % Keep a copy of the original notice environment
344 \let\origbeginnotice\notice
345 \let\origendnotice\endnotice
346
347 % Redefine the notice environment so we can add our own code to it
348 \renewenvironment{notice}[2]{%
349   \origbeginnotice{#1}{}% equivalent to original \begin{notice}{#1}{#2}
350   % load graphics
de8c1b 351   \ifthenelse{\equal{#1}{warning}}{\includegraphics{latex-warning.png}}{}
BL 352   \ifthenelse{\equal{#1}{note}}{\includegraphics{latex-note.png}}{}
dc0ba7 353   % etc.
CM 354 }{%
355   \origendnotice% equivalent to original \end{notice}
356 }
357
9ec2d6 358 % try to prevent code-block boxes from splitting across pages
44f1df 359 \sloppy
9ec2d6 360 \widowpenalty=300
CM 361 \clubpenalty=300
362 \setlength{\parskip}{3ex plus 2ex minus 2ex}
363
364 % suppress page numbers on pages showing part title
365 \makeatletter
366 \let\sv@endpart\@endpart
367 \def\@endpart{\thispagestyle{empty}\sv@endpart}
368 \makeatother
369
370 % prevent page numbers in TOC (reset to fancy by frontmatter directive)
371 \pagestyle{empty}
f2086c 372 """
125e97 373
CM 374 latex_elements = {
f2086c 375     'preamble': _PREAMBLE,
CM 376     'wrapperclass':'book',
d22e8d 377     'date':'',
3a4e6f 378     'releasename':'Version',
edd915 379     'title':r'The Pyramid Web Application \newline Development Framework',
9544d0 380 #    'pointsize':'12pt', # uncomment for 12pt version
f2086c 381 }
CM 382
9ec2d6 383 # secnumdepth counter reset to 2 causes numbering in related matter;
CM 384 # reset to -1 causes chapters to not be numbered, reset to -2 causes
385 # parts to not be numbered.
386
387 #part          -1
388 #chapter       0
389 #section       1
390 #subsection    2
391 #subsubsection 3
392 #paragraph     4
393 #subparagraph  5
394
f2086c 395 def frontmatter(name, arguments, options, content, lineno,
CM 396                 content_offset, block_text, state, state_machine):
9ec2d6 397     return [nodes.raw(
CM 398         '',
399         r"""
400 \frontmatter
401 % prevent part/chapter/section numbering
402 \setcounter{secnumdepth}{-2}
403 % suppress headers
404 \pagestyle{plain}
405 % reset page counter
406 \setcounter{page}{1}
407 % suppress first toc pagenum
c8b363 408 \addtocontents{toc}{\protect\thispagestyle{empty}}
9ec2d6 409 """,
CM 410         format='latex')]
f2086c 411
CM 412 def mainmatter(name, arguments, options, content, lineno,
413                content_offset, block_text, state, state_machine):
9ec2d6 414     return [nodes.raw(
CM 415         '',
416         r"""
417 \mainmatter
418 % allow part/chapter/section numbering
419 \setcounter{secnumdepth}{2}
420 % get headers back
c8b363 421 \pagestyle{fancy}
9ec2d6 422 \fancyhf{}
CM 423 \renewcommand{\headrulewidth}{0.5pt}
424 \renewcommand{\footrulewidth}{0pt}
425 \fancyfoot[C]{\thepage}
426 \fancyhead[RO]{\rightmark}
427 \fancyhead[LE]{\leftmark}
428 """,
429         format='latex')]
f2086c 430
CM 431 def backmatter(name, arguments, options, content, lineno,
432               content_offset, block_text, state, state_machine):
9ec2d6 433     return [nodes.raw('', '\\backmatter\n\\setcounter{secnumdepth}{-1}\n',
CM 434                       format='latex')]
f2086c 435
fd5ae9 436 def app_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
CM 437     """custom role for :app: marker, does nothing in particular except allow
438     :app:`Pyramid` to work (for later search and replace)."""
439     if 'class' in options:
440         assert 'classes' not in options
441         options['classes'] = options['class']
442         del options['class']
443     return [nodes.inline(rawtext, utils.unescape(text), **options)], []
444
445
f2086c 446 def setup(app):
fd5ae9 447     app.add_role('app', app_role)
f2086c 448     app.add_directive('frontmatter', frontmatter, 1, (0, 0, 0))
CM 449     app.add_directive('mainmatter', mainmatter, 1, (0, 0, 0))
450     app.add_directive('backmatter', backmatter, 1, (0, 0, 0))
be5f12 451     app.connect('autodoc-process-signature', resig)
CM 452
453 def resig(app, what, name, obj, options, signature, return_annotation):
454     """ Allow for preservation of ``@action_method`` decorated methods
455     in configurator """
456     docobj = getattr(obj, '__docobj__', None)
457     if docobj is not None:
458         argspec = inspect.getargspec(docobj)
459         if argspec[0] and argspec[0][0] in ('cls', 'self'):
460             del argspec[0][0]
461         signature = inspect.formatargspec(*argspec)
462     return signature, return_annotation
016a1f 463
274778 464 # turn off all line numbers in latex formatting
CM 465
466 ## from pygments.formatters import LatexFormatter
467 ## from sphinx.highlighting import PygmentsBridge
468
469 ## class NoLinenosLatexFormatter(LatexFormatter):
470 ##     def __init__(self, **options):
471 ##         LatexFormatter.__init__(self, **options)
472 ##         self.linenos = False
473
474 ## PygmentsBridge.latex_formatter = NoLinenosLatexFormatter
6d47bc 475
CM 476 # -- Options for Epub output ---------------------------------------------------
477
478 # Bibliographic Dublin Core info.
5f1cf3 479 epub_title = 'The Pyramid Web Application Development Framework, Version 1.3'
6d47bc 480 epub_author = 'Chris McDonough'
CM 481 epub_publisher = 'Agendaless Consulting'
74c3c3 482 epub_copyright = '2008-2011'
6d47bc 483
CM 484 # The language of the text. It defaults to the language option
485 # or en if the language is not set.
486 epub_language = 'en'
487
488 # The scheme of the identifier. Typical schemes are ISBN or URL.
489 epub_scheme = 'ISBN'
490
491 # The unique identifier of the text. This can be a ISBN number
492 # or the project homepage.
5236f3 493 epub_identifier = '0615445675'
6d47bc 494
CM 495 # A unique identification for the text.
5f1cf3 496 epub_uid = 'The Pyramid Web Application Development Framework, Version 1.3'
6d47bc 497
CM 498 # HTML files that should be inserted before the pages created by sphinx.
499 # The format is a list of tuples containing the path and title.
500 #epub_pre_files = []
501
502 # HTML files shat should be inserted after the pages created by sphinx.
503 # The format is a list of tuples containing the path and title.
504 #epub_post_files = []
505
506 # A list of files that should not be packed into the epub file.
c8b363 507 epub_exclude_files = ['_static/opensearch.xml', '_static/doctools.js',
M 508     '_static/jquery.js', '_static/searchtools.js', '_static/underscore.js',
509     '_static/basic.css', 'search.html']
510
6d47bc 511
CM 512 # The depth of the table of contents in toc.ncx.
513 epub_tocdepth = 3