Good to hear it (almost) works!
- The header is a docked cell, so, to remove it, you could evaluate
SetOptions[EvaluationNotebook[], DockedCells->{}]
in the notebook (before you publish it to the cloud).
- To upload a whole directory to the cloud, you can use
CopyDirectory["localpath", CloudObject["cloudpath"]]
(with localpath
and cloudpath
set appropriately). To make all the created cloud objects public, you could temporarily change $Permissions
, or you could (recursively) iterate over them using CloudObjects
and apply SetPermissions
to each of them. We're working on more direct ways to do this, also in the GUI ("Publish Directory to Cloud"). Documentation also needs to be further improved, but the guide page about Managing Content in the Cloud is a good starting point for more information.
To address the problem with paclet:
hyperlinks: I think the best option (for now) is to preprocess each notebook before publishing it to the cloud, replacing the target URLs of all such ButtonBox
es with corresponding cloud object URLs. Here's some code that does this:
dirPrefixes = <|
"Guides" -> "guide", {"ReferencePages", "Symbols"} -> "ref",
"Tutorials" -> "tutorial"|>;
subdirString[prefix_String] := prefix
subdirString[prefixes_List] := FileNameJoin[prefixes]
pacletLinkQ[str_String] := StringStartsQ[str, "paclet:"]
pacletLinkQ[_] := False
fixPacletLink[str_, pacletName_, targetURL_] :=
StringReplace[
str, (StartOfString ~~ "paclet:" ~~ pacletName) -> targetURL] <>
".nb"
fixPacletLinks[nb_Notebook, pacletName_, targetDir_String] :=
nb /. ButtonBox[content_, opts1___, ButtonData -> data_?pacletLinkQ,
opts2___] :>
ButtonBox[content,
ButtonFunction :> (FrontEndExecute[
NotebookLocate[{URL[#2], None}]] &), opts1,
ButtonData -> fixPacletLink[data, pacletName, targetDir], opts2]
removeDockedCells[
Notebook[content_, opts1___, DockedCells -> _, opts2___]] :=
Notebook[content, opts1, DockedCells -> {}, opts2]
removeDockedCells[Notebook[content_, opts___]] :=
Notebook[content, DockedCells -> {}, opts]
resetMagnification[
Notebook[content_, opts1___, (Rule | RuleDelayed)[Magnification, _],
opts2___]] := Notebook[content, opts1, opts2]
resetMagnification[nb_Notebook] := nb
fixStyleSheet[
Notebook[content_, opts1___, StyleDefinitions -> _, opts2___]] :=
Notebook[content, opts1,
StyleDefinitions -> FrontEnd`FileName[{"Wolfram"}, "Reference.nb"],
opts2]
publishDocNB[filename_String, target : CloudObject[targetURL_, ___],
prefix_, pacletName_] :=
Module[{nb, newNB, obj}, nb = Get[filename];
newNB = resetMagnification@
fixStyleSheet@
removeDockedCells@fixPacletLinks[nb, pacletName, targetURL];
obj = FileNameJoin[{target, prefix, FileNameTake[filename]}];
Print["Publishing ", filename, " to ", obj];
CloudPublish[newNB, obj]]
publishDocDir[pacletDir_, subdir_, prefix_, target_] :=
Module[{nbfiles =
FileNames["*.nb",
FileNameJoin[{pacletDir, "Documentation", "English",
subdirString[subdir]}]], pacletName = FileNameTake[pacletDir]},
publishDocNB[#, target, prefix, pacletName] & /@ nbfiles]
PublishPacletDocs[pacletDir_String, target_CloudObject] :=
KeyValueMap[publishDocDir[pacletDir, #1, #2, target] &, dirPrefixes]
Calling the function like
PublishPacletDocs["~/Projects/EcoEvo/EcoEvo", CloudObject["EcoEvo"]]
will publish all documentation notebooks in the given paclet directory (assuming they're all in the usual subdirectory structure of Documentation/English
) to a cloud directory EcoEvo
in your cloud home directory.
This also takes care of points 1 and 2, and, as a little bonus, I also made it change the stylesheet to Wolfram/Reference.nb
(since Wolfram/FunctionPageStyles.nb
doesn't exist right now) and reset the Magnification
to 1. (You could also deploy a custom stylesheet to the cloud and reference that.)
You can see the result here: https://www.wolframcloud.com/obj/jpoeschko/EcoEvo/guide/EcoEvo.nb
(Hope it's okay that I took your https://github.com/cklausme/EcoEvo and published it to my own Wolfram Cloud account for now. Just let me know if I should replace the link in this answer with a link to your own published version.)
paclet:
to properly linked can be resolved by usingURLParse
on them then changing the"Scheme"
and"Domain"
viaReplacePart
and if needed also inserting the path before hitting it with aURLBuild
or whatever the functions are again. This assumes you already know where the stuff will be going. Otherwise you'll need relative linking inside the package and to full WRI docs outside. I took that approach at one time before I decided I didn't want to host documentation for my packages (or really deal with documentation in any way...). $\endgroup$paclet:
links. It's in the same spirit as the (slightly later) suggestion by @b3m2a1 above. Could certainly be made a bit more sophisticated, but should be a good start. Does this help, @Chris K? $\endgroup$