From b37da647af2c1da0598e241b68904bd0cd0a56bf Mon Sep 17 00:00:00 2001 From: Lukas Lang Date: Wed, 9 May 2018 16:01:38 +0200 Subject: [PATCH] Made ExampleInputs with Visible->False set more invisible --- ForScience/PacletInfo.m | 2 +- ForScience/PacletUtils/Examples.wl | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ForScience/PacletInfo.m b/ForScience/PacletInfo.m index 6443bdc..6901f44 100644 --- a/ForScience/PacletInfo.m +++ b/ForScience/PacletInfo.m @@ -4,7 +4,7 @@ Name -> "ForScience", Description -> "Contains various utility functions and styling to make it easier to use MMA for scientific plots", Creator -> "Lukas Lang & Marc Lehner", - Version -> "0.63.5", + Version -> "0.63.6", MathematicaVersion -> "11.1+", Extensions -> { { "Documentation", Language -> "English"}, diff --git a/ForScience/PacletUtils/Examples.wl b/ForScience/PacletUtils/Examples.wl index b7513fe..6de4388 100644 --- a/ForScience/PacletUtils/Examples.wl +++ b/ForScience/PacletUtils/Examples.wl @@ -67,6 +67,14 @@ Attributes[ExamplesSection]={HoldFirst}; $ExampleLevels={"PrimaryExamplesSection","ExampleSection","ExampleSubsection"}; +resetInOut[in_,out_]:=( + Unprotect@{In,Out}; + DownValues@In=oldIn; + DownValues@Out=oldOut; + Protect@{In,Out}; + Out[$Line] +) + ExamplesSection[sec_Association,nb_,lev_]:= KeyValueMap[ With[ @@ -97,7 +105,20 @@ ExamplesSection[sec_List,_,_]:= #/.ExampleInput[in__,OptionsPattern[]]:>If[ Visible/.Join[Options[#],Options[ExampleInput]], ExampleInput[in], - ExampleInput[line=$Line;,in,NotebookDelete@EvaluationCell[];$Line=line-1;] + ExampleInput[ + oldIn=Most@DownValues@In; + oldOut=DownValues@Out; + oldLine=--$Line; + resetInOut[oldIn,oldOut];, + in, + NotebookDelete@EvaluationCell[]; + Unprotect@{In,Out}; + DownValues@In=oldIn; + DownValues@Out=oldOut; + Protect@{In,Out}; + $Line=oldLine; + resetInOut[oldIn,oldOut]; + ] ], { s_String:>(MathLink`CallFrontEnd[