[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] commit: HTML helpfile support
Okay, I've committed working support for HTML documentation. This might need to be fleshed out before it's ready for primetime, but it's available to try out.
Some things to note:
Links are currently blue and underlined. Those who'd prefer something else can fight amongst yourselves. You can change the colour afterwards, but it doesn't save for some reason. I can try to track that down if anyone cares.
Links open up in a new window, just like Cmd-?.
This uses NSTextView's builtin HTML rendering to show the files. This seemed the simplest and most lightweight approach. It might be appropriate to do something more elaborate with WebKit in the future, but I thought that would probably be overkill. NSTextView doesn't have perfect rendering, and information can be lost. (When saving reencoding to HTML is done with an NSAttributedString and Adam Iser's AIHTMLDecoder class from Adium). So in general don't do anything fancier than what you can do in a normal SC rtf doc. I figured this is okay, since what we're looking for here is simple documentation system, and not virtuoso stuff.
I've added a new menu item to the Edit menu: Link to Helpfile. Select some text and execute it and this will make a link. Currently this calls pathOfHelpFileFor() and creates a link of the lastPathComponent. So in the saved file this will produce a link of the type: <a href="Class.rtf">Class</a> or <a href="SinOsc.htm">SinOsc</a>. It will search for files with extensions rtf, htm, html, etc., so the doc can be mixed and matched as it's converted. This type of link works with the existing help search methods, and should allow html doc to be placed online without any changes, as some people have expressed interest in that. I can change this to include directory info if that's better. I don't know how the swiki is organised, so I've done it this way for the time being.
Making a link will change the default save type of the document to HTML. However if you edit an existing rtf file, you must Save As. Simply saving will result in an rtf file with underlined and blue text, but no functional links. Is there a way to change a document's status to 'unsaved' so to speak?
I've added a version of the main helpfile with links for people to try out. It's called Help.help.htm and is in the Help/ directory. The old rtf version is still there.
**I assume that someone will need to add some files to the XCode project. Basically all the headers and source files beginning with AI. These are in headers/app/ and source/app. Also, I've added a new document type, SC Help (HTML), which will also need to be added. I assume there's an elegant way to do this in XCode as in PB. In any case the Info.plist entries are below.
(Under CFBundleDocumentTypes)
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>htm</string>
<string>html</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>html.icns</string>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>text/html</string>
</array>
<key>CFBundleTypeName</key>
<string>SC Help (HTML)</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>HTML</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>MyDocument</string>
</dict>
Comments would be appreciated. My Obj-C skills are germinal, so apologies if there's anything truly dumb in what I've done. If people like this I can start the long and tedious process of converting the doc to html.
best,
S.