mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add html_short_title and html_show_sphinx config values.
This commit is contained in:
parent
316d9e3e88
commit
02b529bf52
11
CHANGES
11
CHANGES
@ -19,6 +19,15 @@ New features added
|
|||||||
|
|
||||||
* The directories in the `html_static_path` can now contain subdirectories.
|
* The directories in the `html_static_path` can now contain subdirectories.
|
||||||
|
|
||||||
|
* The new config value `html_short_title` can be used to set a shorter
|
||||||
|
title for the documentation which is then used in the navigation bar.
|
||||||
|
|
||||||
|
* The new config value `html_show_sphinx` can be used to control whether
|
||||||
|
a link to Sphinx is added to the HTML footer.
|
||||||
|
|
||||||
|
* Defaults for configuration values can now be callables, which allows
|
||||||
|
dynamic defaults.
|
||||||
|
|
||||||
Bugs fixed
|
Bugs fixed
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@ -40,7 +49,7 @@ Bugs fixed
|
|||||||
|
|
||||||
* Fix behavior of references to functions/methods with an explicit title.
|
* Fix behavior of references to functions/methods with an explicit title.
|
||||||
|
|
||||||
* Support citation nodes in LaTeX writer.
|
* Support citation nodes in LaTeX writer.M v7
|
||||||
|
|
||||||
|
|
||||||
Release 0.3 (May 6, 2008)
|
Release 0.3 (May 6, 2008)
|
||||||
|
@ -182,6 +182,14 @@ that use Sphinx' HTMLWriter class.
|
|||||||
v{<revision>} documentation'`, where the placeholders are replaced by the
|
v{<revision>} documentation'`, where the placeholders are replaced by the
|
||||||
config values of the same name.
|
config values of the same name.
|
||||||
|
|
||||||
|
.. confval:: html_short_title
|
||||||
|
|
||||||
|
A shorter "title" for the HTML docs. This is used in for links in the header
|
||||||
|
and in the HTML Help docs. If not given, it defaults to the value of
|
||||||
|
:confval:`html_title`.
|
||||||
|
|
||||||
|
.. versionadded:: 0.4
|
||||||
|
|
||||||
.. confval:: html_style
|
.. confval:: html_style
|
||||||
|
|
||||||
The style sheet to use for HTML pages. A file of that name must exist either
|
The style sheet to use for HTML pages. A file of that name must exist either
|
||||||
@ -293,6 +301,13 @@ that use Sphinx' HTMLWriter class.
|
|||||||
to translate document trees to HTML. Default is ``None`` (use the builtin
|
to translate document trees to HTML. Default is ``None`` (use the builtin
|
||||||
translator).
|
translator).
|
||||||
|
|
||||||
|
.. confval:: html_show_sphinx
|
||||||
|
|
||||||
|
If true, "Created using Sphinx" is shown in the HTML footer. Default is
|
||||||
|
``True``.
|
||||||
|
|
||||||
|
.. versionadded:: 0.4
|
||||||
|
|
||||||
.. confval:: htmlhelp_basename
|
.. confval:: htmlhelp_basename
|
||||||
|
|
||||||
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
||||||
|
@ -24,6 +24,11 @@ the following public API:
|
|||||||
in the setting only takes effect when a document is parsed -- this means that
|
in the setting only takes effect when a document is parsed -- this means that
|
||||||
the whole environment must be rebuilt.
|
the whole environment must be rebuilt.
|
||||||
|
|
||||||
|
.. versionchanged:: 0.4
|
||||||
|
If the *default* value is a callable, it will be called with the config
|
||||||
|
object as its argument in order to get the default value. This can be
|
||||||
|
used to implement config values whose default depends on other values.
|
||||||
|
|
||||||
.. method:: Sphinx.add_event(name)
|
.. method:: Sphinx.add_event(name)
|
||||||
|
|
||||||
Register an event called *name*.
|
Register an event called *name*.
|
||||||
@ -43,7 +48,7 @@ the following public API:
|
|||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
.. XXX once we target docutils 0.5, update this
|
.. XXX once we target docutils 0.5, update this
|
||||||
|
|
||||||
.. method:: Sphinx.add_role(name, role)
|
.. method:: Sphinx.add_role(name, role)
|
||||||
|
|
||||||
Register a Docutils role. *name* must be the role name that occurs in the
|
Register a Docutils role. *name* must be the role name that occurs in the
|
||||||
|
@ -79,16 +79,12 @@ class Sphinx(object):
|
|||||||
setattr(self.config, key, val)
|
setattr(self.config, key, val)
|
||||||
|
|
||||||
# load all extension modules
|
# load all extension modules
|
||||||
for extension in getattr(self.config, 'extensions', ()):
|
for extension in self.config.extensions:
|
||||||
self.setup_extension(extension)
|
self.setup_extension(extension)
|
||||||
# the config file itself can be an extension
|
# the config file itself can be an extension
|
||||||
if hasattr(self.config, 'setup'):
|
if self.config.setup:
|
||||||
self.config.setup(self)
|
self.config.setup(self)
|
||||||
|
|
||||||
# this must happen after loading extension modules, since they
|
|
||||||
# can add custom config values
|
|
||||||
self.config.init_defaults()
|
|
||||||
|
|
||||||
if buildername is None:
|
if buildername is None:
|
||||||
print >>status, 'No builder selected, using default: html'
|
print >>status, 'No builder selected, using default: html'
|
||||||
buildername = 'html'
|
buildername = 'html'
|
||||||
@ -179,9 +175,10 @@ class Sphinx(object):
|
|||||||
self.builderclasses[builder.name] = builder
|
self.builderclasses[builder.name] = builder
|
||||||
|
|
||||||
def add_config_value(self, name, default, rebuild_env):
|
def add_config_value(self, name, default, rebuild_env):
|
||||||
if name in self.config.values:
|
if name in self.config.valuenames:
|
||||||
raise ExtensionError('Config value %r already present' % name)
|
raise ExtensionError('Config value %r already present' % name)
|
||||||
self.config.values[name] = (default, rebuild_env)
|
self.config.valuenames.add(name)
|
||||||
|
self.config.__class__.config_values[name] = (default, rebuild_env)
|
||||||
|
|
||||||
def add_event(self, name):
|
def add_event(self, name):
|
||||||
if name in self._events:
|
if name in self._events:
|
||||||
|
@ -320,9 +320,6 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
else:
|
else:
|
||||||
self.last_updated = None
|
self.last_updated = None
|
||||||
|
|
||||||
docstitle = self.config.html_title or \
|
|
||||||
'%s v%s documentation' % (self.config.project,
|
|
||||||
self.config.release)
|
|
||||||
logo = self.config.html_logo and \
|
logo = self.config.html_logo and \
|
||||||
path.basename(self.config.html_logo) or ''
|
path.basename(self.config.html_logo) or ''
|
||||||
|
|
||||||
@ -339,7 +336,9 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
use_modindex = self.config.html_use_modindex,
|
use_modindex = self.config.html_use_modindex,
|
||||||
use_index = self.config.html_use_index,
|
use_index = self.config.html_use_index,
|
||||||
use_opensearch = self.config.html_use_opensearch,
|
use_opensearch = self.config.html_use_opensearch,
|
||||||
docstitle = docstitle,
|
docstitle = self.config.html_title,
|
||||||
|
shorttitle = self.config.html_short_title,
|
||||||
|
show_sphinx = self.config.html_show_sphinx,
|
||||||
builder = self.name,
|
builder = self.name,
|
||||||
parents = [],
|
parents = [],
|
||||||
titles = {},
|
titles = {},
|
||||||
@ -913,17 +912,15 @@ class ChangesBuilder(Builder):
|
|||||||
otherchanges.setdefault((docname, title), []).append(
|
otherchanges.setdefault((docname, title), []).append(
|
||||||
(entry, docname, lineno))
|
(entry, docname, lineno))
|
||||||
|
|
||||||
docstitle = self.config.html_title or \
|
|
||||||
'%s v%s documentation' % (self.config.project,
|
|
||||||
self.config.release)
|
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
'project': self.config.project,
|
'project': self.config.project,
|
||||||
'version': version,
|
'version': version,
|
||||||
'docstitle': docstitle,
|
'docstitle': self.config.html_title,
|
||||||
|
'shorttitle': self.config.html_short_title,
|
||||||
'libchanges': sorted(libchanges.iteritems()),
|
'libchanges': sorted(libchanges.iteritems()),
|
||||||
'apichanges': sorted(apichanges),
|
'apichanges': sorted(apichanges),
|
||||||
'otherchanges': sorted(otherchanges.iteritems()),
|
'otherchanges': sorted(otherchanges.iteritems()),
|
||||||
|
'show_sphinx': self.config.html_show_sphinx,
|
||||||
}
|
}
|
||||||
f = open(path.join(self.outdir, 'index.html'), 'w')
|
f = open(path.join(self.outdir, 'index.html'), 'w')
|
||||||
try:
|
try:
|
||||||
|
@ -47,7 +47,10 @@ class Config(object):
|
|||||||
template_bridge = (None, False),
|
template_bridge = (None, False),
|
||||||
|
|
||||||
# HTML options
|
# HTML options
|
||||||
html_title = (None, False),
|
html_title = (lambda self: '%s v%s documentation' %
|
||||||
|
(self.project, self.release),
|
||||||
|
False),
|
||||||
|
html_short_title = (lambda self: self.html_title, False),
|
||||||
html_style = ('default.css', False),
|
html_style = ('default.css', False),
|
||||||
html_logo = (None, False),
|
html_logo = (None, False),
|
||||||
html_static_path = ([], False),
|
html_static_path = ([], False),
|
||||||
@ -61,6 +64,7 @@ class Config(object):
|
|||||||
html_copy_source = (True, False),
|
html_copy_source = (True, False),
|
||||||
html_use_opensearch = ('', False),
|
html_use_opensearch = ('', False),
|
||||||
html_file_suffix = (None, False),
|
html_file_suffix = (None, False),
|
||||||
|
html_show_sphinx = (True, False),
|
||||||
|
|
||||||
# HTML help only options
|
# HTML help only options
|
||||||
htmlhelp_basename = ('pydoc', False),
|
htmlhelp_basename = ('pydoc', False),
|
||||||
@ -77,7 +81,7 @@ class Config(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, dirname, filename):
|
def __init__(self, dirname, filename):
|
||||||
self.values = self.config_values.copy()
|
self.valuenames = set(self.config_values.keys())
|
||||||
config = {'__file__': path.join(dirname, filename)}
|
config = {'__file__': path.join(dirname, filename)}
|
||||||
olddir = os.getcwd()
|
olddir = os.getcwd()
|
||||||
try:
|
try:
|
||||||
@ -85,12 +89,20 @@ class Config(object):
|
|||||||
execfile(config['__file__'], config)
|
execfile(config['__file__'], config)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
self.__dict__.update(config)
|
for name in config:
|
||||||
|
if name in self.valuenames:
|
||||||
|
self.__dict__[name] = config[name]
|
||||||
|
self.setup = config.get('setup', None)
|
||||||
|
|
||||||
def init_defaults(self):
|
def __getattr__(self, name):
|
||||||
for val in self.values:
|
if name.startswith('_'):
|
||||||
if val not in self.__dict__:
|
raise AttributeError(name)
|
||||||
self.__dict__[val] = self.values[val][0]
|
if name not in self.valuenames:
|
||||||
|
raise AttributeError('No such config value: %s' % name)
|
||||||
|
default = self.config_values[name][0]
|
||||||
|
if callable(default):
|
||||||
|
return default(self)
|
||||||
|
return default
|
||||||
|
|
||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
@ -102,4 +114,4 @@ class Config(object):
|
|||||||
delattr(self, name)
|
delattr(self, name)
|
||||||
|
|
||||||
def __contains__(self, name):
|
def __contains__(self, name):
|
||||||
return hasattr(self, name)
|
return name in self.valuenames
|
||||||
|
@ -129,9 +129,8 @@ def build_hhx(builder, outdir, outname):
|
|||||||
builder.info('writing project file...')
|
builder.info('writing project file...')
|
||||||
f = open(path.join(outdir, outname+'.hhp'), 'w')
|
f = open(path.join(outdir, outname+'.hhp'), 'w')
|
||||||
try:
|
try:
|
||||||
title = builder.config.html_title or \
|
f.write(project_template % {'outname': outname,
|
||||||
'%s v%s documentation' % (builder.config.project, builder.config.release)
|
'title': builder.config.html_title,
|
||||||
f.write(project_template % {'outname': outname, 'title': title,
|
|
||||||
'version': builder.config.version,
|
'version': builder.config.version,
|
||||||
'project': builder.config.project})
|
'project': builder.config.project})
|
||||||
if not outdir.endswith(os.sep):
|
if not outdir.endswith(os.sep):
|
||||||
@ -150,7 +149,8 @@ def build_hhx(builder, outdir, outname):
|
|||||||
try:
|
try:
|
||||||
f.write(contents_header)
|
f.write(contents_header)
|
||||||
# special books
|
# special books
|
||||||
f.write('<LI> ' + object_sitemap % ('Main page', 'index.html'))
|
f.write('<LI> ' + object_sitemap % (builder.config.html_short_title,
|
||||||
|
'index.html'))
|
||||||
if builder.config.html_use_modindex:
|
if builder.config.html_use_modindex:
|
||||||
f.write('<LI> ' + object_sitemap % ('Global Module Index', 'modindex.html'))
|
f.write('<LI> ' + object_sitemap % ('Global Module Index', 'modindex.html'))
|
||||||
# the TOC
|
# the TOC
|
||||||
|
@ -105,6 +105,9 @@ html_style = 'default.css'
|
|||||||
# "<project> v<release> documentation".
|
# "<project> v<release> documentation".
|
||||||
#html_title = None
|
#html_title = None
|
||||||
|
|
||||||
|
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||||
|
#html_short_title = None
|
||||||
|
|
||||||
# The name of an image file (within the static path) to place at the top of
|
# The name of an image file (within the static path) to place at the top of
|
||||||
# the sidebar.
|
# the sidebar.
|
||||||
#html_logo = None
|
#html_logo = None
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
title="Customize your viewing settings" accesskey="S">settings</a> |</li>
|
title="Customize your viewing settings" accesskey="S">settings</a> |</li>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- block rootrellink %}
|
{%- block rootrellink %}
|
||||||
<li><a href="{{ pathto('index') }}">{{ docstitle }}</a>{{ reldelim1 }}</li>
|
<li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li>
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
{%- for parent in parents %}
|
{%- for parent in parents %}
|
||||||
<li><a href="{{ parent.link|e }}" accesskey="U">{{ parent.title }}</a>{{ reldelim1 }}</li>
|
<li><a href="{{ parent.link|e }}" accesskey="U">{{ parent.title }}</a>{{ reldelim1 }}</li>
|
||||||
@ -185,6 +185,9 @@
|
|||||||
{%- if last_updated %}
|
{%- if last_updated %}
|
||||||
Last updated on {{ last_updated }}.
|
Last updated on {{ last_updated }}.
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if show_sphinx %}
|
||||||
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
|
||||||
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user