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