lib/fdoc.fy in fancy-0.3.3 vs lib/fdoc.fy in fancy-0.4.0

- old
+ new

@@ -107,49 +107,50 @@ cls send(type ++ "s", false) each: |n| { mattr = <[]> exec = cls send(type, n) executable() methods delete(exec) mdoc = Fancy Documentation for: exec + { next } unless: mdoc # skip methods with no documentation if: mdoc then: { - mattr at: 'doc put: $ mdoc format: 'fdoc + mattr['doc]: $ mdoc format: 'fdoc if: (mdoc meta) then: { - mattr at: 'arg put: $ mdoc meta at: 'argnames + mattr['arg]: $ mdoc meta at: 'argnames } } if: (exec class() == Rubinius CompiledMethod) then: { relative_file = exec file() # HACK: We simply delete everything before lib/ # TODO: Fix, either use a -r (root) option or use __FILE__ relative_file = relative_file to_s gsub(/.*lib/, "lib") lines = exec lines() to_a() - mattr at: 'file put: $ relative_file + mattr['file]: $ relative_file # TODO calculate line numbers from compiled method # right now we only use the first line of code in the body. - mattr at: 'lines put: $ [lines[3], lines[3]] + mattr['lines]: $ [lines[3], lines[3]] } - attr[(type ++ "s") intern()] at: n put: mattr + attr[(type ++ "s") intern()] [n]: mattr } } def generate_map { map = <['title => "Fancy Documentation", 'date => Time now() to_s(), 'classes => <[]>, 'methods => <[]>, 'objects => <[]> ]> methods = @methods dup() @classes each: |cls| { - name = cls name() gsub("::", " ") + name = cls name gsub("::", " ") doc = Fancy Documentation for: cls attr = <[ 'doc => doc format: 'fdoc, 'instance_methods => <[]>, 'methods => <[]>, 'ancestors => cls ancestors() map: |c| { c name() gsub("::", " ") } ]> popuplate_methods: cls on: attr type: 'instance_method known: methods popuplate_methods: cls on: attr type: 'method known: methods - map['classes] at: name put: attr + map['classes][name]: attr } methods each: |cm| { cls = cm scope() module() cls_name = cls name() gsub("::", " ") @@ -161,11 +162,11 @@ attr = <[ 'args => doc meta at: 'argnames, 'doc => doc format: 'fdoc ]> - map['methods] at: full_name put: attr + map['methods][full_name]: attr } map } @@ -192,35 +193,20 @@ def self format: doc { str = doc to_s tags = <[ ]> - str = remove_indentation: str + str = str skip_leading_indentation str = remove_tags: str into: tags str = create_tags: str with: tags str = create_class_references: str str = create_method_references: str str = create_code: str str = htmlize: str str } - def self remove_indentation: str { - """ - Remove leading white space for multi-line strings. - This method expects the first character to be an line return. - """ - m = /^(\r?\n)*(\s+)/ match(str) - str = str strip() - if: m then: { - pattern = "^ {" ++ (m[2] size()) ++ "}" - rex = Regexp.new(pattern) - str = str gsub(rex, ""); - } - str - } - def self create_class_references: str { """ Creates class references for Fancy class names. A docstring may contain class names sorounded by @ @@ -311,10 +297,10 @@ def self remove_tags: str into: map { ary = str split(/\r?\n/) map: |line| { m = /^@([a-z@]\S+?)\s+(.*)/ match(line) if: m then: { - map at: (m[1]) put: (m[2]) + map[m[1]]: (m[2]) nil } else: { line } }