|
31 | 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom |
32 | 32 | # ones. |
33 | 33 | extensions = [ |
| 34 | + 'sphinx.ext.extlinks', |
34 | 35 | 'sphinx.ext.intersphinx', |
35 | 36 | 'sphinx.ext.todo', |
36 | 37 | ] |
|
51 | 52 | # The master toctree document. |
52 | 53 | master_doc = 'index' |
53 | 54 |
|
| 55 | +# -- Project information ----------------------------------------------------- |
| 56 | + |
| 57 | +github_url = 'https://github.com' |
| 58 | +github_repo_org = 'pypa' |
| 59 | +github_repo_name = 'packaging.python.org' |
| 60 | +github_repo_slug = f'{github_repo_org}/{github_repo_name}' |
| 61 | +github_repo_url = f'{github_url}/{github_repo_slug}' |
| 62 | +github_repo_issues_url = f'{github_url}/{github_repo_slug}/issues' |
| 63 | +github_sponsors_url = f'{github_url}/sponsors' |
| 64 | + |
54 | 65 | # General information about the project. |
55 | 66 | project = u'Python Packaging User Guide' |
56 | | -copyright = u'2013–2019, PyPA' |
| 67 | +copyright = u'2013–2020, PyPA' |
57 | 68 | author = 'Python Packaging Authority' |
58 | 69 |
|
59 | 70 | # The version info for the project you're documenting, acts as replacement for |
|
88 | 99 |
|
89 | 100 | # The reST default role (used for this markup: `text`) to use for all |
90 | 101 | # documents. |
91 | | -# |
92 | | -# default_role = None |
| 102 | +# Ref: python-attrs/attrs#571 |
| 103 | +default_role = 'any' # makes single backticks autofind targets |
93 | 104 |
|
94 | 105 | # If true, '()' will be appended to :func: etc. cross-reference text. |
95 | 106 | # |
|
132 | 143 | 'collapsiblesidebar': True, |
133 | 144 | 'externalrefs': True, |
134 | 145 | 'navigation_depth': 2, |
135 | | - 'issues_url': 'https://github.com/pypa/python-packaging-user-guide/issues' |
| 146 | + 'issues_url': github_repo_issues_url, |
136 | 147 | } |
137 | 148 |
|
138 | 149 | # Add any paths that contain custom themes here, relative to this directory. |
|
185 | 196 |
|
186 | 197 | # Custom sidebar templates, filenames relative to this file. |
187 | 198 | html_sidebars = { |
188 | | - '**': ['localtoc.html', 'relations.html'], |
189 | | - 'index': ['localtoc.html'] |
| 199 | + '**': ['globaltoc.html', 'relations.html'], |
| 200 | + 'index': ['globaltoc.html'] |
190 | 201 | } |
191 | 202 |
|
192 | 203 | # Additional templates that should be rendered to pages, maps page names to |
|
350 | 361 | # |
351 | 362 | # texinfo_no_detailmenu = False |
352 | 363 |
|
| 364 | +# -- Options for extlinks extension --------------------------------------- |
| 365 | +extlinks = { |
| 366 | + 'issue': (f'{github_repo_issues_url}/%s', '#'), # noqa: WPS323 |
| 367 | + 'pr': (f'{github_repo_url}/pull/%s', 'PR #'), # noqa: WPS323 |
| 368 | + 'commit': (f'{github_repo_url}/commit/%s', ''), # noqa: WPS323 |
| 369 | + 'gh': (f'{github_url}/%s', 'GitHub: '), # noqa: WPS323 |
| 370 | + 'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 |
| 371 | +} |
| 372 | + |
353 | 373 | # Example configuration for intersphinx: refer to the Python standard library. |
354 | 374 | intersphinx_mapping = { |
355 | | - 'python': ('https://docs.python.org/3.6', None), |
| 375 | + 'python': ('https://docs.python.org/3', None), |
| 376 | + 'python2': ('https://docs.python.org/2', None), |
356 | 377 | 'pip': ('https://pip.pypa.io/en/latest/', None), |
357 | 378 | } |
358 | 379 |
|
|
362 | 383 |
|
363 | 384 | todo_include_todos = True |
364 | 385 |
|
365 | | -# Configure the GitHub PR role to point to our project. |
366 | | - |
367 | | -pr_role_github_org_and_project = 'pypa/python-packaging-user-guide' |
368 | | - |
369 | | -# |
370 | | -# Custom plugin code below. |
371 | | -# |
372 | | - |
373 | | - |
374 | | -def setup(app): |
375 | | - app.add_config_value('pr_role_github_org_and_project', None, 'html') |
376 | | - app.add_role('pr', pr_role) |
377 | | - |
378 | | - |
379 | | -def pr_role(name, rawtext, text, lineno, inliner, options={}, content=[]): |
380 | | - """Transforms ':pr:`number`'' to a hyperlink to the referenced pull request |
381 | | - on GitHub.""" |
382 | | - from docutils import nodes |
383 | | - |
384 | | - app = inliner.document.settings.env |
385 | | - project = app.config.pr_role_github_org_and_project |
386 | | - title = '#{}'.format(text) |
387 | | - |
388 | | - uri = 'https://github.com/{}/pull/{}'.format(project, text) |
389 | | - rn = nodes.reference( |
390 | | - title, title, internal=False, refuri=uri, classes=['pr']) |
391 | | - return [rn], [] |
| 386 | +nitpicky = True |
| 387 | + |
| 388 | +# NOTE: consider having a separate ignore file |
| 389 | +# Ref: https://stackoverflow.com/a/30624034/595220 |
| 390 | +nitpick_ignore = [ |
| 391 | + ('envvar', 'PATH'), |
| 392 | + ('py:func', 'find_packages'), |
| 393 | + ('py:func', 'pkg_resources.iter_entry_points'), |
| 394 | + ('py:func', 'setup'), |
| 395 | + ('py:func', 'setuptools.find_namespace_packages'), |
| 396 | + ('py:func', 'setuptools.find_packages'), |
| 397 | + ('py:func', 'setuptools.setup'), |
| 398 | +] |
0 commit comments