mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merged in mcmtroffaes/sphinx-html-extra-path (pull request #158)
Add html_extra_path option to copy additional files ad verbatim to the output root folder.
This commit is contained in:
commit
7c7c5af02a
@ -509,10 +509,11 @@ that use Sphinx' HTMLWriter class.
|
|||||||
|
|
||||||
.. confval:: html_static_path
|
.. confval:: html_static_path
|
||||||
|
|
||||||
A list of paths that contain custom static files (such as style sheets or
|
A list of paths that contain custom static files (such as style
|
||||||
script files). Relative paths are taken as relative to the configuration
|
sheets or script files). Relative paths are taken as relative to
|
||||||
directory. They are copied to the output directory after the theme's static
|
the configuration directory. They are copied to the output's
|
||||||
files, so a file named :file:`default.css` will overwrite the theme's
|
:file:`_static` directory after the theme's static files, so a file
|
||||||
|
named :file:`default.css` will overwrite the theme's
|
||||||
:file:`default.css`.
|
:file:`default.css`.
|
||||||
|
|
||||||
.. versionchanged:: 0.4
|
.. versionchanged:: 0.4
|
||||||
@ -521,6 +522,19 @@ that use Sphinx' HTMLWriter class.
|
|||||||
.. versionchanged:: 1.0
|
.. versionchanged:: 1.0
|
||||||
The entries in :confval:`html_static_path` can now be single files.
|
The entries in :confval:`html_static_path` can now be single files.
|
||||||
|
|
||||||
|
.. confval:: html_extra_path
|
||||||
|
|
||||||
|
A list of paths that contain extra files not directly related to
|
||||||
|
the documentation, such as :file:`robots.txt` or :file:`.htaccess`.
|
||||||
|
Relative paths are taken as relative to the configuration
|
||||||
|
directory. They are copied to the output directory. They will
|
||||||
|
overwrite any existing file of the same name.
|
||||||
|
|
||||||
|
As these files are not meant to be built, they are automatically added to
|
||||||
|
:confval:`exclude_patterns`.
|
||||||
|
|
||||||
|
.. versionadded:: 1.2
|
||||||
|
|
||||||
.. confval:: html_last_updated_fmt
|
.. confval:: html_last_updated_fmt
|
||||||
|
|
||||||
If this is not the empty string, a 'Last updated on:' timestamp is inserted
|
If this is not the empty string, a 'Last updated on:' timestamp is inserted
|
||||||
|
@ -480,6 +480,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
self.copy_image_files()
|
self.copy_image_files()
|
||||||
self.copy_download_files()
|
self.copy_download_files()
|
||||||
self.copy_static_files()
|
self.copy_static_files()
|
||||||
|
self.copy_extra_files()
|
||||||
self.write_buildinfo()
|
self.write_buildinfo()
|
||||||
|
|
||||||
# dump the search index
|
# dump the search index
|
||||||
@ -607,6 +608,17 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
icontarget)
|
icontarget)
|
||||||
self.info('done')
|
self.info('done')
|
||||||
|
|
||||||
|
def copy_extra_files(self):
|
||||||
|
# copy html_extra_path files
|
||||||
|
self.info(bold('copying extra files... '), nonl=True)
|
||||||
|
extraentries = [path.join(self.confdir, epath)
|
||||||
|
for epath in self.config.html_extra_path]
|
||||||
|
for entry in extraentries:
|
||||||
|
if not path.exists(entry):
|
||||||
|
self.warn('html_extra_path entry %r does not exist' % entry)
|
||||||
|
continue
|
||||||
|
copy_static_entry(entry, self.outdir, self)
|
||||||
|
|
||||||
def write_buildinfo(self):
|
def write_buildinfo(self):
|
||||||
# write build info file
|
# write build info file
|
||||||
fp = open(path.join(self.outdir, '.buildinfo'), 'w')
|
fp = open(path.join(self.outdir, '.buildinfo'), 'w')
|
||||||
|
@ -86,6 +86,7 @@ class Config(object):
|
|||||||
html_logo = (None, 'html'),
|
html_logo = (None, 'html'),
|
||||||
html_favicon = (None, 'html'),
|
html_favicon = (None, 'html'),
|
||||||
html_static_path = ([], 'html'),
|
html_static_path = ([], 'html'),
|
||||||
|
html_extra_path = ([], 'html'),
|
||||||
# the real default is locale-dependent
|
# the real default is locale-dependent
|
||||||
html_last_updated_fmt = (None, 'html'),
|
html_last_updated_fmt = (None, 'html'),
|
||||||
html_use_smartypants = (True, 'html'),
|
html_use_smartypants = (True, 'html'),
|
||||||
|
@ -335,6 +335,7 @@ class BuildEnvironment:
|
|||||||
"""
|
"""
|
||||||
matchers = compile_matchers(
|
matchers = compile_matchers(
|
||||||
config.exclude_patterns[:] +
|
config.exclude_patterns[:] +
|
||||||
|
config.html_extra_path +
|
||||||
config.exclude_trees +
|
config.exclude_trees +
|
||||||
[d + config.source_suffix for d in config.unused_docs] +
|
[d + config.source_suffix for d in config.unused_docs] +
|
||||||
['**/' + d for d in config.exclude_dirnames] +
|
['**/' + d for d in config.exclude_dirnames] +
|
||||||
|
@ -171,6 +171,11 @@ html_theme = 'default'
|
|||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ['%(dot)sstatic']
|
html_static_path = ['%(dot)sstatic']
|
||||||
|
|
||||||
|
# Add any extra paths that contain custom files (such as robots.txt or
|
||||||
|
# .htaccess) here, relative to this directory. These files are copied
|
||||||
|
# directly to the root of the documentation.
|
||||||
|
#html_extra_path = []
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
#html_last_updated_fmt = '%%b %%d, %%Y'
|
#html_last_updated_fmt = '%%b %%d, %%Y'
|
||||||
|
@ -38,6 +38,7 @@ html_sidebars = {'**': 'customsb.html',
|
|||||||
'contents': ['contentssb.html', 'localtoc.html'] }
|
'contents': ['contentssb.html', 'localtoc.html'] }
|
||||||
html_style = 'default.css'
|
html_style = 'default.css'
|
||||||
html_static_path = ['_static', 'templated.css_t']
|
html_static_path = ['_static', 'templated.css_t']
|
||||||
|
html_extra_path = ['robots.txt']
|
||||||
html_last_updated_fmt = '%b %d, %Y'
|
html_last_updated_fmt = '%b %d, %Y'
|
||||||
html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'}
|
html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'}
|
||||||
|
|
||||||
|
2
tests/root/robots.txt
Normal file
2
tests/root/robots.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
User-agent: *
|
||||||
|
Disallow: /cgi-bin/
|
@ -320,6 +320,9 @@ def check_static_entries(outdir):
|
|||||||
# a file from _static, but matches exclude_patterns
|
# a file from _static, but matches exclude_patterns
|
||||||
assert not (staticdir / 'excluded.css').exists()
|
assert not (staticdir / 'excluded.css').exists()
|
||||||
|
|
||||||
|
def check_extra_entries(outdir):
|
||||||
|
assert (outdir / 'robots.txt').isfile()
|
||||||
|
|
||||||
@gen_with_app(buildername='html', warning=html_warnfile, cleanenv=True,
|
@gen_with_app(buildername='html', warning=html_warnfile, cleanenv=True,
|
||||||
confoverrides={'html_context.hckey_co': 'hcval_co'},
|
confoverrides={'html_context.hckey_co': 'hcval_co'},
|
||||||
tags=['testtag'])
|
tags=['testtag'])
|
||||||
@ -345,6 +348,7 @@ def test_html(app):
|
|||||||
yield check_xpath, etree, fname, path, check
|
yield check_xpath, etree, fname, path, check
|
||||||
|
|
||||||
check_static_entries(app.builder.outdir)
|
check_static_entries(app.builder.outdir)
|
||||||
|
check_extra_entries(app.builder.outdir)
|
||||||
|
|
||||||
@with_app(buildername='html', srcdir='(empty)',
|
@with_app(buildername='html', srcdir='(empty)',
|
||||||
confoverrides={'html_sidebars': {'*': ['globaltoc.html']}},
|
confoverrides={'html_sidebars': {'*': ['globaltoc.html']}},
|
||||||
|
Loading…
Reference in New Issue
Block a user