Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 37a0020

Browse files
authoredAug 20, 2020
Upgrade docs to Sphinx 3+ and add doc build test (#1613)
* Upgrade docs to Sphinx 3+ * Fix all the warnings... - Fixed bad docstrings - Fixed bad fenced code blocks in documentation - Blocklisted some sections from being generated from the README - Added missing documentation to index.rst - Fixed an invalid autofunction directive in reference/reference_functions.rst - Pin another documentation dependency * Add documentation build test
1 parent e5bb92f commit 37a0020

File tree

9 files changed

+75
-21
lines changed

9 files changed

+75
-21
lines changed
 

‎.github/workflows/doc.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Documentation Build
2+
3+
on:
4+
push:
5+
paths:
6+
- "docs/**"
7+
- "README.md"
8+
- "CHANGES.md"
9+
- "CONTRIBUTING.md"
10+
pull_request:
11+
paths:
12+
- "docs/**"
13+
- "README.md"
14+
- "CHANGES.md"
15+
- "CONTRIBUTING.md"
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up Python 3.8
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.8
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip setuptools wheel
32+
python -m pip install -e "."
33+
python -m pip install -r "docs/requirements.txt"
34+
35+
- name: Build documentation
36+
run: sphinx-build -a -b html -W docs/ docs/_build/

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Twisted and CPython:
464464

465465
Use the badge in your project's README.md:
466466

467-
```markdown
467+
```md
468468
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
469469
```
470470

@@ -625,7 +625,7 @@ Multiple contributions by:
625625
- [Miroslav Shubernetskiy](mailto:miroslav@miki725.com)
626626
- MomIsBestFriend
627627
- [Nathan Goldbaum](mailto:ngoldbau@illinois.edu)
628-
- [Nathan Hunt](mailtoneighthan.hunt@gmail.com)
628+
- [Nathan Hunt](mailto:neighthan.hunt@gmail.com)
629629
- [Neraste](mailto:neraste.herr10@gmail.com)
630630
- [Nikolaus Waxweiler](mailto:madigens@gmail.com)
631631
- [Ofek Lev](mailto:ofekmeister@gmail.com)

‎docs/black_primer.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ each parameter is explained below:
7171
"expect_formatting_changes": true,
7272
"git_clone_url": "https://github.com/cooperlees/aioexabgp.git",
7373
"long_checkout": false,
74-
"py_versions": ["all", "3.8"] // "all" ignores all other versions
74+
"py_versions": ["all", "3.8"]
7575
}
7676
}
7777
}
@@ -103,9 +103,9 @@ Failed projects:
103103
+++ tests/b303_b304.py 2020-05-17 20:06:42.753851 +0000
104104
@@ -26,11 +26,11 @@
105105
maxint = 5 # this is okay
106-
# the following shouldn't crash
106+
# the following should not crash
107107
(a, b, c) = list(range(3))
108-
# it's different than this
108+
# it is different than this
109109
a, b, c = list(range(3))
110110
- a, b, c, = list(range(3))
111111
+ a, b, c = list(range(3))

‎docs/compatible_configs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ characters via `max-line-length = 88`.
241241
<details>
242242
<summary>pylintrc</summary>
243243

244-
```rc
244+
```ini
245245
[MESSAGES CONTROL]
246246
disable = C0330, C0326
247247

‎docs/conf.py

+26-11
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@
1717
import string
1818
from typing import Callable, List, Optional, Pattern, Tuple, Set
1919
from dataclasses import dataclass
20-
import os
2120
import logging
2221

2322
from pkg_resources import get_distribution
24-
from recommonmark.parser import CommonMarkParser
2523

2624
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)
2725

2826
LOG = logging.getLogger(__name__)
2927

30-
# Get a relative path so logs printing out SRC isn't too long.
31-
CURRENT_DIR = Path(__file__).parent.relative_to(os.getcwd())
28+
CURRENT_DIR = Path(__file__).parent
3229
README = CURRENT_DIR / ".." / "README.md"
3330
REFERENCE_DIR = CURRENT_DIR / "reference"
3431
STATIC_DIR = CURRENT_DIR / "_static"
@@ -200,7 +197,7 @@ def process_sections(
200197
# -- Project information -----------------------------------------------------
201198

202199
project = "Black"
203-
copyright = "2018, Łukasz Langa and contributors to Black"
200+
copyright = "2020, Łukasz Langa and contributors to Black"
204201
author = "Łukasz Langa and contributors to Black"
205202

206203
# Autopopulate version
@@ -213,36 +210,54 @@ def process_sections(
213210

214211
custom_sections = [
215212
DocSection("the_black_code_style", CURRENT_DIR / "the_black_code_style.md",),
216-
DocSection("pragmatism", CURRENT_DIR / "the_black_code_style.md",),
217213
DocSection("editor_integration", CURRENT_DIR / "editor_integration.md"),
218214
DocSection("blackd", CURRENT_DIR / "blackd.md"),
219215
DocSection("black_primer", CURRENT_DIR / "black_primer.md"),
220216
DocSection("contributing_to_black", CURRENT_DIR / ".." / "CONTRIBUTING.md"),
221217
DocSection("change_log", CURRENT_DIR / ".." / "CHANGES.md"),
222218
]
223219

220+
# Sphinx complains when there is a source file that isn't referenced in any of the docs.
221+
# Since some sections autogenerated from the README are unused warnings will appear.
222+
#
223+
# Sections must be listed to what their name is when passed through make_filename().
224+
blocklisted_sections_from_readme = {
225+
"license",
226+
"pragmatism",
227+
"testimonials",
228+
"used_by",
229+
}
224230

225231
make_pypi_svg(release)
226232
readme_sections = get_sections_from_readme()
233+
readme_sections = [
234+
x for x in readme_sections if x.name not in blocklisted_sections_from_readme
235+
]
236+
227237
process_sections(custom_sections, readme_sections)
228238

229239

230240
# -- General configuration ---------------------------------------------------
231241

232242
# If your documentation needs a minimal Sphinx version, state it here.
233-
#
234-
# needs_sphinx = '1.0'
243+
needs_sphinx = "3.0"
235244

236245
# Add any Sphinx extension module names here, as strings. They can be
237246
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
238247
# ones.
239-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx.ext.napoleon"]
248+
extensions = [
249+
"sphinx.ext.autodoc",
250+
"sphinx.ext.intersphinx",
251+
"sphinx.ext.napoleon",
252+
"recommonmark",
253+
]
254+
255+
# If you need extensions of a certain version or higher, list them here.
256+
needs_extensions = {"recommonmark": "0.5"}
240257

241258
# Add any paths that contain templates here, relative to this directory.
242259
templates_path = ["_templates"]
243260

244-
source_parsers = {".md": CommonMarkParser}
245-
246261
# The suffix(es) of source filenames.
247262
# You can specify multiple suffix as a list of string:
248263
source_suffix = [".rst", ".md"]

‎docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ Contents
5151
installation_and_usage
5252
the_black_code_style
5353
pyproject_toml
54+
compatible_configs
5455
editor_integration
5556
blackd
5657
black_primer
5758
version_control_integration
59+
github_actions
5860
ignoring_unmodified_files
5961
contributing_to_black
6062
show_your_style
@@ -66,5 +68,4 @@ Indices and tables
6668
==================
6769

6870
* :ref:`genindex`
69-
* :ref:`modindex`
7071
* :ref:`search`

‎docs/reference/reference_functions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Split functions
8989

9090
.. autofunction:: black.standalone_comment_split
9191

92-
.. autofunction:: black.split_line
92+
.. autofunction:: black.transform_line
9393

9494
Caching
9595
-------

‎docs/requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
recommonmark==0.4.0
2-
Sphinx==1.7.2
1+
recommonmark==0.6.0
2+
Sphinx==3.2.1
3+
Pygments==2.6.1

‎src/black/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ def f(arg: str = "") -> None:
952952
...
953953
954954
A more complex example:
955+
955956
>>> print(
956957
... black.format_str(
957958
... "def f(arg:str='')->None: hey",

0 commit comments

Comments
 (0)
Please sign in to comment.