Skip to content

Commit

Permalink
removing stuff from cli and concentrating on config file
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Jun 13, 2011
1 parent 47bdc10 commit ddc9e8e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/js/docurium.js
Expand Up @@ -39,7 +39,7 @@ $(function() {
content = $('.content')
content.empty()

content.append($('<h1>').append("API Docs"))
content.append($('<h1>').append("Public API Functions"))

// Function Groups
for (var i in data['groups']) {
Expand Down
33 changes: 20 additions & 13 deletions lib/docurium.rb
Expand Up @@ -5,24 +5,27 @@
class Docurium
Version = VERSION = '0.0.1'

attr_accessor :header_dir, :branch, :output_dir, :valid, :data
attr_accessor :header_dir, :branch, :output_dir, :data

def initialize(dir)
@valid = false
def initialize(config_file)
@data = {:files => [], :functions => {}, :globals => {}, :types => {}, :prefix => ''}
if !dir
puts "You need to specify a directory"
else
@valid = true
@data[:prefix] = "include/git2"
@header_dir = File.expand_path(dir)
end
raise "You need to specify a config file" if !config_file
raise "You need to specify a valid config file" if !valid_config(config_file)
end

def set_function_filter(prefix)
@prefix_filter = prefix
def valid_config(file)
return false if !File.file?(file)
fpath = File.expand_path(file)
@project_dir = File.dirname(fpath)
@config_file = File.basename(fpath)
@options = JSON.parse(File.read(fpath))
@data[:prefix] = @options['input'] || ''
@header_dir = File.join(@project_dir, @data[:prefix])
raise "Not an input directory" if !File.directory?(@header_dir)
true
end


def set_branch(branch)
@branch = branch
end
Expand Down Expand Up @@ -57,7 +60,11 @@ def parse_headers
def group_functions
func = {}
@data[:functions].each_pair do |key, value|
k = key.gsub(@prefix_filter, '') if @prefix_filter
if @options['prefix']
k = key.gsub(@options['prefix'], '')
else
k = key
end
group, rest = k.split('_', 2)
next if group.empty?
if !rest
Expand Down
10 changes: 1 addition & 9 deletions lib/docurium/cli.rb
Expand Up @@ -3,15 +3,7 @@ class CLI

def self.doc(idir, options)
doc = Docurium.new(idir)
if doc.valid
doc.set_function_filter(options[:f]) if options[:f]
if options[:b]
doc.set_branch(options[:b])
elsif options[:o]
doc.set_output_dir(options[:o])
end
doc.generate_docs
end
doc.generate_docs
end

end
Expand Down

0 comments on commit ddc9e8e

Please sign in to comment.