Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
343 stars 230 forks source link

canned examples #1258

Closed DanGrayson closed 3 years ago

DanGrayson commented 4 years ago

There should be a way to generate canned examples, which duplicates the internal method for making examples in documentation, namely this:

document {
     Key => "foo",
     TABLE splice { "class" => "examples", 
      TR TD PRE ///
i1 : loadPackage "Foo"

o1 = Foo

o1 : Package///,
      TR TD PRE ///
i2 : viewHelp oo
///
}}

The point is to get those nice lines between the individual input/output triples, as in

Screen Shot 2020-06-10 at 1 43 43 PM
mahrud commented 3 years ago

Try:

importFrom_Core {"separateM2output"}
beginDocumentation()
s = "\ni1 : 4 * 4\n\no1 = 16\n\ni2 : 12 + 16;\n\ni3 : 11\n\no3 = 11\n\ni4 : \n"
document { Key => "foo", TABLE flatten {"class" => "examples", TR \ TD \ PRE \ separateM2output s} };
help foo

Maybe separateM2output would need to be renamed into something and exported, but this doesn't seem like a common enough occurrence to make it worth that.

Perhaps this should also be added here: https://github.com/Macaulay2/M2/blob/1e47260755100936bafd60d64013672dedd3941f/M2/Macaulay2/packages/SimpleDoc.m2#L246-L248