SuperCollider CLASSES

SCDoc

Help system main class
Source: /Applications/SuperCollider/SuperCollider.app/Contents/Resources/SCClassLibrary/SCDoc/SCDoc.sc
Inherits from: Object

Description

SCDoc manages the SuperCollider documentation system.

It uses SCDocParser for parsing and SCDocRenderer for rendering.

The syntax reference for the documentation markup language can be found here: SCDocSyntax.

A guide to writing help can be found here: Writing Help.

Basic usage

Get help URL for a specific string:

url = SCDoc.prepareHelpForURL(SCDoc.findHelpFile("SinOsc"));

Class Methods

*p

The default SCDocParser object, created automatically.

*r

The default SCDocRenderer object, created automatically. Defaults to an instance of SCDocHTMLRenderer

*helpSourceDir [= path]

get/set the system-wide directory of help sourcefiles. Defaults to thisProcess.platform.classLibraryDir.dirname +/+ "HelpSource"

*helpSourceDirs

get the list of HelpSource folders, including extensions and quarks.

Discussion:

This searches recursively for all folders named "HelpSource" under thisProcess.platform.userExtensionDir and thisProcess.platform.systemExtensionDir as well as including the system-wide helpSourceDir

*helpTargetDir [= path]

get/set the user help target directory. Defaults to thisProcess.platform.userAppSupportDir +/+ "Help"

*undocumentedClasses

A set of all undocumented classes.

*verbose [= value]

If true, print progress status messages to post window.

Main interface

*prepareHelpForURL (url)

Prepare help for the given URL by checking if the file needs rendering from schelp source, or some other action needs to be done. Use this as a wrapper to get on-the-fly rendering and processing of help files. If called from a routine, do some 0.wait while running to give the GUI a chance to respond.

Arguments:

url

The url to prepare. If this is not a local file inside *helpTargetDir then it will just pass through the url directly.

Returns:

the URL or nil if file not found.

*findHelpFile (str)

Find help for a given string. This method redirects to the instance method findHelpFile on the current renderer object.

Returns:

the URL for help on given string

Render all or specific files

*renderAll (force = false, threaded = true, findExtensions = true, doneFunc)

Render all help-files that need updating and generate overviews and cached metadata index. This can take several minutes. Useful mainly if you want to render all help to put online or similar.

Arguments:

force

Force updating of all files.

threaded

When true, runs the process in a Routine on AppClock. This is needed to get progress feedback when running inside a frontend like the SuperCollider app on OSX. If running with the sclang terminal client, this can be set to false for better performance.

findExtensions

If false, don't search for extensions (useful when building base help)

doneFunc

Function to evaluate when done.

Discussion:

It traverses the directory tree recursively starting at helpSourceDir, parsing and rendering all *.schelp files and copying all other files. The output goes to an equal directory layout in helpTargetDir.

*parseAndRender (src, dest, subtarget)

Parse and render a specific file.

Arguments:

src

The .schelp source document file, must be full path.

dest

The destination target file ( .html if current renderer is SCDocHTMLRenderer ), must be full path.

kind

The document "kind", like Classes, Reference, Overviews, Guides. Should be the same as the parent folder name of both src and dest

Cached map of documents

SCDoc keeps a dictionary where each document is represented by an Event with the keys path, title, categories, summary, installed.

SCDoc also writes the document map in JSON format to helpTargetDir/docmap.js.

*docMap

Returns the internal dictionary of documents.

Returns:

An internal Dictionary, it will be empty if there was no docmap cache file.

Discussion:

If the document map cache was not already read from file, it's first read from file if existent. The returned Dictionary is indexed by the documents path relative helpSourceDir, and without file suffix. Like Classes/SCDoc.

This dictionary is cached in helpTargetDir/scdoc_cache.

*makeCategoryMap

Creates a dictionary of all categories, with a list of documents for each category.

Returns:

A Dictionary of all documents grouped by category.

Discussion:

The keys are category symbols, and each value is a List of Events representing each document.

*cleanState (noCache = false)

Reset the state so that next time *prepareHelpForURL is called, SCDoc will collect any newly added HelpSource files and undocumented classes.

Arguments:

noCache

If true, don't read doc map cache from file and discard any old rendered files. This makes sure that every file is re-rendered, even if there was already a rendered help file. This is similar to starting with an empty Help folder.

Utilities

*makeClassTemplate (name, path)

Create a schelp template for specified class.

Arguments:

name

String or Symbol. The name of the class.

path

File to render the help stub and template to, used internally by SCDoc. Just pass nil (default) to return the template string.

Returns:

If path was given, true or false. If not given, returns the template string.

*splitList (txt)

Split a comma-separated string into an array of whitespace-stripped strings, useful to parse the contents of tags like categories:: and related::.

Arguments:

txt

The string to split.

Returns:

An Array of whitespace-stripped strings.

*classHasArKrIr (c)

Arguments:

c

The Class to check.

Returns:

true if the class responds to ar, kr or ir classmethods.

*findHelpSource (subtarget)

Find the helpsource for a help path, if existent.

Arguments:

subtarget

The sub-path for a help file, like "Guides/WritingHelp" or "Classes/SinOsc".

Returns:

The path to the .schelp file, or nil if no file found.

Discussion:

Example:

SCDoc.findHelpSource("Classes/SCDoc"); // a path
SCDoc.findHelpSource("NoSuch/File"); // nil

Inherited class methods

Undocumented class methods

*checkSystemCmd (cmd)

Instance Methods

Inherited instance methods