mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#16: allow referring to figures without explicit text.
This commit is contained in:
parent
20e989e19b
commit
47ce40c492
6
CHANGES
6
CHANGES
@ -9,7 +9,8 @@ New features added
|
||||
- Incompatible change: The "root" relation link (top left in the
|
||||
relbar) now points to the ``master_doc`` by default, no longer to a
|
||||
document called "index". The old behavior, while useful in some
|
||||
situations, was somewhat unexpected.
|
||||
situations, was somewhat unexpected. Override the "rootrellink"
|
||||
block in the template to customize where it refers to.
|
||||
|
||||
- The JavaScript search now searches for objects before searching in
|
||||
the full text.
|
||||
@ -96,6 +97,9 @@ New features added
|
||||
|
||||
- Glossary entries are now automatically added to the index.
|
||||
|
||||
- Figures with captions can now be referred to like section titles,
|
||||
using the ``:ref:`` role without an explicit link text.
|
||||
|
||||
|
||||
Release 0.4.2 (Jul 29, 2008)
|
||||
============================
|
||||
|
@ -205,6 +205,17 @@ to labels:
|
||||
title being "Section to cross-reference". This works just as well when
|
||||
section and reference are in different source files.
|
||||
|
||||
Automatic labels also work with figures: given ::
|
||||
|
||||
.. _my-figure:
|
||||
|
||||
.. figure:: whatever
|
||||
|
||||
Figure caption
|
||||
|
||||
a reference ``:ref:`my-figure``` would insert a reference to the figure with
|
||||
link text "Figure caption".
|
||||
|
||||
* Labels that aren't placed before a section title can still be referenced to,
|
||||
but you must give the link an explicit title, using this syntax: ``:ref:`Link
|
||||
title <label-name>```.
|
||||
|
@ -658,10 +658,18 @@ class BuildEnvironment:
|
||||
'other instance in %s' % self.doc2path(self.labels[name][0]),
|
||||
node.line)
|
||||
self.anonlabels[name] = docname, labelid
|
||||
if not isinstance(node, nodes.section):
|
||||
if node.tagname == 'section':
|
||||
sectname = node[0].astext() # node[0] == title node
|
||||
elif node.tagname == 'figure':
|
||||
for n in node:
|
||||
if n.tagname == 'caption':
|
||||
sectname = n.astext()
|
||||
break
|
||||
else:
|
||||
continue
|
||||
else:
|
||||
# anonymous-only labels
|
||||
continue
|
||||
sectname = node[0].astext() # node[0] == title node
|
||||
self.labels[name] = docname, labelid, sectname
|
||||
|
||||
def note_indexentries_from(self, docname, document):
|
||||
|
Loading…
Reference in New Issue
Block a user