Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This template creates a javascript enhanced rdoc (similar to what is on http://w
1) Get the files (pick your flavor)
* tarball: http://github.com/breakpointer/ajax-rdoc/tarball/master)
* git: git clone git://github.com/breakpointer/ajax-rdoc.git

2) cd into the new ajax-rdoc directory

3) Install the generator and templates into your version of rdoc
Expand Down
68 changes: 34 additions & 34 deletions rdoc/generators/ajax_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# [classes] an html file for each class or module encountered.
# These classes are not grouped by file: if a file
# contains four classes, we'll generate an html
# file for the file itself, and four html files
# for the individual classes.
# file for the file itself, and four html files
# for the individual classes.
#
# Method descriptions appear in whatever entity (file, class,
# or module) that contains them.
Expand Down Expand Up @@ -49,10 +49,10 @@ module Generators

##
# Build a hash of all items that can be cross-referenced.
# This is used when we output required and included names:
# This is used when we output required and included names:
# if the names appear in this hash, we can generate
# an html cross reference to the appropriate description.
# We also use this when parsing comment blocks: any decorated
# We also use this when parsing comment blocks: any decorated
# words matching an entry in this list are hyperlinked.

class AllReferences
Expand Down Expand Up @@ -171,7 +171,7 @@ def handle_special_HYPERLINK(special)
def handle_special_TIDYLINK(special)
text = special.text
# unless text =~ /(\S+)\[(.*?)\]/
unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
return text
end
label = $1
Expand Down Expand Up @@ -203,7 +203,7 @@ def markup(str, remove_para=false)
@markup.add_special(/(
\b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
| \b([A-Z]\w+(::\w+)*) # A::B..
| \#\w+[!?=]? # #meth_name
| \#\w+[!?=]? # #meth_name
| \b\w+([_\/\.]+\w+)+[!?=]? # meth_name
)/x, :CROSSREF)

Expand Down Expand Up @@ -238,7 +238,7 @@ def markup(str, remove_para=false)


def style_url(path, css_name=nil)
css_name ||= CSS_NAME
css_name ||= CSS_NAME
end

# Build a webcvs URL with the given 'url' argument. URLs with a '%s' in them
Expand All @@ -260,7 +260,7 @@ def cvs_url(url, full_path)
# A Context is built by the parser to represent a container: contexts
# hold classes, modules, methods, require lists and include lists.
# ClassModule and TopLevel are the context objects we process here
#
#
class ContextUser

include MarkUp
Expand Down Expand Up @@ -360,12 +360,12 @@ def build_include_list(context)
def potentially_referenced_list(array)
res = []
array.each do |i|
ref = AllReferences[i.name]
ref = AllReferences[i.name]
# if !ref
# container = @context.parent
# while !ref && container
# name = container.name + "::" + i.name
# ref = AllReferences[name]
# ref = AllReferences[name]
# container = container.parent
# end
# end
Expand Down Expand Up @@ -400,12 +400,12 @@ def build_method_detail_list(section)

methods = @methods.sort
for singleton in [true, false]
for vis in [ :public, :protected, :private ]
for vis in [ :public, :protected, :private ]
res = []
methods.each do |m|
if m.section == section and
m.document_self and
m.visibility == vis and
m.document_self and
m.visibility == vis and
m.singleton == singleton
row = {}
if m.call_seq
Expand All @@ -428,7 +428,7 @@ def build_method_detail_list(section)
'name' => other.name,
'href' => other.viewer.path,
'aref' => other.viewer.aref
}
}
end
end
unless alias_names.empty?
Expand All @@ -448,7 +448,7 @@ def build_method_detail_list(section)
res << row
end
end
if res.size > 0
if res.size > 0
outer << {
"type" => vis.to_s.capitalize,
"category" => singleton ? "Class" : "Instance",
Expand All @@ -461,7 +461,7 @@ def build_method_detail_list(section)
end

# Build the structured list of classes and modules contained
# in this context.
# in this context.

def build_class_list(level, from, section, infile=nil)
res = ""
Expand All @@ -471,7 +471,7 @@ def build_class_list(level, from, section, infile=nil)
next unless mod.section == section
next if infile && !mod.defined_in?(infile)
if mod.document_self
res <<
res <<
prefix <<
"Module " <<
href(mod.viewer.path, "link", mod.full_name) <<
Expand All @@ -485,7 +485,7 @@ def build_class_list(level, from, section, infile=nil)
next if infile && !cls.defined_in?(infile)
if cls.document_self
res <<
prefix <<
prefix <<
"Class " <<
href(cls.viewer.path, "link", cls.full_name) <<
"<br />\n" <<
Expand Down Expand Up @@ -587,7 +587,7 @@ def scope
a.pop
a.join("::")
else
""
""
end
end

Expand Down Expand Up @@ -663,8 +663,8 @@ def build_attribute_list(section)
next unless att.section == section
if att.visibility == :public || att.visibility == :protected || @options.show_all
entry = {
"name" => CGI.escapeHTML(att.name),
"rw" => att.rw,
"name" => CGI.escapeHTML(att.name),
"rw" => att.rw,
"a_desc" => markup(att.comment, true)
}
unless att.visibility == :public || att.visibility == :protected
Expand Down Expand Up @@ -796,7 +796,7 @@ def parent_name

def full_file_source
ret_str = ""
File.open(@source_file_path, 'r') do |f|
File.open(@source_file_path, 'r') do |f|
while(!f.eof?) do
ret_str += f.readline()
end
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def markup_code(tokens)
end

# we rely on the fact that the first line of a source code
# listing has
# listing has
# # File xxxxx, line dddd

def add_line_numbers(src)
Expand All @@ -1092,7 +1092,7 @@ def add_line_numbers(src)
real_fmt = "%#{size}d: "
fmt = " " * (size+2)
src.gsub!(/^/) do
res = sprintf(fmt, first)
res = sprintf(fmt, first)
first += 1
fmt = real_fmt
res
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def initialize(options) #:not-new:
##
# Build the initial indices and output objects
# based on an array of TopLevel objects containing
# the extracted information.
# the extracted information.

def generate(toplevels)
@toplevels = toplevels
Expand Down Expand Up @@ -1194,20 +1194,20 @@ def write_style_sheet
template.write_html_on(f, values)
end
end

def write_javascript
#Argh... I couldn't figure out how to copy these from the template dir so they were copied into
# the template file "ajax.rb" and processed similarlly to the style sheets. Not exactly a good thing to do with
# external library code. Not very DRY.

File.open("api_grease.js", "w") do |f|
f << RDoc::Page::API_GREASE_JS
end

File.open("prototype.js", "w") do |f|
f << RDoc::Page::PROTOTYPE_JS
end

rescue LoadError
$stderr.puts "Could not find AJAX template"
exit 99
Expand All @@ -1219,7 +1219,7 @@ def write_javascript

def gen_sub_directories
File.makedirs(FILE_DIR, CLASS_DIR)
rescue
rescue
$stderr.puts $!.message
exit 1
end
Expand Down Expand Up @@ -1280,8 +1280,8 @@ def gen_into(list)
end

def gen_file_index
gen_an_index(@files, 'Files',
RDoc::Page::FILE_INDEX,
gen_an_index(@files, 'Files',
RDoc::Page::FILE_INDEX,
"fr_file_index.html")
end

Expand All @@ -1292,7 +1292,7 @@ def gen_class_index
end

def gen_method_index
gen_an_index(HtmlMethod.all_methods, 'Methods',
gen_an_index(HtmlMethod.all_methods, 'Methods',
RDoc::Page::METHOD_INDEX,
"fr_method_index.html")
end
Expand Down Expand Up @@ -1337,7 +1337,7 @@ def gen_main_index
'title' => CGI.escapeHTML(@options.title),
'charset' => @options.charset
}

values['inline_source'] = true
template.write_html_on(f, values)
end
Expand Down
Loading