XcodePages 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in XcodePages.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,86 @@
1
+ = Xcode Pages
2
+
3
+ The XcodePages gem helps you publish documentation from within Xcode using
4
+ {Doxygen}[http://www.stack.nl/~dimitri/doxygen/].
5
+
6
+ The term 'Pages' comes from the ultimate goal: to publish the HTML web pages on
7
+ the Internet somewhere appropriate, e.g. on GitHub via the +gh-pages+ {branch
8
+ feature}[http://pages.github.com/].
9
+
10
+ The gem works for Objective-C projects built using Apple's {Xcode
11
+ IDE}[http://developer.apple.com/xcode/]. It consequently focuses on
12
+ documentation within Objective-C and Objective-C++ source files; files ending
13
+ with extensions +h+, +m+ or +mm+.
14
+
15
+ == How to Use Xcode Pages
16
+
17
+ === Step 1
18
+
19
+ Add a new target to your Xcode project. Suppose your Xcode project has the name
20
+ +MyProject+. Add a new <em>External Build System</em> target called
21
+ +MyProjectPages+.
22
+
23
+ === Step 2
24
+
25
+ Set the external build target up as follows.
26
+
27
+ - Build Tool: <code>/bin/sh</code>
28
+ - Arguments: <code>-c "$HOME/.rvm/bin/rvm-auto-ruby -r XcodePages -e XcodePages.doxygen_docset_install"</code>
29
+ - Directory: None
30
+ - Pass build setting in environment: Yes
31
+
32
+ Leave Build Settings and Phases as defaults.
33
+
34
+ Note that the arguments above tell the shell to run
35
+ <code>$HOME/.rvm/bin/rvm-auto-ruby</code>. This assumes you are running
36
+ {RVM}[http://beginrescueend.com/].
37
+
38
+ Also, do not try to promote your Ruby path to the Build Tool setting unless you
39
+ have a fixed path to Ruby, e.g. +/usr/bin/ruby+. Xcode does *not* make
40
+ environment variables substitutions within the Build Tool setting.
41
+
42
+ === Step 3
43
+
44
+ Set up a new +Doxyfile+ in your project's source root containing four Doxygen settings:
45
+
46
+ * <code>DOCSET_FEEDNAME = "My Project Documentation Set"</code>
47
+ * <code>DOCSET_BUNDLE_ID = com.domain.MyProjectDocSet</code>
48
+ * <code>DOCSET_PUBLISHER_ID = com.domain.MyProjectDocSet.documentation</code>
49
+ * <code>DOCSET_PUBLISHER_NAME = My Publisher Name</code>
50
+
51
+ +DOCSET_BUNDLE_ID+ is the most significant item for this determines the base
52
+ name for the documentation set. Doxygen just adds extension +docset+ to make the
53
+ file name.
54
+
55
+ === Step 4
56
+
57
+ You can now switch target to +MyProjectPages+ and hit Build (Cmd+B) to compile
58
+ the documentation. It will appear in folder +MyProjectPages+ within the source
59
+ root folder and a new Xcode +docset+ will appear in
60
+ +~/Library/Developer/Shared/Documentation/DocSets+.
61
+
62
+ You would normally have to reload Xcode to see the new documentation. As a
63
+ courtesy, the last step tells the running Xcode application to pick up the new
64
+ set.
65
+
66
+ == Benefits
67
+
68
+ * Takes the "fiddle" out of fiddling with Doxygen.
69
+ * You can easily identify undocumented classes and methods.
70
+
71
+ Warning messages output by Doxygen make this possible. After building your
72
+ project Pages target, the build results contain warning about undocumented
73
+ elements within your project. Press the Cmd+\' (Jump to Next Issue command) to
74
+ navigate through the undocumented code.
75
+
76
+ == Examples
77
+
78
+ You can find examples of projects using XcodePages here:
79
+
80
+ * {Active Support Kit}[https://github.com/royratcliffe/ActiveSupportKit]
81
+
82
+ == Prerequisites
83
+
84
+ * Xcode and associated Apple developer tools
85
+ * Ruby and RubyGems package manager
86
+ * Doxygen
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "XcodePages/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "XcodePages"
7
+ s.version = XcodePages::VERSION
8
+ s.authors = ["Roy Ratcliffe"]
9
+ s.email = ["roy@pioneeringsoftware.co.uk"]
10
+ s.homepage = ""
11
+ s.summary = %q{Helps you publish documentation from within Xcode using Doxygen}
12
+ s.description = %q{
13
+ Helps you publish HTML web pages on the Internet somewhere appropriate, e.g.
14
+ on GitHub via the gh-pages branch feature.
15
+
16
+ Works for Objective-C projects built using Apple's Xcode IDE and
17
+ consequently focuses on documentation within Objective-C and Objective-C++
18
+ source files; files ending with extensions h, m or mm.}
19
+
20
+ s.rubyforge_project = "XcodePages"
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.require_paths = ["lib"]
26
+
27
+ s.add_development_dependency "rake"
28
+ s.add_runtime_dependency "activesupport"
29
+ end
@@ -0,0 +1,3 @@
1
+ module XcodePages
2
+ VERSION = "0.0.1"
3
+ end
data/lib/XcodePages.rb ADDED
@@ -0,0 +1,145 @@
1
+ # encoding: utf-8
2
+
3
+ require "XcodePages/version"
4
+ require 'active_support/core_ext/string'
5
+ require 'tempfile'
6
+
7
+ module XcodePages
8
+ # Prints the environment. Xcode passes many useful pieces of information via
9
+ # the Unix environment.
10
+ #
11
+ # This can be useful for testing. Add an external build target to Xcode. Make
12
+ # the Build Tool equal to /bin/sh and make the arguments equal to:
13
+ #
14
+ # -c "$HOME/.rvm/bin/rvm-auto-ruby -r XcodePages -e XcodePages.print_env"
15
+ #
16
+ # and you will see all the Unix environment variables. This assumes that you
17
+ # are using RVM in your local account to manage Ruby.
18
+ def self.print_env
19
+ ENV.each { |key, value| puts "#{key}=#{value}" }
20
+ end
21
+
22
+ # Searches for all the available source files (files with h, m or mm
23
+ # extension) in the current working directory or below. Pulls out their
24
+ # directory names and answers an array of unique space-delimited relative
25
+ # folder paths. These directory names will become Doxygen input folders.
26
+ #
27
+ # The implementation assumes that the current working directory equals the
28
+ # Xcode source root. It also makes some simplifying assumptions about spaces
29
+ # in the paths: that there are *no* spaces. Doxygen uses spaces to delimit the
30
+ # files and directories listed for input. But what if the paths themselves
31
+ # contain spaces?
32
+ #
33
+ # Note that this method works correctly when the source root itself contains
34
+ # headers or sources. In this case, the answer will contain the "." directory.
35
+ def self.input
36
+ Dir.glob('**/*.{h,m,mm}').map { |relative_path| File.dirname(relative_path) }.uniq.join(' ')
37
+ end
38
+
39
+ # Answers the project "marketing version" using Apple's +agvtool+. The
40
+ # marketing version is the "bundle short version string" appearing in the
41
+ # bundle's +Info.plist+. Cocoa only uses this for display in the standard
42
+ # About panel.
43
+ def self.marketing_version
44
+ %x(agvtool mvers -terse1).chomp
45
+ end
46
+
47
+ # Answers the project build version using Apple's +agvtool+. This is the real
48
+ # version number, equating to +CURRENT_PROJECT_VERSION+.
49
+ def self.build_version
50
+ %x(agvtool vers -terse).chomp
51
+ end
52
+
53
+ # Answers what Doxygen calls the ‘project number.’ This is the revision
54
+ # number appearing beside the project name in the documentation title. Uses
55
+ # the marketing and build version numbers in the format +vMV (BV)+ where +MV+
56
+ # stands for marketing version and +BV+ stands for build version. Omits the
57
+ # build version if the project matches marketing and build version. No sense
58
+ # repeating the same number if they are the same.
59
+ def self.project_number
60
+ project_number = "v#{marketing_version}"
61
+ project_number << "&nbsp;(#{build_version})" if build_version != marketing_version
62
+ end
63
+
64
+ # Answers the path of the output directory. Doxygen outputs to this folder.
65
+ # HTML web pages appear in the +html+ sub-folder.
66
+ def self.output_directory
67
+ "#{ENV['PROJECT_NAME']}Pages"
68
+ end
69
+
70
+ # Answers the path to the +html+ output sub-folder where Doxygen writes the
71
+ # HTML web pages and the DocSet +Makefile+ when +GENERATE_DOCSET+ equals
72
+ # +YES+.
73
+ def self.html_output_directory
74
+ File.join(output_directory, 'html')
75
+ end
76
+
77
+ # Launches Doxygen.
78
+ #
79
+ # The implementation derives the Doxygen project name from the environment
80
+ # PROJECT_NAME variable. Xcode passes this variable. Typically, it is a
81
+ # camel-cased name. Using ActiveSupport (part of the Rails framework) the
82
+ # implementation below derives a humanised title; effectively puts spaces
83
+ # in-between the camels!
84
+ def self.doxygen
85
+ IO.popen('doxygen -', 'r+') do |doxygen|
86
+ doxygen.puts <<-EOF
87
+ PROJECT_NAME = #{ENV['PROJECT_NAME'].titleize}
88
+ PROJECT_NUMBER = #{project_number}
89
+ OUTPUT_DIRECTORY = #{output_directory}
90
+ TAB_SIZE = 4
91
+ EXTENSION_MAPPING = h=Objective-C
92
+ INPUT = #{input}
93
+ SOURCE_BROWSER = YES
94
+ HTML_TIMESTAMP = NO
95
+ GENERATE_LATEX = NO
96
+ HAVE_DOT = YES
97
+ EOF
98
+
99
+ # Let the user override the previous defaults by loading up the Doxyfile
100
+ # if one exists. This should appear in the source root folder.
101
+ if File.exists?('Doxyfile')
102
+ doxygen.write File.read('Doxyfile')
103
+ end
104
+
105
+ # Close the write-end of the pipe.
106
+ doxygen.close_write
107
+
108
+ # Read the read-end of the pipe and send the lines to standard output.
109
+ puts doxygen.readlines
110
+ end
111
+ end
112
+
113
+ # Launches Doxygen and builds the Apple DocSet. It does not install the
114
+ # DocSet. The compiled documentation set remains in the +html+ sub-folder.
115
+ def self.doxygen_docset
116
+ doxygen
117
+ # Assume that doxygen succeeds. But what happens when it does not?
118
+ %x(cd #{html_output_directory} ; make)
119
+ end
120
+
121
+ # Runs Doxygen and installs the Apple DocSet in the current user's shared
122
+ # documentation folder. Finally, as a courtesy, it tells Xcode about the
123
+ # change; signalling an update in your running Xcode IDE. Documentation
124
+ # updates immediately.
125
+ def self.doxygen_docset_install
126
+ doxygen
127
+ %x(cd #{html_output_directory} ; make install)
128
+
129
+ script = Tempfile.open(['XcodePages', '.scpt']) do |script|
130
+ script.puts <<-EOF
131
+ tell application "Xcode"
132
+ EOF
133
+ Dir.glob(File.join(html_output_directory, '*.docset')).each do |docset_path|
134
+ script.puts <<-EOF
135
+ load documentation set with path "#{ENV['HOME']}/Library/Developer/Shared/Documentation/DocSets/#{File.basename(docset_path)}"
136
+ EOF
137
+ end
138
+ script.puts <<-EOF
139
+ end tell
140
+ EOF
141
+ script.close
142
+ %x(osascript #{script.path})
143
+ end
144
+ end
145
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: XcodePages
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Roy Ratcliffe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70122300103820 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70122300103820
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &70122300091600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70122300091600
36
+ description: ! "\n Helps you publish HTML web pages on the Internet somewhere appropriate,
37
+ e.g.\n on GitHub via the gh-pages branch feature.\n\n Works for Objective-C
38
+ projects built using Apple's Xcode IDE and\n consequently focuses on documentation
39
+ within Objective-C and Objective-C++\n source files; files ending with extensions
40
+ h, m or mm."
41
+ email:
42
+ - roy@pioneeringsoftware.co.uk
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - Gemfile
49
+ - README.rdoc
50
+ - Rakefile
51
+ - XcodePages.gemspec
52
+ - lib/XcodePages.rb
53
+ - lib/XcodePages/version.rb
54
+ homepage: ''
55
+ licenses: []
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project: XcodePages
74
+ rubygems_version: 1.8.10
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Helps you publish documentation from within Xcode using Doxygen
78
+ test_files: []
79
+ has_rdoc: