Hi Sage fan, Reviving an old thread.
> Before the second code block, you need a "link" directive to tell it > that it should be connected with the previous block. See > > <http://sagemath.org/doc/developer/conventions.html#testing-rest- > documentation> > > for documentation. For an example, see the file "interfaces.rst" in > the tutorial. Your example could look like this: > > > Examples of code:: > > sage: el = 1 > sage: el > 1 > > Some explanations: > > .. link > > :: > > > sage: el > 1 > > > It seems that doesn't work inside a note environement: > > I guess it doesn't interact well with other environments? As far as I > know, the ".. link" directive is a Sage add-on, dealt with in > SAGE_ROOT/local/bin/sage-doctest, and it may not be implemented as > fully as one might like. Another way of looking at this is, perhaps > you should only be able to link blocks which are at the same level of > indentation, so maybe this is a feature, not a bug :) I'm trying to improve this and I realize the following: To tests a .rst file we convert it to a python file and send the resulting file to the usual doctest infrastructure. If the .rst file contains: blabla:: sage: x=1 more blabla:: sage: x 1 This is converted to something like """ sage: y=1 """ """ sage: y 1 """ And the second test fails because y isn't defined. One have to write blabla:: sage: x=1 more blabla: ..link :: sage: x 1 to have something like """ sage: y=1 sage: y 1 """ which is correct. Is there any good reason why we do this complicated transformation rather that simply put a pair of """ """ around the .rst file ? Indeed sending """ blabla:: sage: x=1 more blabla:: sage: x 1 """ perfectly works. > I'm also interested in this feature: how about we add a single line at > the beggining of the rst file that indicates that all code cells are > linked? That would cover all my use cases: how about yours? The following easy diff should solve the problem. (I'll put a patch in ticket #11263 for it). But I don't see why we need to do something more complicated. diff --git a/sage-doctest b/sage-doctest --- a/sage-doctest +++ b/sage-doctest @@ -524,7 +524,10 @@ def pythonify_rst(F): verbatim examples in the ReST file. """ import re - + + if '.. linkall' in F: + return '\n"""\n\n%s\n\n"""\n'%F + def get_next_verbatim_block(s, pos): while True: # regular expression search in string s[pos:] for: Cheers, Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org