]> git.madduck.net Git - etc/vim.git/blob - docs/conf.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

ce7536defbd6417be7c62c8fcbbba3c899bc41b0
[etc/vim.git] / docs / conf.py
1 # -*- coding: utf-8 -*-
2 #
3 # Configuration file for the Sphinx documentation builder.
4 #
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
8
9 # -- Path setup --------------------------------------------------------------
10
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.
14 #
15 from pathlib import Path
16 import regex as re
17 import shutil
18 import string
19
20 from setuptools_scm import get_version
21 from recommonmark.parser import CommonMarkParser
22
23
24 CURRENT_DIR = Path(__file__).parent
25
26
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:
33         f.write(svg)
34
35
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"
45
46
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)
52
53     output = None
54     target_dir = target_dir.relative_to(CURRENT_DIR)
55     with open(str(readme), "r", encoding="utf8") as f:
56         for line in f:
57             if line.startswith("## "):
58                 if output is not None:
59                     output.close()
60                 filename = make_filename(line)
61                 output_path = CURRENT_DIR / filename
62                 if output_path.is_symlink() or output_path.is_file():
63                     output_path.unlink()
64                 output_path.symlink_to(target_dir / filename)
65                 output = open(str(output_path), "w", encoding="utf8")
66                 output.write(
67                     "[//]: # (NOTE: THIS FILE IS AUTOGENERATED FROM README.md)\n\n"
68                 )
69
70             if output is None:
71                 continue
72
73             if line.startswith("##"):
74                 line = line[1:]
75
76             output.write(line)
77
78
79 # -- Project information -----------------------------------------------------
80
81 project = "Black"
82 copyright = "2018, Łukasz Langa and contributors to Black"
83 author = "Łukasz Langa and contributors to Black"
84
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.
89 version = release
90 for sp in "abcfr":
91     version = version.split(sp)[0]
92 make_pypi_svg(release)
93 generate_sections_from_readme()
94
95
96 # -- General configuration ---------------------------------------------------
97
98 # If your documentation needs a minimal Sphinx version, state it here.
99 #
100 # needs_sphinx = '1.0'
101
102 # Add any Sphinx extension module names here, as strings. They can be
103 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
104 # ones.
105 extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.napoleon"]
106
107 # Add any paths that contain templates here, relative to this directory.
108 templates_path = ["_templates"]
109
110 source_parsers = {".md": CommonMarkParser}
111
112 # The suffix(es) of source filenames.
113 # You can specify multiple suffix as a list of string:
114 source_suffix = [".rst", ".md"]
115
116 # The master toctree document.
117 master_doc = "index"
118
119 # The language for content autogenerated by Sphinx. Refer to documentation
120 # for a list of supported languages.
121 #
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.
124 language = None
125
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"]
130
131 # The name of the Pygments (syntax highlighting) style to use.
132 pygments_style = "sphinx"
133
134
135 # -- Options for HTML output -------------------------------------------------
136
137 # The theme to use for HTML and HTML Help pages.  See the documentation for
138 # a list of builtin themes.
139 #
140 html_theme = "alabaster"
141
142 html_sidebars = {
143     "**": [
144         "about.html",
145         "navigation.html",
146         "relations.html",
147         "sourcelink.html",
148         "searchbox.html",
149     ]
150 }
151
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,
161     "logo": "logo2.png",
162     "travis_button": True,
163 }
164
165
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"]
170
171 # Custom sidebar templates, must be a dictionary that maps document names
172 # to template names.
173 #
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']``.
178 #
179 # html_sidebars = {}
180
181
182 # -- Options for HTMLHelp output ---------------------------------------------
183
184 # Output file base name for HTML help builder.
185 htmlhelp_basename = "blackdoc"
186
187
188 # -- Options for LaTeX output ------------------------------------------------
189
190 latex_elements = {
191     # The paper size ('letterpaper' or 'a4paper').
192     #
193     # 'papersize': 'letterpaper',
194     # The font size ('10pt', '11pt' or '12pt').
195     #
196     # 'pointsize': '10pt',
197     # Additional stuff for the LaTeX preamble.
198     #
199     # 'preamble': '',
200     # Latex figure (float) alignment
201     #
202     # 'figure_align': 'htbp',
203 }
204
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]).
208 latex_documents = [
209     (
210         master_doc,
211         "black.tex",
212         "Documentation for Black",
213         "Łukasz Langa and contributors to Black",
214         "manual",
215     )
216 ]
217
218
219 # -- Options for manual page output ------------------------------------------
220
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)]
224
225
226 # -- Options for Texinfo output ----------------------------------------------
227
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 = [
232     (
233         master_doc,
234         "Black",
235         "Documentation for Black",
236         author,
237         "Black",
238         "The uncompromising Python code formatter",
239         "Miscellaneous",
240     )
241 ]
242
243
244 # -- Options for Epub output -------------------------------------------------
245
246 # Bibliographic Dublin Core info.
247 epub_title = project
248 epub_author = author
249 epub_publisher = author
250 epub_copyright = copyright
251
252 # The unique identifier of the text. This can be a ISBN number
253 # or the project homepage.
254 #
255 # epub_identifier = ''
256
257 # A unique identification for the text.
258 #
259 # epub_uid = ''
260
261 # A list of files that should not be packed into the epub file.
262 epub_exclude_files = ["search.html"]
263
264
265 # -- Extension configuration -------------------------------------------------
266
267 autodoc_member_order = "bysource"
268
269 # -- Options for intersphinx extension ---------------------------------------
270
271 # Example configuration for intersphinx: refer to the Python standard library.
272 intersphinx_mapping = {"https://docs.python.org/3/": None}