On Tue, Feb 26, 2013 at 3:11 AM, Guenter Milde <[email protected]> wrote:
> On 2013-02-25, Kevin Horn wrote: > > On Tue, Feb 19, 2013 at 4:43 AM, Thomas Güttler <[email protected]> wrote: > > ... > > > An extension wouldn't be terribly difficult by the way. I think it would > > just be a matter of creating a custom text role that spits out the value > of > > a config var. It should be pretty simple to create, though I haven't > seen > > anything like it yet, so perhaps it's not as easy as I think. > > In my view, a new `directive for substitution definitions`__ would be more > in line with the existing reStructuredText syntax. Usually, a rst `role` > changes the meaning of the content while a rst `substitution` replaces the > content. > > Hmmm. I'm not sure that I agree with this, though I'm not sure that I disagree with it either. The main reason I was thinking of a role is because I tend to think of substitutions when I want to make a block-level item into an inline structure, though obviously that's not the only use for them. A directive+substitution would certainly work, though is more complex. Assuming for just a moment that I had the option of using either a directive+substitution or a role, I think I would prefer a directive+substitution when the "variable" was repeated several times in a document, and a role when it wasn't. Maybe it makes sense to have both a role _and_ a directive. > How about a new directive "echo" that expands environment variables: > > .. |LANG| echo:: $LANG > > The value of the environment variable LANG is |LANG|. > > I certainly don't care for the name, "echo", though of course that isn't central to your argument. I'd much prefer something like "expand". Also, when you say "environment variable", do you mean actual environment variables (like you might see in a shell if you typed "set"), or just variables defined in Sphinx's conf.py? I had thought we were talking about the latter, though the former is also an interesting idea. Using actual shell env vars is less Sphinx-specific, and could be used in any docutils processing system , *but* could open up security holes if used improperly. > > Günter > > > __ > http://docutils.sourceforge.net/docs/ref/rst/directives.html#directives-for-substitution-definitions > > -- Kevin Horn -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to 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.
