Skip to content

Commit

Permalink
Made ExampleInputs with Visible->False set more invisible
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Lang committed May 9, 2018
1 parent c50a5be commit b37da64
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ForScience/PacletInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
23 changes: 22 additions & 1 deletion ForScience/PacletUtils/Examples.wl
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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[
Expand Down

0 comments on commit b37da64

Please sign in to comment.