13
$\begingroup$

There is a feature called ResourceFunction in Mathematica. For example you can color a string with rainbow style.

https://resources.wolframcloud.com/FunctionRepository/resources/RainbowText/

Below is a screenshot of the site in the Chrome browser.

screenshot from the RainbowText resource function website

As you see, the definition is not immediately visible, although it is available after downloading the source notebook (marked in light green) and opening the .nb file.

Below is a screenshot of the Mathematica program after opening the RainbowText-1-0-0-definition.nb file.

the RainbowText notebook, opened in Mathematica

Q1) Why are so many steps required to see the definition?

Q2) Can I get the definition of a resource function without downloading a notebook? I mean, just knowing the function name RainbowText, can I get the definition of RainbowText?

$\endgroup$
3
  • 2
    $\begingroup$ Seems that Domen has answered Q2. As for Q1, I think that a comment should suffice: it does not seem to be so uncomfortable to get the source notebook if one wants to have it, but this is not the intended use case/scenario for the general user. Presenting such information as the intended use case/scenario would likely result in some errors by the user when copying over the code blocks. By wrapping the functions in a contained format like that of the ResourceFunction allows for access to information like the version number, while also cleanly integrating with the overarching system. $\endgroup$ Commented Oct 12, 2021 at 3:41
  • 5
    $\begingroup$ ResourceFunction["RainbowText", "Properties"] for more info $\endgroup$
    – Syed
    Commented Oct 12, 2021 at 4:48
  • $\begingroup$ Thank you CA Trevilian and Syed! $\endgroup$
    – imida k
    Commented Oct 13, 2021 at 3:28

3 Answers 3

17
$\begingroup$

ResourceFunction["RainbowText", "Definition"]

Get Definition.

$\endgroup$
8
$\begingroup$

Alternatively, you could use "ResourceFunctionDefinitionViewer", to open a new notebook showing the implementation:

ResourceFunction["ResourceFunctionDefinitionViewer"][ResourceFunction["RainbowText"]]

definition

$\endgroup$
5
$\begingroup$

You can treat the resource as an object rather than a function in order to make meta-queries:

ResourceObject["RainbowText"]["Properties"]
{"AllVersions", "AutoUpdate", "Categories", "ContributorInformation", 
 "Definition", "DefinitionNotebook", "DefinitionNotebookObject", 
 "Description", "Details", "Documentation", "DocumentationLink", 
 "DocumentationNotebook", "DownloadedVersion", "ExampleNotebook", 
 "ExampleNotebookObject", "Function", "FunctionLocation", "Keywords", 
 "LatestUpdate", "Name", "Originator", "Properties", "RelatedSymbols", 
 "ReleaseDate", "RepositoryLocation", "ResourceLocations", 
 "ResourceObject", "ResourceType", "SeeAlso", "ShortName", 
 "SourceMetadata", "Symbol", "SymbolName", "TestReport", "Usage", 
 "UUID", "VerificationTests", "Version", "VersionInformation", 
 "VersionsAvailable", "WolframLanguageVersionRequired"}

The definition notebook:

ResourceObject["RainbowText"]["DefinitionNotebook"];

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.