[Python-checkins] r66591 - in doctools/trunk: CHANGES doc/markup/inline.rst sphinx/environment.py

georg.brandl python-checkins at python.org
Wed Sep 24 17:36:35 CEST 2008


Author: georg.brandl
Date: Wed Sep 24 17:36:34 2008
New Revision: 66591
Log:
#16: allow referring to figures without explicit text.
Modified:
 doctools/trunk/CHANGES
 doctools/trunk/doc/markup/inline.rst
 doctools/trunk/sphinx/environment.py
Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Wed Sep 24 17:36:34 2008
@@ -9,7 +9,8 @@
 - 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 @@
 
 - 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)
 ============================
Modified: doctools/trunk/doc/markup/inline.rst
==============================================================================
--- doctools/trunk/doc/markup/inline.rst	(original)
+++ doctools/trunk/doc/markup/inline.rst	Wed Sep 24 17:36:34 2008
@@ -205,6 +205,17 @@
 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>```.
Modified: doctools/trunk/sphinx/environment.py
==============================================================================
--- doctools/trunk/sphinx/environment.py	(original)
+++ doctools/trunk/sphinx/environment.py	Wed Sep 24 17:36:34 2008
@@ -658,10 +658,18 @@
 '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):


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /