mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add sphinx.ext.githubpages to publish the docs on GitHub Pages
This commit is contained in:
parent
ddf6acd33c
commit
0ea518d563
12
doc/ext/githubpages.rst
Normal file
12
doc/ext/githubpages.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.. highlight:: rest
|
||||||
|
|
||||||
|
:mod:`sphinx.ext.githubpages` -- Publish HTML docs in GitHub Pages
|
||||||
|
==================================================================
|
||||||
|
|
||||||
|
.. module:: sphinx.ext.githubpages
|
||||||
|
:synopsis: Publish HTML docs in GitHub Pages
|
||||||
|
|
||||||
|
.. versionadded:: 1.4
|
||||||
|
|
||||||
|
This extension creates ``.nojekyll`` file on generated HTML directory to publish
|
||||||
|
the document on GitHub Pages.
|
@ -32,6 +32,7 @@ These extensions are built in and can be activated by respective entries in the
|
|||||||
ext/viewcode
|
ext/viewcode
|
||||||
ext/linkcode
|
ext/linkcode
|
||||||
ext/napoleon
|
ext/napoleon
|
||||||
|
ext/githubpages
|
||||||
|
|
||||||
|
|
||||||
Third-party extensions
|
Third-party extensions
|
||||||
|
24
sphinx/ext/githubpages.py
Normal file
24
sphinx/ext/githubpages.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
sphinx.ext.githubpages
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
To publish HTML docs at GitHub Pages, create .nojekyll file.
|
||||||
|
|
||||||
|
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sphinx
|
||||||
|
|
||||||
|
|
||||||
|
def create_nojekyll(app, env):
|
||||||
|
if app.builder.format == 'html':
|
||||||
|
path = os.path.join(app.builder.outdir, '.nojekyll')
|
||||||
|
open(path, 'wt').close()
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
app.connect('env-updated', create_nojekyll)
|
||||||
|
return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
|
@ -60,7 +60,7 @@ DEFAULT_VALUE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
|
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
|
||||||
'imgmath', 'mathjax', 'ifconfig', 'viewcode')
|
'imgmath', 'mathjax', 'ifconfig', 'viewcode', 'githubpages')
|
||||||
|
|
||||||
PROMPT_PREFIX = '> '
|
PROMPT_PREFIX = '> '
|
||||||
|
|
||||||
@ -1271,6 +1271,9 @@ imgmath has been deselected.''')
|
|||||||
if 'ext_viewcode' not in d:
|
if 'ext_viewcode' not in d:
|
||||||
do_prompt(d, 'ext_viewcode', 'viewcode: include links to the source '
|
do_prompt(d, 'ext_viewcode', 'viewcode: include links to the source '
|
||||||
'code of documented Python objects (y/n)', 'n', boolean)
|
'code of documented Python objects (y/n)', 'n', boolean)
|
||||||
|
if 'ext_githubpages' not in d:
|
||||||
|
do_prompt(d, 'ext_githubpages', 'githubpages: create .nojekyll file '
|
||||||
|
'to publish the document on GitHub pages (y/n)', 'n', boolean)
|
||||||
|
|
||||||
if 'no_makefile' in d:
|
if 'no_makefile' in d:
|
||||||
d['makefile'] = False
|
d['makefile'] = False
|
||||||
|
4
tests/roots/test-ext-githubpages/conf.py
Normal file
4
tests/roots/test-ext-githubpages/conf.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
extensions = ['sphinx.ext.githubpages']
|
||||||
|
master_doc = 'index'
|
3
tests/roots/test-ext-githubpages/index.rst
Normal file
3
tests/roots/test-ext-githubpages/index.rst
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
githubpages
|
||||||
|
===========
|
||||||
|
|
20
tests/test_ext_githubpages.py
Normal file
20
tests/test_ext_githubpages.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
test_ext_githubpages
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Test sphinx.ext.githubpages extension.
|
||||||
|
|
||||||
|
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
|
||||||
|
:license: BSD, see LICENSE for details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from util import with_app
|
||||||
|
|
||||||
|
|
||||||
|
@with_app('html', testroot='ext-githubpages')
|
||||||
|
def test_githubpages(app, status, warning):
|
||||||
|
app.builder.build_all()
|
||||||
|
assert (app.outdir / '.nojekyll').exists()
|
@ -185,6 +185,7 @@ def test_quickstart_all_answers(tempdir):
|
|||||||
'mathjax': 'no',
|
'mathjax': 'no',
|
||||||
'ifconfig': 'no',
|
'ifconfig': 'no',
|
||||||
'viewcode': 'no',
|
'viewcode': 'no',
|
||||||
|
'githubpages': 'no',
|
||||||
'Create Makefile': 'no',
|
'Create Makefile': 'no',
|
||||||
'Create Windows command file': 'no',
|
'Create Windows command file': 'no',
|
||||||
'Do you want to use the epub builder': 'yes',
|
'Do you want to use the epub builder': 'yes',
|
||||||
|
Loading…
Reference in New Issue
Block a user