Function Repository Resource:

AssociationNotebook

Source Notebook

Create a structured notebook containing data from an association

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["AssociationNotebook"][assoc]

creates a Notebook with the same structure as assoc.

Details and Options

ResourceFunction["AssociationNotebook"] accepts the same options as Notebook with the following additions:
"Title"Nonechoose a title to insert into the notebook
"MaxOpenSize"4096specify a threshold for having sections start closed

Examples

Basic Examples (2) 

Create a Notebook from an Association:

In[1]:=
ResourceFunction[
 "AssociationNotebook"][<|"Text" -> "Hello world", "Data" -> <|"Expression" -> f[x], "List" -> {a + b, c + d}|>|>]
Out[1]=

View the notebook:

In[2]:=
NotebookPut[%]
Out[2]=
In[3]:=
NotebookClose[%]

Use a list of rules:

In[4]:=
NotebookPut[
 ResourceFunction[
  "AssociationNotebook"][{"Section 1" -> "Text 1", "Section 2" -> "Text 2"}]]
Out[4]=
In[5]:=
NotebookClose[%]

Scope (4) 

Strings are represented as "Text" cells:

In[6]:=
NotebookPut[
 ResourceFunction[
  "AssociationNotebook"][<|
   "Text Example" -> "This string will be in a text cell."|>]]
Out[6]=

Lists are converted to multiple "Item" cells:

In[7]:=
NotebookPut@
 ResourceFunction[
  "AssociationNotebook"][<|"List Example" -> {"a", "b", "c"}|>]
Out[7]=

Other expressions will be displayed in StandardForm using "Input" cells:

In[8]:=
NotebookPut@
 ResourceFunction[
  "AssociationNotebook"][<|
   "Expression Example" -> ResourceObject["Gettysburg Address"]|>]
Out[8]=

Expressions held by RuleDelayed will also be unevaluated in the notebook:

In[9]:=
NotebookPut@
 ResourceFunction[
  "AssociationNotebook"][<|"Unevaluated Example" :> Print[1 + 1]|>]
Out[9]=

Options (2) 

Title (1) 

Insert a title:

In[10]:=
NotebookPut@
 ResourceFunction["AssociationNotebook"][SystemInformation["Kernel"], "Title" -> "Kernel Information"]
Out[10]=

MaxOpenSize (1) 

Specify a threshold for closing sections (in total bytes for all section cells):

In[11]:=
NotebookPut@
 ResourceFunction[
  "AssociationNotebook"][<|"Small" -> f[Range[10]], "Large" -> f[Range[10000]]|>, "MaxOpenSize" -> 10000]
Out[11]=

Applications (1) 

Browse metadata in a notebook:

In[12]:=
NotebookPut@
 ResourceFunction["AssociationNotebook"][
  ResourceObject["MoveMouse"][All]]
Out[12]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.1.0 – 13 August 2020
  • 1.0.0 – 09 November 2018

Related Resources

License Information