summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-05-30 12:11:52 +0200
committerGeorg Brandl <georg@python.org>2010-05-30 12:11:52 +0200
commitd653dacea8d7a933a02dbf08ad1708255ad14630 (patch)
tree499503f34149677d2e3b2b5b2696e1b4065adc9f
parentf713c87d438f3adb668c7190d1c29fe66282277f (diff)
downloadsphinx-d653dacea8d7a933a02dbf08ad1708255ad14630.tar.gz
Allow linking to tables just like figures with :ref:.
-rw-r--r--CHANGES1
-rw-r--r--doc/markup/inline.rst3
-rw-r--r--sphinx/domains/std.py7
3 files changed, 11 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 754b6826..5be94f2f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -50,6 +50,7 @@ Features added
``literalinclude`` directive.
- #284: All docinfo metadata is now put into the document metadata, not
just the author.
+ - The ``ref`` role can now also reference tables by caption.
* Configuration:
diff --git a/doc/markup/inline.rst b/doc/markup/inline.rst
index 4d4ebe24..bb1ed68e 100644
--- a/doc/markup/inline.rst
+++ b/doc/markup/inline.rst
@@ -83,6 +83,9 @@ Cross-referencing arbitrary locations
a reference ``:ref:`my-figure``` would insert a reference to the figure
with link text "Figure caption".
+ The same works for tables that are given an explicit caption using the
+ :dudir:`table` directive.
+
* 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>```.
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 68bff15e..63a3bf6d 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -410,6 +410,13 @@ class StandardDomain(Domain):
break
else:
continue
+ elif node.tagname == 'table':
+ for n in node:
+ if n.tagname == 'title':
+ sectname = clean_astext(n)
+ break
+ else:
+ continue
else:
# anonymous-only labels
continue