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