summaryrefslogtreecommitdiff
path: root/sphinx/ext/githubpages.py
blob: 1b1a604eb3615689c61ed24b3d70737b8a488030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
    sphinx.ext.githubpages
    ~~~~~~~~~~~~~~~~~~~~~~

    To publish HTML docs at GitHub Pages, create .nojekyll file.

    :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import os

import sphinx

if False:
    # For type annotation
    from typing import Any, Dict  # NOQA
    from sphinx.application import Sphinx  # NOQA
    from sphinx.environment import BuildEnvironment  # NOQA


def create_nojekyll(app, env):
    # type: (Sphinx, BuildEnvironment) -> None
    if app.builder.format == 'html':
        path = os.path.join(app.builder.outdir, '.nojekyll')
        open(path, 'wt').close()


def setup(app):
    # type: (Sphinx) -> Dict[str, Any]
    app.connect('env-updated', create_nojekyll)
    return {'version': sphinx.__display_version__, 'parallel_read_safe': True}