summaryrefslogtreecommitdiff
path: root/sphinx/quickstart.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2016-07-07 23:29:25 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2016-07-26 14:45:57 +0900
commit151478ff96a2000eb717c0e1017296d309015ca4 (patch)
tree020d2889ab39622473fe314a76a7624a7d518bff /sphinx/quickstart.py
parentb208b3e9e0e174c7640735668aa69c453ba66ac3 (diff)
downloadsphinx-git-151478ff96a2000eb717c0e1017296d309015ca4.tar.gz
Jinja2-ize quickstart
Diffstat (limited to 'sphinx/quickstart.py')
-rw-r--r--sphinx/quickstart.py1082
1 files changed, 20 insertions, 1062 deletions
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 1b12b0a7f..326da03db 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -34,10 +34,11 @@ from six.moves import input
from six.moves.urllib.parse import quote as urlquote
from docutils.utils import column_width
-from sphinx import __display_version__
+from sphinx import __display_version__, package_dir
from sphinx.util.osutil import make_filename
from sphinx.util.console import purple, bold, red, turquoise, \
nocolor, color_terminal
+from sphinx.util.template import SphinxRenderer
from sphinx.util import texescape
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
@@ -65,1047 +66,6 @@ EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
PROMPT_PREFIX = '> '
-if PY3:
- # prevents that the file is checked for being written in Python 2.x syntax
- QUICKSTART_CONF = u'#!/usr/bin/env python3\n'
-else:
- QUICKSTART_CONF = u''
-
-QUICKSTART_CONF += u'''\
-# -*- coding: utf-8 -*-
-#
-# %(project)s documentation build configuration file, created by
-# sphinx-quickstart on %(now)s.
-#
-# This file is execfile()d with the current directory set to its
-# containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))
-
-# -- General configuration ------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#
-# needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
-extensions = [%(extensions)s]
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['%(dot)stemplates']
-
-# The suffix(es) of source filenames.
-# You can specify multiple suffix as a list of string:
-#
-# source_suffix = ['.rst', '.md']
-source_suffix = '%(suffix)s'
-
-# The encoding of source files.
-#
-# source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = '%(master_str)s'
-
-# General information about the project.
-project = u'%(project_str)s'
-copyright = u'%(copyright_str)s'
-author = u'%(author_str)s'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = u'%(version_str)s'
-# The full version, including alpha/beta/rc tags.
-release = u'%(release_str)s'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#
-# This is also used if you do content translation via gettext catalogs.
-# Usually you set "language" from the command line for these cases.
-language = %(language)r
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#
-# today = ''
-#
-# Else, today_fmt is used as the format for a strftime call.
-#
-# today_fmt = '%%B %%d, %%Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-# This patterns also effect to html_static_path and html_extra_path
-exclude_patterns = [%(exclude_patterns)s]
-
-# The reST default role (used for this markup: `text`) to use for all
-# documents.
-#
-# default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#
-# add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#
-# add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#
-# show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-# modindex_common_prefix = []
-
-# If true, keep warnings as "system message" paragraphs in the built documents.
-# keep_warnings = False
-
-# If true, `todo` and `todoList` produce output, else they produce nothing.
-todo_include_todos = %(ext_todo)s
-
-
-# -- Options for HTML output ----------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. See the documentation for
-# a list of builtin themes.
-#
-html_theme = 'alabaster'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#
-# html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-# html_theme_path = []
-
-# The name for this set of Sphinx documents.
-# "<project> v<release> documentation" by default.
-#
-# html_title = u'%(project_str)s v%(release_str)s'
-
-# A shorter title for the navigation bar. Default is the same as html_title.
-#
-# html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#
-# html_logo = None
-
-# The name of an image file (relative to this directory) to use as a favicon of
-# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#
-# html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['%(dot)sstatic']
-
-# Add any extra paths that contain custom files (such as robots.txt or
-# .htaccess) here, relative to this directory. These files are copied
-# directly to the root of the documentation.
-#
-# html_extra_path = []
-
-# If not None, a 'Last updated on:' timestamp is inserted at every page
-# bottom, using the given strftime format.
-# The empty string is equivalent to '%%b %%d, %%Y'.
-#
-# html_last_updated_fmt = None
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#
-# html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#
-# html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#
-# html_additional_pages = {}
-
-# If false, no module index is generated.
-#
-# html_domain_indices = True
-
-# If false, no index is generated.
-#
-# html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#
-# html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#
-# html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#
-# html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#
-# html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it. The value of this option must be the
-# base URL from which the finished HTML is served.
-#
-# html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-# html_file_suffix = None
-
-# Language to be used for generating the HTML full-text search index.
-# Sphinx supports the following languages:
-# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
-# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
-#
-# html_search_language = 'en'
-
-# A dictionary with options for the search language support, empty by default.
-# 'ja' uses this config value.
-# 'zh' user can custom change `jieba` dictionary path.
-#
-# html_search_options = {'type': 'default'}
-
-# The name of a javascript file (relative to the configuration directory) that
-# implements a search results scorer. If empty, the default will be used.
-#
-# html_search_scorer = 'scorer.js'
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = '%(project_fn)sdoc'
-
-# -- Options for LaTeX output ---------------------------------------------
-
-latex_elements = {
- # The paper size ('letterpaper' or 'a4paper').
- #
- # 'papersize': 'letterpaper',
-
- # The font size ('10pt', '11pt' or '12pt').
- #
- # 'pointsize': '10pt',
-
- # Additional stuff for the LaTeX preamble.
- #
- # 'preamble': '',
-
- # Latex figure (float) alignment
- #
- # 'figure_align': 'htbp',
-}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-# author, documentclass [howto, manual, or own class]).
-latex_documents = [
- (master_doc, '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s',
- u'%(author_texescaped_str)s', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#
-# latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#
-# latex_use_parts = False
-
-# If true, show page references after internal links.
-#
-# latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#
-# latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#
-# latex_appendices = []
-
-# It false, will not define \strong, \code, \titleref, \crossref ... but only
-# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added
-# packages.
-#
-# latex_keep_old_macro_names = True
-
-# If false, no module index is generated.
-#
-# latex_domain_indices = True
-
-
-# -- Options for manual page output ---------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
- (master_doc, '%(project_manpage)s', u'%(project_doc_str)s',
- [author], 1)
-]
-
-# If true, show URL addresses after external links.
-#
-# man_show_urls = False
-
-
-# -- Options for Texinfo output -------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-# dir menu entry, description, category)
-texinfo_documents = [
- (master_doc, '%(project_fn)s', u'%(project_doc_str)s',
- author, '%(project_fn)s', 'One line description of project.',
- 'Miscellaneous'),
-]
-
-# Documents to append as an appendix to all manuals.
-#
-# texinfo_appendices = []
-
-# If false, no module index is generated.
-#
-# texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#
-# texinfo_show_urls = 'footnote'
-
-# If true, do not generate a @detailmenu in the "Top" node's menu.
-#
-# texinfo_no_detailmenu = False
-'''
-
-EPUB_CONFIG = u'''
-
-# -- Options for Epub output ----------------------------------------------
-
-# Bibliographic Dublin Core info.
-epub_title = project
-epub_author = author
-epub_publisher = author
-epub_copyright = copyright
-
-# The basename for the epub file. It defaults to the project name.
-# epub_basename = project
-
-# The HTML theme for the epub output. Since the default themes are not
-# optimized for small screen space, using the same theme for HTML and epub
-# output is usually not wise. This defaults to 'epub', a theme designed to save
-# visual space.
-#
-# epub_theme = 'epub'
-
-# The language of the text. It defaults to the language option
-# or 'en' if the language is not set.
-#
-# epub_language = ''
-
-# The scheme of the identifier. Typical schemes are ISBN or URL.
-# epub_scheme = ''
-
-# The unique identifier of the text. This can be a ISBN number
-# or the project homepage.
-#
-# epub_identifier = ''
-
-# A unique identification for the text.
-#
-# epub_uid = ''
-
-# A tuple containing the cover image and cover page html template filenames.
-#
-# epub_cover = ()
-
-# A sequence of (type, uri, title) tuples for the guide element of content.opf.
-#
-# epub_guide = ()
-
-# HTML files that should be inserted before the pages created by sphinx.
-# The format is a list of tuples containing the path and title.
-#
-# epub_pre_files = []
-
-# HTML files that should be inserted after the pages created by sphinx.
-# The format is a list of tuples containing the path and title.
-#
-# epub_post_files = []
-
-# A list of files that should not be packed into the epub file.
-epub_exclude_files = ['search.html']
-
-# The depth of the table of contents in toc.ncx.
-#
-# epub_tocdepth = 3
-
-# Allow duplicate toc entries.
-#
-# epub_tocdup = True
-
-# Choose between 'default' and 'includehidden'.
-#
-# epub_tocscope = 'default'
-
-# Fix unsupported image types using the Pillow.
-#
-# epub_fix_images = False
-
-# Scale large images.
-#
-# epub_max_image_width = 0
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#
-# epub_show_urls = 'inline'
-
-# If false, no index is generated.
-#
-# epub_use_index = True
-'''
-
-INTERSPHINX_CONFIG = u'''
-
-# Example configuration for intersphinx: refer to the Python standard library.
-intersphinx_mapping = {'https://docs.python.org/': None}
-'''
-
-MASTER_FILE = u'''\
-.. %(project)s documentation master file, created by
- sphinx-quickstart on %(now)s.
- You can adapt this file completely to your liking, but it should at least
- contain the root `toctree` directive.
-
-Welcome to %(project)s's documentation!
-===========%(project_underline)s=================
-
-Contents:
-
-.. toctree::
- :maxdepth: %(mastertocmaxdepth)s
-
-%(mastertoctree)s
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
-
-'''
-
-MAKEFILE = u'''\
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = %(rbuilddir)s
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) \
-$(SPHINXOPTS) %(rsrcdir)s
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) %(rsrcdir)s
-
-.PHONY: help
-help:
-\t@echo "Please use \\`make <target>' where <target> is one of"
-\t@echo " html to make standalone HTML files"
-\t@echo " dirhtml to make HTML files named index.html in directories"
-\t@echo " singlehtml to make a single large HTML file"
-\t@echo " pickle to make pickle files"
-\t@echo " json to make JSON files"
-\t@echo " htmlhelp to make HTML files and a HTML help project"
-\t@echo " qthelp to make HTML files and a qthelp project"
-\t@echo " applehelp to make an Apple Help Book"
-\t@echo " devhelp to make HTML files and a Devhelp project"
-\t@echo " epub to make an epub"
-\t@echo " epub3 to make an epub3"
-\t@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-\t@echo " latexpdf to make LaTeX files and run them through pdflatex"
-\t@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
-\t@echo " text to make text files"
-\t@echo " man to make manual pages"
-\t@echo " texinfo to make Texinfo files"
-\t@echo " info to make Texinfo files and run them through makeinfo"
-\t@echo " gettext to make PO message catalogs"
-\t@echo " changes to make an overview of all changed/added/deprecated items"
-\t@echo " xml to make Docutils-native XML files"
-\t@echo " pseudoxml to make pseudoxml-XML files for display purposes"
-\t@echo " linkcheck to check all external links for integrity"
-\t@echo " doctest to run all doctests embedded in the documentation \
-(if enabled)"
-\t@echo " coverage to run coverage check of the documentation (if enabled)"
-\t@echo " dummy to check syntax errors of document sources"
-
-.PHONY: clean
-clean:
-\trm -rf $(BUILDDIR)/*
-
-.PHONY: html
-html:
-\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-\t@echo
-\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-.PHONY: dirhtml
-dirhtml:
-\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-\t@echo
-\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-.PHONY: singlehtml
-singlehtml:
-\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
-\t@echo
-\t@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-.PHONY: pickle
-pickle:
-\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-\t@echo
-\t@echo "Build finished; now you can process the pickle files."
-
-.PHONY: json
-json:
-\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-\t@echo
-\t@echo "Build finished; now you can process the JSON files."
-
-.PHONY: htmlhelp
-htmlhelp:
-\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-\t@echo
-\t@echo "Build finished; now you can run HTML Help Workshop with the" \\
-\t ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-.PHONY: qthelp
-qthelp:
-\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-\t@echo
-\t@echo "Build finished; now you can run "qcollectiongenerator" with the" \\
-\t ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-\t@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/%(project_fn)s.qhcp"
-\t@echo "To view the help file:"
-\t@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/%(project_fn)s.qhc"
-
-.PHONY: applehelp
-applehelp:
-\t$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
-\t@echo
-\t@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
-\t@echo "N.B. You won't be able to view it unless you put it in" \\
-\t "~/Library/Documentation/Help or install it in your application" \\
-\t "bundle."
-
-.PHONY: devhelp
-devhelp:
-\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
-\t@echo
-\t@echo "Build finished."
-\t@echo "To view the help file:"
-\t@echo "# mkdir -p $$HOME/.local/share/devhelp/%(project_fn)s"
-\t@echo "# ln -s $(BUILDDIR)/devhelp\
- $$HOME/.local/share/devhelp/%(project_fn)s"
-\t@echo "# devhelp"
-
-.PHONY: epub
-epub:
-\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
-\t@echo
-\t@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-.PHONY: epub3
-epub3:
-\t$(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3
-\t@echo
-\t@echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3."
-
-.PHONY: latex
-latex:
-\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-\t@echo
-\t@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-\t@echo "Run \\`make' in that directory to run these through (pdf)latex" \\
-\t "(use \\`make latexpdf' here to do that automatically)."
-
-.PHONY: latexpdf
-latexpdf:
-\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-\t@echo "Running LaTeX files through pdflatex..."
-\t$(MAKE) -C $(BUILDDIR)/latex all-pdf
-\t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-.PHONY: latexpdfja
-latexpdfja:
-\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-\t@echo "Running LaTeX files through platex and dvipdfmx..."
-\t$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
-\t@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-.PHONY: text
-text:
-\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
-\t@echo
-\t@echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-.PHONY: man
-man:
-\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
-\t@echo
-\t@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-.PHONY: texinfo
-texinfo:
-\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-\t@echo
-\t@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
-\t@echo "Run \\`make' in that directory to run these through makeinfo" \\
-\t "(use \\`make info' here to do that automatically)."
-
-.PHONY: info
-info:
-\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-\t@echo "Running Texinfo files through makeinfo..."
-\tmake -C $(BUILDDIR)/texinfo info
-\t@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
-
-.PHONY: gettext
-gettext:
-\t$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
-\t@echo
-\t@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-.PHONY: changes
-changes:
-\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
-\t@echo
-\t@echo "The overview file is in $(BUILDDIR)/changes."
-
-.PHONY: linkcheck
-linkcheck:
-\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
-\t@echo
-\t@echo "Link check complete; look for any errors in the above output " \\
-\t "or in $(BUILDDIR)/linkcheck/output.txt."
-
-.PHONY: doctest
-doctest:
-\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
-\t@echo "Testing of doctests in the sources finished, look at the " \\
-\t "results in $(BUILDDIR)/doctest/output.txt."
-
-.PHONY: coverage
-coverage:
-\t$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
-\t@echo "Testing of coverage in the sources finished, look at the " \\
-\t "results in $(BUILDDIR)/coverage/python.txt."
-
-.PHONY: xml
-xml:
-\t$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
-\t@echo
-\t@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
-
-.PHONY: pseudoxml
-pseudoxml:
-\t$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
-\t@echo
-\t@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
-
-.PHONY: dummy
-dummy:
-\t$(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy
-\t@echo
-\t@echo "Build finished. Dummy builder generates no files."
-'''
-
-BATCHFILE = u'''\
-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%%SPHINXBUILD%%" == "" (
-\tset SPHINXBUILD=sphinx-build
-)
-set BUILDDIR=%(rbuilddir)s
-set ALLSPHINXOPTS=-d %%BUILDDIR%%/doctrees %%SPHINXOPTS%% %(rsrcdir)s
-set I18NSPHINXOPTS=%%SPHINXOPTS%% %(rsrcdir)s
-if NOT "%%PAPER%%" == "" (
-\tset ALLSPHINXOPTS=-D latex_paper_size=%%PAPER%% %%ALLSPHINXOPTS%%
-\tset I18NSPHINXOPTS=-D latex_paper_size=%%PAPER%% %%I18NSPHINXOPTS%%
-)
-
-if "%%1" == "" goto help
-
-if "%%1" == "help" (
-\t:help
-\techo.Please use `make ^<target^>` where ^<target^> is one of
-\techo. html to make standalone HTML files
-\techo. dirhtml to make HTML files named index.html in directories
-\techo. singlehtml to make a single large HTML file
-\techo. pickle to make pickle files
-\techo. json to make JSON files
-\techo. htmlhelp to make HTML files and a HTML help project
-\techo. qthelp to make HTML files and a qthelp project
-\techo. devhelp to make HTML files and a Devhelp project
-\techo. epub to make an epub
-\techo. epub3 to make an epub3
-\techo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
-\techo. text to make text files
-\techo. man to make manual pages
-\techo. texinfo to make Texinfo files
-\techo. gettext to make PO message catalogs
-\techo. changes to make an overview over all changed/added/deprecated items
-\techo. xml to make Docutils-native XML files
-\techo. pseudoxml to make pseudoxml-XML files for display purposes
-\techo. linkcheck to check all external links for integrity
-\techo. doctest to run all doctests embedded in the documentation if enabled
-\techo. coverage to run coverage check of the documentation if enabled
-\techo. dummy to check syntax errors of document sources
-\tgoto end
-)
-
-if "%%1" == "clean" (
-\tfor /d %%%%i in (%%BUILDDIR%%\*) do rmdir /q /s %%%%i
-\tdel /q /s %%BUILDDIR%%\*
-\tgoto end
-)
-
-
-REM Check if sphinx-build is available and fallback to Python version if any
-%%SPHINXBUILD%% 1>NUL 2>NUL
-if errorlevel 9009 goto sphinx_python
-goto sphinx_ok
-
-:sphinx_python
-
-set SPHINXBUILD=python -m sphinx.__init__
-%%SPHINXBUILD%% 2> nul
-if errorlevel 9009 (
-\techo.
-\techo.The 'sphinx-build' command was not found. Make sure you have Sphinx
-\techo.installed, then set the SPHINXBUILD environment variable to point
-\techo.to the full path of the 'sphinx-build' executable. Alternatively you
-\techo.may add the Sphinx directory to PATH.
-\techo.
-\techo.If you don't have Sphinx installed, grab it from
-\techo.http://sphinx-doc.org/
-\texit /b 1
-)
-
-:sphinx_ok
-
-
-if "%%1" == "html" (
-\t%%SPHINXBUILD%% -b html %%ALLSPHINXOPTS%% %%BUILDDIR%%/html
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The HTML pages are in %%BUILDDIR%%/html.
-\tgoto end
-)
-
-if "%%1" == "dirhtml" (
-\t%%SPHINXBUILD%% -b dirhtml %%ALLSPHINXOPTS%% %%BUILDDIR%%/dirhtml
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The HTML pages are in %%BUILDDIR%%/dirhtml.
-\tgoto end
-)
-
-if "%%1" == "singlehtml" (
-\t%%SPHINXBUILD%% -b singlehtml %%ALLSPHINXOPTS%% %%BUILDDIR%%/singlehtml
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The HTML pages are in %%BUILDDIR%%/singlehtml.
-\tgoto end
-)
-
-if "%%1" == "pickle" (
-\t%%SPHINXBUILD%% -b pickle %%ALLSPHINXOPTS%% %%BUILDDIR%%/pickle
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished; now you can process the pickle files.
-\tgoto end
-)
-
-if "%%1" == "json" (
-\t%%SPHINXBUILD%% -b json %%ALLSPHINXOPTS%% %%BUILDDIR%%/json
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished; now you can process the JSON files.
-\tgoto end
-)
-
-if "%%1" == "htmlhelp" (
-\t%%SPHINXBUILD%% -b htmlhelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/htmlhelp
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished; now you can run HTML Help Workshop with the ^
-.hhp project file in %%BUILDDIR%%/htmlhelp.
-\tgoto end
-)
-
-if "%%1" == "qthelp" (
-\t%%SPHINXBUILD%% -b qthelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/qthelp
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished; now you can run "qcollectiongenerator" with the ^
-.qhcp project file in %%BUILDDIR%%/qthelp, like this:
-\techo.^> qcollectiongenerator %%BUILDDIR%%\\qthelp\\%(project_fn)s.qhcp
-\techo.To view the help file:
-\techo.^> assistant -collectionFile %%BUILDDIR%%\\qthelp\\%(project_fn)s.ghc
-\tgoto end
-)
-
-if "%%1" == "devhelp" (
-\t%%SPHINXBUILD%% -b devhelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/devhelp
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished.
-\tgoto end
-)
-
-if "%%1" == "epub" (
-\t%%SPHINXBUILD%% -b epub %%ALLSPHINXOPTS%% %%BUILDDIR%%/epub
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The epub file is in %%BUILDDIR%%/epub.
-\tgoto end
-)
-
-if "%%1" == "epub3" (
-\t%%SPHINXBUILD%% -b epub3 %%ALLSPHINXOPTS%% %%BUILDDIR%%/epub3
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The epub3 file is in %%BUILDDIR%%/epub3.
-\tgoto end
-)
-
-if "%%1" == "latex" (
-\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished; the LaTeX files are in %%BUILDDIR%%/latex.
-\tgoto end
-)
-
-if "%%1" == "latexpdf" (
-\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex
-\tcd %%BUILDDIR%%/latex
-\tmake all-pdf
-\tcd %%~dp0
-\techo.
-\techo.Build finished; the PDF files are in %%BUILDDIR%%/latex.
-\tgoto end
-)
-
-if "%%1" == "latexpdfja" (
-\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex
-\tcd %%BUILDDIR%%/latex
-\tmake all-pdf-ja
-\tcd %%~dp0
-\techo.
-\techo.Build finished; the PDF files are in %%BUILDDIR%%/latex.
-\tgoto end
-)
-
-if "%%1" == "text" (
-\t%%SPHINXBUILD%% -b text %%ALLSPHINXOPTS%% %%BUILDDIR%%/text
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The text files are in %%BUILDDIR%%/text.
-\tgoto end
-)
-
-if "%%1" == "man" (
-\t%%SPHINXBUILD%% -b man %%ALLSPHINXOPTS%% %%BUILDDIR%%/man
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The manual pages are in %%BUILDDIR%%/man.
-\tgoto end
-)
-
-if "%%1" == "texinfo" (
-\t%%SPHINXBUILD%% -b texinfo %%ALLSPHINXOPTS%% %%BUILDDIR%%/texinfo
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The Texinfo files are in %%BUILDDIR%%/texinfo.
-\tgoto end
-)
-
-if "%%1" == "gettext" (
-\t%%SPHINXBUILD%% -b gettext %%I18NSPHINXOPTS%% %%BUILDDIR%%/locale
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The message catalogs are in %%BUILDDIR%%/locale.
-\tgoto end
-)
-
-if "%%1" == "changes" (
-\t%%SPHINXBUILD%% -b changes %%ALLSPHINXOPTS%% %%BUILDDIR%%/changes
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.The overview file is in %%BUILDDIR%%/changes.
-\tgoto end
-)
-
-if "%%1" == "linkcheck" (
-\t%%SPHINXBUILD%% -b linkcheck %%ALLSPHINXOPTS%% %%BUILDDIR%%/linkcheck
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Link check complete; look for any errors in the above output ^
-or in %%BUILDDIR%%/linkcheck/output.txt.
-\tgoto end
-)
-
-if "%%1" == "doctest" (
-\t%%SPHINXBUILD%% -b doctest %%ALLSPHINXOPTS%% %%BUILDDIR%%/doctest
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Testing of doctests in the sources finished, look at the ^
-results in %%BUILDDIR%%/doctest/output.txt.
-\tgoto end
-)
-
-if "%%1" == "coverage" (
-\t%%SPHINXBUILD%% -b coverage %%ALLSPHINXOPTS%% %%BUILDDIR%%/coverage
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Testing of coverage in the sources finished, look at the ^
-results in %%BUILDDIR%%/coverage/python.txt.
-\tgoto end
-)
-
-if "%%1" == "xml" (
-\t%%SPHINXBUILD%% -b xml %%ALLSPHINXOPTS%% %%BUILDDIR%%/xml
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The XML files are in %%BUILDDIR%%/xml.
-\tgoto end
-)
-
-if "%%1" == "pseudoxml" (
-\t%%SPHINXBUILD%% -b pseudoxml %%ALLSPHINXOPTS%% %%BUILDDIR%%/pseudoxml
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. The pseudo-XML files are in %%BUILDDIR%%/pseudoxml.
-\tgoto end
-)
-
-if "%%1" == "dummy" (
-\t%%SPHINXBUILD%% -b dummy %%ALLSPHINXOPTS%% %%BUILDDIR%%/dummy
-\tif errorlevel 1 exit /b 1
-\techo.
-\techo.Build finished. Dummy builder generates no files.
-\tgoto end
-)
-
-:end
-'''
-
-# This will become the Makefile template for Sphinx 1.5.
-MAKEFILE_NEW = u'''\
-# Minimal makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-SPHINXPROJ = %(project_fn)s
-SOURCEDIR = %(rsrcdir)s
-BUILDDIR = %(rbuilddir)s
-
-# Has to be explicit, otherwise we don't get "make" without targets right.
-help:
-\t@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
-# You can add custom targets here.
-
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-%%:
-\t@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-'''
-
-# This will become the make.bat template for Sphinx 1.5.
-BATCHFILE_NEW = u'''\
-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%%SPHINXBUILD%%" == "" (
-\tset SPHINXBUILD=sphinx-build
-)
-set SOURCEDIR=%(rsrcdir)s
-set BUILDDIR=%(rbuilddir)s
-set SPHINXPROJ=%(project_fn)s
-
-if "%%1" == "" goto help
-
-%%SPHINXBUILD%% >NUL 2>NUL
-if errorlevel 9009 (
-\techo.
-\techo.The 'sphinx-build' command was not found. Make sure you have Sphinx
-\techo.installed, then set the SPHINXBUILD environment variable to point
-\techo.to the full path of the 'sphinx-build' executable. Alternatively you
-\techo.may add the Sphinx directory to PATH.
-\techo.
-\techo.If you don't have Sphinx installed, grab it from
-\techo.http://sphinx-doc.org/
-\texit /b 1
-)
-
-%%SPHINXBUILD%% -M %%1 %%SOURCEDIR%% %%BUILDDIR%% %%SPHINXOPTS%%
-goto end
-
-:help
-%%SPHINXBUILD%% -M help %%SOURCEDIR%% %%BUILDDIR%% %%SPHINXOPTS%%
-
-:end
-'''
-
def mkdir_p(dir):
if path.isdir(dir):
@@ -1214,15 +174,12 @@ def do_prompt(d, key, text, default=None, validator=nonempty):
d[key] = x
-if PY3:
+def convert_python_source(source, rex=re.compile(r"[uU]('.*?')")):
# remove Unicode literal prefixes
- def _convert_python_source(source, rex=re.compile(r"[uU]('.*?')")):
+ if PY3:
return rex.sub('\\1', source)
-
- for f in ['QUICKSTART_CONF', 'EPUB_CONFIG', 'INTERSPHINX_CONFIG']:
- globals()[f] = _convert_python_source(globals()[f])
-
- del _convert_python_source
+ else:
+ return source
def ask_user(d):
@@ -1402,6 +359,7 @@ directly.''')
def generate(d, overwrite=True, silent=False):
"""Generate project based on values in *d*."""
+ template = SphinxRenderer()
texescape.init()
indent = ' ' * 4
@@ -1411,6 +369,7 @@ def generate(d, overwrite=True, silent=False):
if 'mastertocmaxdepth' not in d:
d['mastertocmaxdepth'] = 2
+ d['PY3'] = PY3
d['project_fn'] = make_filename(d['project'])
d['project_url'] = urlquote(d['project'].encode('idna'))
d['project_manpage'] = d['project_fn'].lower()
@@ -1466,34 +425,33 @@ def generate(d, overwrite=True, silent=False):
else:
print('File %s already exists, skipping.' % fpath)
- conf_text = QUICKSTART_CONF % d
- if d['epub']:
- conf_text += EPUB_CONFIG % d
- if d.get('ext_intersphinx'):
- conf_text += INTERSPHINX_CONFIG
+ with open(os.path.join(package_dir, 'templates', 'quickstart', 'conf.py_t')) as f:
+ conf_text = convert_python_source(f.read())
- write_file(path.join(srcdir, 'conf.py'), conf_text)
+ write_file(path.join(srcdir, 'conf.py'), template.render_string(conf_text, d))
masterfile = path.join(srcdir, d['master'] + d['suffix'])
- write_file(masterfile, MASTER_FILE % d)
+ write_file(masterfile, template.render('quickstart/master_doc.rst_t', d))
if d.get('make_mode') is True:
- makefile_template = MAKEFILE_NEW
- batchfile_template = BATCHFILE_NEW
+ makefile_template = 'quickstart/Makefile.new_t'
+ batchfile_template = 'quickstart/make.bat.new_t'
else:
- makefile_template = MAKEFILE
- batchfile_template = BATCHFILE
+ makefile_template = 'quickstart/Makefile_t'
+ batchfile_template = 'quickstart/make.bat_t'
if d['makefile'] is True:
d['rsrcdir'] = d['sep'] and 'source' or '.'
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
# use binary mode, to avoid writing \r\n on Windows
- write_file(path.join(d['path'], 'Makefile'), makefile_template % d, u'\n')
+ write_file(path.join(d['path'], 'Makefile'),
+ template.render(makefile_template, d), u'\n')
if d['batchfile'] is True:
d['rsrcdir'] = d['sep'] and 'source' or '.'
d['rbuilddir'] = d['sep'] and 'build' or d['dot'] + 'build'
- write_file(path.join(d['path'], 'make.bat'), batchfile_template % d, u'\r\n')
+ write_file(path.join(d['path'], 'make.bat'),
+ template.render(batchfile_template, d), u'\r\n')
if silent:
return