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