DISQUS

toxicsoftware.com: View man pages in Xcode script

  • Tom Harrington · 2 years ago
    Thanks, that's pretty cool. I like the way Xcode's viewer inserts hyperlinks to cross-referenced man pages.

    I have a script I've used for a while that uses PDF rendering of pages-- see http://www.atomicbird.com/blog/2007/07/man-page... to see how it works.
  • schwa · 2 years ago
    I like it. Dueling man page hacks.
  • Justin Miller · 2 years ago
    Great script -- thanks for that!
  • hollywood · 2 years ago
    I like the way Xcode’s viewer inserts hyperlinks to cross-referenced man pages.
  • Nico · 2 years ago
    osascript -e ''tell application "XCode" to show document with apple_ref "//apple_ref/doc/man/1/'$1

    should work as well and doesn't require gui scripting. Use "//apple_ref/doc/c_ref/" to show documentation for C code (e.g. Carbon functions and constants; cocoa class names work too).
  • schwa · 2 years ago
    Nico, if that works then very nice.

    But you've just killed my blog post! ;-)
  • Nico · 1 year ago
    Turns out that what I wrote doesn't work with Leopard (it did work with Tiger, though). But the apple_ref scheme is actually documented: http://developer.apple.com/documentation/Develo...

    So to open the "interesting" man page (1) (that's what your script does as well) you can use

    tell application "Xcode" to show document with apple_ref "//apple_ref/c/func/strlen"

    to open the man page for strlen. And

    tell application "Xcode" to show document with apple_ref "//apple_ref/occ/instm/NSArray/initWithArray:copyItems:"

    to show the documentation for -[NSArray initWithArray:copyItems:]. And so on. Semi-useful if you want to use a better editor than xed for code editing, but still look at XCode documentation from there (only semi-useful because you have to guess the top-level link like occ, c etc first before sending the applescript command to xcode).