# Can I view a package as a regular notebook?

How can I open a package as a normal notebook, i.e. without the toolbars and formatting of the built-in .m file interface.

Upon opening you can change the stylesheet and remove the docked cell:

SetOptions[EvaluationNotebook[], DockedCells -> {},StyleDefinitions -> "Default.nb"]


Then if you want to change the "Code" styles to something else, possibly "Input", do this:

NotebookFind[EvaluationNotebook[], "Code", All, CellStyle]
FrontEndExecute[FrontEndToken["StyleOther"]]

• It doesn't seem to save, is there a way around running this command manually every time I open the notebook? – M.R. Feb 8 '15 at 22:38
• Well perhaps that is a separate question - how to run a bit of code every time a notebook opens... what do you think? – M.R. Feb 8 '15 at 22:39

Here is one way. Using the parseString function from this answer of Mr.Wizard, the following will create a notebook with an entire package's code being placed in a single Code - style cell:

parseString[s_String, prep : (True | False) : True] :=
FrontEndExecute[UndocumentedTestFEParserPacket[s, prep]]

ClearAll[openPackage];
openPackage[file_String?FileExistsQ] :=
With[{stringCode = Import[file, "String"]},
CreateDocument[
Cell[First@parseString[stringCode, False], "Code"]
] /; stringCode =!= \$Failed
]


For example:

openPackage@FileNameJoin[{FileNameDrop[FindFile["Combinatorica"], -2], "Combinatorica.m"}]
`

You can split the code into multiple cells, but that would require a bit more work.