All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 # -*- coding: utf-8 -*-
3 # Configuration file for the Sphinx documentation builder.
5 # This file does only contain a selection of the most common options. For a
6 # full list see the documentation:
7 # http://www.sphinx-doc.org/en/stable/config
9 # -- Path setup --------------------------------------------------------------
11 # If extensions (or modules to document with autodoc) are in another directory,
12 # add these directories to sys.path here. If the directory is relative to the
13 # documentation root, use os.path.abspath to make it absolute, like shown here.
15 from pathlib import Path
20 from setuptools_scm import get_version
21 from recommonmark.parser import CommonMarkParser
24 CURRENT_DIR = Path(__file__).parent
27 def make_pypi_svg(version):
28 template = CURRENT_DIR / "_static" / "pypi_template.svg"
29 target = CURRENT_DIR / "_static" / "pypi.svg"
30 with open(str(template), "r", encoding="utf8") as f:
31 svg = string.Template(f.read()).substitute(version=version)
32 with open(str(target), "w", encoding="utf8") as f:
36 def make_filename(line):
37 non_letters = re.compile(r"[^a-z]+")
38 filename = line[3:].rstrip().lower()
39 filename = non_letters.sub("_", filename)
40 if filename.startswith("_"):
41 filename = filename[1:]
42 if filename.endswith("_"):
43 filename = filename[:-1]
44 return filename + ".md"
47 def generate_sections_from_readme():
48 target_dir = CURRENT_DIR / "_build" / "generated"
49 readme = CURRENT_DIR / ".." / "README.md"
50 shutil.rmtree(str(target_dir), ignore_errors=True)
51 target_dir.mkdir(parents=True)
54 target_dir = target_dir.relative_to(CURRENT_DIR)
55 with open(str(readme), "r", encoding="utf8") as f:
57 if line.startswith("## "):
58 if output is not None:
60 filename = make_filename(line)
61 output_path = CURRENT_DIR / filename
62 if output_path.is_symlink() or output_path.is_file():
64 output_path.symlink_to(target_dir / filename)
65 output = open(str(output_path), "w", encoding="utf8")
67 "[//]: # (NOTE: THIS FILE IS AUTOGENERATED FROM README.md)\n\n"
73 if line.startswith("##"):
79 # -- Project information -----------------------------------------------------
82 copyright = "2018, Łukasz Langa and contributors to Black"
83 author = "Łukasz Langa and contributors to Black"
85 # Autopopulate version
86 # The full version, including alpha/beta/rc tags.
87 release = get_version(root=CURRENT_DIR.parent)
88 # The short X.Y version.
91 version = version.split(sp)[0]
92 make_pypi_svg(release)
93 generate_sections_from_readme()
96 # -- General configuration ---------------------------------------------------
98 # If your documentation needs a minimal Sphinx version, state it here.
100 # needs_sphinx = '1.0'
102 # Add any Sphinx extension module names here, as strings. They can be
103 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
105 extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.napoleon"]
107 # Add any paths that contain templates here, relative to this directory.
108 templates_path = ["_templates"]
110 source_parsers = {".md": CommonMarkParser}
112 # The suffix(es) of source filenames.
113 # You can specify multiple suffix as a list of string:
114 source_suffix = [".rst", ".md"]
116 # The master toctree document.
119 # The language for content autogenerated by Sphinx. Refer to documentation
120 # for a list of supported languages.
122 # This is also used if you do content translation via gettext catalogs.
123 # Usually you set "language" from the command line for these cases.
126 # List of patterns, relative to source directory, that match files and
127 # directories to ignore when looking for source files.
128 # This pattern also affects html_static_path and html_extra_path .
129 exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
131 # The name of the Pygments (syntax highlighting) style to use.
132 pygments_style = "sphinx"
135 # -- Options for HTML output -------------------------------------------------
137 # The theme to use for HTML and HTML Help pages. See the documentation for
138 # a list of builtin themes.
140 html_theme = "alabaster"
152 html_theme_options = {
153 "show_related": False,
154 "description": "“Any color you like.”",
155 "github_button": True,
156 "github_user": "psf",
157 "github_repo": "black",
158 "github_type": "star",
159 "show_powered_by": True,
160 "fixed_sidebar": True,
162 "travis_button": True,
166 # Add any paths that contain custom static files (such as style sheets) here,
167 # relative to this directory. They are copied after the builtin static files,
168 # so a file named "default.css" will overwrite the builtin "default.css".
169 html_static_path = ["_static"]
171 # Custom sidebar templates, must be a dictionary that maps document names
174 # The default sidebars (for documents that don't match any pattern) are
175 # defined by theme itself. Builtin themes are using these templates by
176 # default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
177 # 'searchbox.html']``.
182 # -- Options for HTMLHelp output ---------------------------------------------
184 # Output file base name for HTML help builder.
185 htmlhelp_basename = "blackdoc"
188 # -- Options for LaTeX output ------------------------------------------------
191 # The paper size ('letterpaper' or 'a4paper').
193 # 'papersize': 'letterpaper',
194 # The font size ('10pt', '11pt' or '12pt').
196 # 'pointsize': '10pt',
197 # Additional stuff for the LaTeX preamble.
200 # Latex figure (float) alignment
202 # 'figure_align': 'htbp',
205 # Grouping the document tree into LaTeX files. List of tuples
206 # (source start file, target name, title,
207 # author, documentclass [howto, manual, or own class]).
212 "Documentation for Black",
213 "Łukasz Langa and contributors to Black",
219 # -- Options for manual page output ------------------------------------------
221 # One entry per manual page. List of tuples
222 # (source start file, name, description, authors, manual section).
223 man_pages = [(master_doc, "black", "Documentation for Black", [author], 1)]
226 # -- Options for Texinfo output ----------------------------------------------
228 # Grouping the document tree into Texinfo files. List of tuples
229 # (source start file, target name, title, author,
230 # dir menu entry, description, category)
231 texinfo_documents = [
235 "Documentation for Black",
238 "The uncompromising Python code formatter",
244 # -- Options for Epub output -------------------------------------------------
246 # Bibliographic Dublin Core info.
249 epub_publisher = author
250 epub_copyright = copyright
252 # The unique identifier of the text. This can be a ISBN number
253 # or the project homepage.
255 # epub_identifier = ''
257 # A unique identification for the text.
261 # A list of files that should not be packed into the epub file.
262 epub_exclude_files = ["search.html"]
265 # -- Extension configuration -------------------------------------------------
267 autodoc_member_order = "bysource"
269 # -- Options for intersphinx extension ---------------------------------------
271 # Example configuration for intersphinx: refer to the Python standard library.
272 intersphinx_mapping = {"https://docs.python.org/3/": None}