Thanks, I got that working. This spawns an additional question: when I 
provide the :name: attribute to my custom directive, I can only reference 
the directive with the :ref:`text <name>` syntax, since the directive has 
no title. However, I'd like to be able to give a default title, like 
"Exercise 4", so the following might work:

.. exercise::
  :name: pythagoras

  Prove the following theorem...

In :ref:`pythagoras`, you demonstrated that...

and I'd see a link to "Exercise 4" or whatever it might be, just as LaTeX 
would fill in the exercise's number. Is there a way to achieve this? There 
must be, since the figure directive can do it.

- Alex Reinhart

On Saturday, January 26, 2013 11:53:24 AM UTC-6, Guenter Milde wrote:
>
> On 2013-01-24, Alex Reinhart wrote: 
>
> > [-- Type: text/plain, Encoding:  --] 
>
> > Hello, 
>
> > I'm trying to create a custom Sphinx directive that can be 
> > cross-referenced. For instance, I'd like to make an "exercise" directive 
> > that gives an example problem for the reader to solve, and which can be 
> > cross-referenced later ("see exercise 1.3"). 
>
> > The ordinary label syntax (.. _label:) doesn't work on custom 
> directives. I 
> > could make a new domain and create an "exercise" object, but objects in 
> > domains don't appear to be customizable. For instance, I couldn't make 
> my 
> > exercise directive display as an admonition or give it any custom 
> features 
>
> The :name: option of a directive crates a label for cross referencing. 
> http://docutils.sourceforge.net/docs/ref/rst/directives.html#name 
>
> This should also be possible to use for custom directives. 
> See the Docutils source code for examples. 
>
> http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/docutils/parsers/rst/directives/
>  
>
> Günter 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sphinx-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to