fancy 0.3.0
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/AUTHORS +7 -0
- data/LICENSE +19 -0
- data/README +173 -0
- data/Rakefile +255 -0
- data/bin/fancy +40 -0
- data/bin/fdoc +23 -0
- data/bin/fyi +22 -0
- data/bin/ifancy +46 -0
- data/boot/README +12 -0
- data/boot/code_loader.rb +165 -0
- data/boot/compile.fy +3 -0
- data/boot/fancy_ext.rb +13 -0
- data/boot/fancy_ext/block_env.rb +29 -0
- data/boot/fancy_ext/class.rb +26 -0
- data/boot/fancy_ext/kernel.rb +12 -0
- data/boot/fancy_ext/module.rb +89 -0
- data/boot/fancy_ext/object.rb +34 -0
- data/boot/fancy_ext/string_helper.rb +10 -0
- data/boot/load.rb +72 -0
- data/boot/rbx-compiler/README +12 -0
- data/boot/rbx-compiler/compiler.rb +24 -0
- data/boot/rbx-compiler/compiler/ast.rb +23 -0
- data/boot/rbx-compiler/compiler/ast/README +11 -0
- data/boot/rbx-compiler/compiler/ast/array_literal.rb +13 -0
- data/boot/rbx-compiler/compiler/ast/assign.rb +57 -0
- data/boot/rbx-compiler/compiler/ast/block.rb +70 -0
- data/boot/rbx-compiler/compiler/ast/class_def.rb +35 -0
- data/boot/rbx-compiler/compiler/ast/expression_list.rb +57 -0
- data/boot/rbx-compiler/compiler/ast/hash_literal.rb +11 -0
- data/boot/rbx-compiler/compiler/ast/identifier.rb +120 -0
- data/boot/rbx-compiler/compiler/ast/match.rb +81 -0
- data/boot/rbx-compiler/compiler/ast/message_send.rb +71 -0
- data/boot/rbx-compiler/compiler/ast/method_def.rb +116 -0
- data/boot/rbx-compiler/compiler/ast/node.rb +6 -0
- data/boot/rbx-compiler/compiler/ast/range_literal.rb +22 -0
- data/boot/rbx-compiler/compiler/ast/require.rb +20 -0
- data/boot/rbx-compiler/compiler/ast/return.rb +29 -0
- data/boot/rbx-compiler/compiler/ast/ruby_args.rb +35 -0
- data/boot/rbx-compiler/compiler/ast/script.rb +56 -0
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +39 -0
- data/boot/rbx-compiler/compiler/ast/string_literal.rb +14 -0
- data/boot/rbx-compiler/compiler/ast/super.rb +25 -0
- data/boot/rbx-compiler/compiler/ast/try_catch_block.rb +220 -0
- data/boot/rbx-compiler/compiler/ast/tuple_literal.rb +33 -0
- data/boot/rbx-compiler/compiler/command.rb +39 -0
- data/boot/rbx-compiler/compiler/compiler.rb +83 -0
- data/boot/rbx-compiler/compiler/stages.rb +99 -0
- data/boot/rbx-compiler/parser.rb +2 -0
- data/boot/rbx-compiler/parser/README +15 -0
- data/boot/rbx-compiler/parser/Rakefile +54 -0
- data/boot/rbx-compiler/parser/extconf.rb +3 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/fancy_parser.c +46 -0
- data/boot/rbx-compiler/parser/fancy_parser.h +8 -0
- data/boot/rbx-compiler/parser/lexer.lex +180 -0
- data/boot/rbx-compiler/parser/parser.rb +356 -0
- data/boot/rbx-compiler/parser/parser.y +711 -0
- data/boot/rsexp_pretty_printer.rb +76 -0
- data/doc/api/fancy.css +93 -0
- data/doc/api/fancy.jsonp +1 -0
- data/doc/api/fdoc.js +187 -0
- data/doc/api/index.html +57 -0
- data/doc/api/underscore-min.js +18 -0
- data/doc/features.md +228 -0
- data/examples/argv.fy +8 -0
- data/examples/arithmetic.fy +7 -0
- data/examples/armstrong_numbers.fy +33 -0
- data/examples/array.fy +52 -0
- data/examples/blocks.fy +15 -0
- data/examples/boolean.fy +24 -0
- data/examples/call_with_receiver.fy +9 -0
- data/examples/class.fy +68 -0
- data/examples/closures.fy +24 -0
- data/examples/constant_access.fy +15 -0
- data/examples/default_args.fy +17 -0
- data/examples/define_methods.fy +15 -0
- data/examples/documentation.fy +57 -0
- data/examples/documentation_formatters.fy +25 -0
- data/examples/echo.fy +16 -0
- data/examples/empty_catch.fy +4 -0
- data/examples/exception.fy +9 -0
- data/examples/factorial.fy +12 -0
- data/examples/fibonacci.fy +16 -0
- data/examples/files.fy +23 -0
- data/examples/finally.fy +5 -0
- data/examples/game_of_life.fy +148 -0
- data/examples/hashes.fy +7 -0
- data/examples/hello_world.fy +6 -0
- data/examples/html_generator.fy +54 -0
- data/examples/implicit_return.fy +3 -0
- data/examples/matchers.fy +6 -0
- data/examples/methods.fy +29 -0
- data/examples/nested_classes.fy +27 -0
- data/examples/nested_try.fy +9 -0
- data/examples/numbers.fy +12 -0
- data/examples/pattern_matching.fy +40 -0
- data/examples/person.fy +65 -0
- data/examples/project-euler/01.fy +8 -0
- data/examples/project-euler/02.fy +21 -0
- data/examples/project-euler/28.fy +33 -0
- data/examples/rbx/and_or.fy +7 -0
- data/examples/rbx/blocks.fy +22 -0
- data/examples/rbx/classes.fy +32 -0
- data/examples/rbx/hello.fy +8 -0
- data/examples/rbx/include.fy +12 -0
- data/examples/rbx/inherit.fy +11 -0
- data/examples/rbx/methods.fy +15 -0
- data/examples/rbx/nested_classes.fy +9 -0
- data/examples/rbx/require.fy +3 -0
- data/examples/rbx/strings.fy +5 -0
- data/examples/regex.fy +7 -0
- data/examples/require.fy +7 -0
- data/examples/retry.fy +12 -0
- data/examples/return.fy +13 -0
- data/examples/ruby_require.fy +7 -0
- data/examples/ruby_send.fy +3 -0
- data/examples/singleton_methods.fy +21 -0
- data/examples/stupid_quicksort.fy +12 -0
- data/examples/threads.fy +18 -0
- data/examples/tuple.fy +8 -0
- data/examples/webserver/webserver.fy +18 -0
- data/lib/argv.fy +36 -0
- data/lib/array.fy +207 -0
- data/lib/block.fy +88 -0
- data/lib/boot.fy +41 -0
- data/lib/class.fy +106 -0
- data/lib/compiler.fy +14 -0
- data/lib/compiler/ast.fy +40 -0
- data/lib/compiler/ast/assign.fy +96 -0
- data/lib/compiler/ast/block.fy +84 -0
- data/lib/compiler/ast/class_def.fy +33 -0
- data/lib/compiler/ast/expression_list.fy +47 -0
- data/lib/compiler/ast/identifier.fy +113 -0
- data/lib/compiler/ast/literals.fy +122 -0
- data/lib/compiler/ast/match.fy +88 -0
- data/lib/compiler/ast/message_send.fy +110 -0
- data/lib/compiler/ast/method_def.fy +90 -0
- data/lib/compiler/ast/node.fy +7 -0
- data/lib/compiler/ast/range.fy +16 -0
- data/lib/compiler/ast/require.fy +15 -0
- data/lib/compiler/ast/return.fy +23 -0
- data/lib/compiler/ast/script.fy +52 -0
- data/lib/compiler/ast/singleton_method_def.fy +35 -0
- data/lib/compiler/ast/super.fy +17 -0
- data/lib/compiler/ast/try_catch.fy +176 -0
- data/lib/compiler/ast/tuple_literal.fy +34 -0
- data/lib/compiler/command.fy +51 -0
- data/lib/compiler/compiler.fy +73 -0
- data/lib/compiler/stages.fy +81 -0
- data/lib/directory.fy +17 -0
- data/lib/documentation.fy +115 -0
- data/lib/enumerable.fy +269 -0
- data/lib/eval.fy +31 -0
- data/lib/fancy_spec.fy +202 -0
- data/lib/fdoc.fy +359 -0
- data/lib/fdoc_hook.fy +10 -0
- data/lib/file.fy +54 -0
- data/lib/hash.fy +56 -0
- data/lib/main.fy +80 -0
- data/lib/method.fy +22 -0
- data/lib/nil_class.fy +56 -0
- data/lib/number.fy +87 -0
- data/lib/object.fy +170 -0
- data/lib/package.fy +61 -0
- data/lib/package/dependency.fy +24 -0
- data/lib/package/installer.fy +180 -0
- data/lib/package/specification.fy +55 -0
- data/lib/package/uninstaller.fy +15 -0
- data/lib/parser.fy +4 -0
- data/lib/parser/ext/README +15 -0
- data/lib/parser/ext/ext.c +42 -0
- data/lib/parser/ext/ext.h +8 -0
- data/lib/parser/ext/extconf.rb +3 -0
- data/lib/parser/ext/lexer.lex +187 -0
- data/lib/parser/ext/parser.y +744 -0
- data/lib/parser/methods.fy +297 -0
- data/lib/rbx.fy +37 -0
- data/lib/rbx/array.fy +237 -0
- data/lib/rbx/bignum.fy +23 -0
- data/lib/rbx/block.fy +9 -0
- data/lib/rbx/class.fy +129 -0
- data/lib/rbx/code_loader.fy +192 -0
- data/lib/rbx/console.fy +63 -0
- data/lib/rbx/directory.fy +46 -0
- data/lib/rbx/documentation.fy +64 -0
- data/lib/rbx/environment_variables.fy +3 -0
- data/lib/rbx/exception.fy +30 -0
- data/lib/rbx/false_class.fy +58 -0
- data/lib/rbx/fiber.fy +25 -0
- data/lib/rbx/file.fy +191 -0
- data/lib/rbx/fixnum.fy +25 -0
- data/lib/rbx/float.fy +14 -0
- data/lib/rbx/hash.fy +38 -0
- data/lib/rbx/integer.fy +15 -0
- data/lib/rbx/io.fy +30 -0
- data/lib/rbx/match_data.fy +9 -0
- data/lib/rbx/method.fy +22 -0
- data/lib/rbx/name_error.fy +3 -0
- data/lib/rbx/no_method_error.fy +15 -0
- data/lib/rbx/object.fy +117 -0
- data/lib/rbx/range.fy +15 -0
- data/lib/rbx/regexp.fy +9 -0
- data/lib/rbx/string.fy +63 -0
- data/lib/rbx/symbol.fy +12 -0
- data/lib/rbx/system.fy +37 -0
- data/lib/rbx/tcp_server.fy +6 -0
- data/lib/rbx/tcp_socket.fy +7 -0
- data/lib/rbx/thread.fy +75 -0
- data/lib/rbx/tuple.fy +37 -0
- data/lib/set.fy +61 -0
- data/lib/stack.fy +51 -0
- data/lib/string.fy +58 -0
- data/lib/struct.fy +13 -0
- data/lib/symbol.fy +23 -0
- data/lib/true_class.fy +43 -0
- data/lib/tuple.fy +68 -0
- data/lib/version.fy +6 -0
- data/tests/argv.fy +13 -0
- data/tests/array.fy +343 -0
- data/tests/assignment.fy +53 -0
- data/tests/block.fy +103 -0
- data/tests/class.fy +409 -0
- data/tests/control_flow.fy +79 -0
- data/tests/documentation.fy +24 -0
- data/tests/exception.fy +115 -0
- data/tests/file.fy +86 -0
- data/tests/hash.fy +101 -0
- data/tests/method.fy +131 -0
- data/tests/nil_class.fy +55 -0
- data/tests/number.fy +128 -0
- data/tests/object.fy +125 -0
- data/tests/parsing/sexp.fy +50 -0
- data/tests/pattern_matching.fy +82 -0
- data/tests/range.fy +11 -0
- data/tests/set.fy +10 -0
- data/tests/stack.fy +22 -0
- data/tests/string.fy +102 -0
- data/tests/symbol.fy +17 -0
- data/tests/true_class.fy +63 -0
- data/tests/tuple.fy +21 -0
- data/tools/fancy-mode.el +63 -0
- metadata +321 -0
data/examples/argv.fy
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# argv.fy
|
2
|
+
# Example of fancy's interface for command line arguments
|
3
|
+
|
4
|
+
"This will always get printed, even when required from another file" println
|
5
|
+
|
6
|
+
if: (ARGV[0] == __FILE__) then: {
|
7
|
+
"This will get printed, if this file is directly run with fancy" println
|
8
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# armstrong_numbers.fy
|
2
|
+
# Calculates & outputs all Armstrong Numbers between 0 and 10000.
|
3
|
+
# See http://en.wikipedia.org/wiki/Narcissistic_number for more
|
4
|
+
# information.
|
5
|
+
|
6
|
+
class Fixnum {
|
7
|
+
def decimals {
|
8
|
+
"""Returns all decimals of a Number as an Array.
|
9
|
+
E.g. 123 decimals # => [1,2,3]"""
|
10
|
+
|
11
|
+
decimals = []
|
12
|
+
tmp = self
|
13
|
+
while: { tmp >= 10 } do: {
|
14
|
+
decimals << (tmp modulo: 10)
|
15
|
+
tmp = (tmp div: 10)
|
16
|
+
}
|
17
|
+
decimals << tmp
|
18
|
+
decimals
|
19
|
+
}
|
20
|
+
|
21
|
+
def armstrong? {
|
22
|
+
"Indicates, if a Number is a Armstrong Number."
|
23
|
+
|
24
|
+
decimals = self decimals
|
25
|
+
n_decimals = decimals size
|
26
|
+
decimals map: |x| { x ** n_decimals } . sum == self
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
# output alls Armstrong Numbers between 0 and 10000
|
31
|
+
0 upto: 10000 do_each: |i| {
|
32
|
+
{ i println } if: $ i armstrong?
|
33
|
+
}
|
data/examples/array.fy
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# array.fy
|
2
|
+
# Examples of fancy Arrays
|
3
|
+
|
4
|
+
# create an array
|
5
|
+
arr = [1,2,3,4,5,6]
|
6
|
+
|
7
|
+
# print each element squared
|
8
|
+
arr each: |x| {
|
9
|
+
x squared println
|
10
|
+
}
|
11
|
+
|
12
|
+
# display each element with its index in the array
|
13
|
+
arr each_with_index: |x i| {
|
14
|
+
"Index " ++ i ++ " -> " ++ x println
|
15
|
+
}
|
16
|
+
|
17
|
+
# print the array of squared elements
|
18
|
+
arr map: 'squared . inspect println
|
19
|
+
|
20
|
+
# print the array of doubled elements
|
21
|
+
arr map: 'doubled . inspect println
|
22
|
+
|
23
|
+
# print array of all elements smaller than 4
|
24
|
+
arr select: |x| { x < 4 } . inspect println
|
25
|
+
|
26
|
+
# print array of all elements that are not smaller than 4
|
27
|
+
arr reject: |x| { x < 4 } . inspect println
|
28
|
+
|
29
|
+
# prints: [5, 6]
|
30
|
+
arr take_while: |x| { x < 5 } . inspect println
|
31
|
+
|
32
|
+
"testing reduce:init_val: " print
|
33
|
+
arr reduce: |acc x| { acc * x } init_val: 1 . println # same as: 1*1*2*3*4*5*6
|
34
|
+
|
35
|
+
"testing any?: " print
|
36
|
+
arr any?: |x| { x > 3 } . println # prints: true
|
37
|
+
|
38
|
+
"testing all?: " print
|
39
|
+
arr all?: |x| { x < 7 } . println # prints: true
|
40
|
+
|
41
|
+
"testing from:to: " print
|
42
|
+
arr [[3,5]] . inspect println # prints: [4, 5, 6]
|
43
|
+
|
44
|
+
# some other handy methods
|
45
|
+
"testing size: " print
|
46
|
+
arr size println # prints: 6
|
47
|
+
|
48
|
+
"testing to_s: " print
|
49
|
+
arr to_s println # prints: 123456
|
50
|
+
|
51
|
+
"testing inspect: " print
|
52
|
+
arr inspect println # prints: [1, 2, 3, 4, 5, 6] : Array
|
data/examples/blocks.fy
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# blocks.fy
|
2
|
+
# Examples of fancy code blocks
|
3
|
+
|
4
|
+
x = { Console println: "Println from within block!" }
|
5
|
+
x call # calls x and prints: "Println from within block!"
|
6
|
+
|
7
|
+
y = |x y| { Console println: $ x + y }
|
8
|
+
y call: [2, 3] # calls y and prints: 5
|
9
|
+
|
10
|
+
# prints numbers 0 to 20
|
11
|
+
zahl = 0
|
12
|
+
while: { zahl <= 20 } do: {
|
13
|
+
Console println: zahl
|
14
|
+
zahl = zahl + 1
|
15
|
+
}
|
data/examples/boolean.fy
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# boolean.fy
|
2
|
+
# Example of boolean expressions and logical operations in fancy
|
3
|
+
|
4
|
+
true and: true . println # true
|
5
|
+
true and: nil . println # nil
|
6
|
+
nil and: nil . println # nil
|
7
|
+
|
8
|
+
true or: true . println # true
|
9
|
+
true or: nil . println # true
|
10
|
+
nil or: nil . println # nil
|
11
|
+
|
12
|
+
|
13
|
+
"--------------" println
|
14
|
+
|
15
|
+
# won't print string
|
16
|
+
nil if_true: {
|
17
|
+
"this should _not_ be displayed" println
|
18
|
+
}
|
19
|
+
|
20
|
+
# will print string
|
21
|
+
nil if_false: {
|
22
|
+
"this _should_ be displayed" println
|
23
|
+
}
|
24
|
+
|
data/examples/class.fy
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# class.fy
|
2
|
+
# Example of fancy's classes mechanism
|
3
|
+
|
4
|
+
class Bar {
|
5
|
+
def initialize {
|
6
|
+
Console println: "In Bar constructor!"
|
7
|
+
}
|
8
|
+
|
9
|
+
def say_hello: name {
|
10
|
+
Console print: "Hello, "
|
11
|
+
Console println: name
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
class Foo : Bar {
|
16
|
+
def initialize: name {
|
17
|
+
Console println: "gonna set @name"
|
18
|
+
@name = name
|
19
|
+
}
|
20
|
+
def say_hello {
|
21
|
+
Console print: "Hello, "
|
22
|
+
Console println: @name
|
23
|
+
{@block call} if: @block
|
24
|
+
}
|
25
|
+
def on_hello_do: block {
|
26
|
+
@block = block
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
bar = Bar new
|
31
|
+
bar say_hello: "Chris"
|
32
|
+
|
33
|
+
foo = Foo new: "Chris from Constructor"
|
34
|
+
foo say_hello
|
35
|
+
foo on_hello_do: {
|
36
|
+
Console println: "Call me when calling on_hello! :)"
|
37
|
+
}
|
38
|
+
foo say_hello
|
39
|
+
|
40
|
+
foo class println # print the class of foo
|
41
|
+
|
42
|
+
# define a singleton method on foo object
|
43
|
+
foo define_singleton_method: "foo!" with: {
|
44
|
+
"In foo method :D" println
|
45
|
+
}
|
46
|
+
|
47
|
+
foo foo!
|
48
|
+
|
49
|
+
# define a 'normal' method on Foo class
|
50
|
+
# (instance method for all instances of Foo)
|
51
|
+
foo class define_method: "foo_for_all:" with: |x| {
|
52
|
+
"In foo_for_all method (defined for all instances of Foo class)" println
|
53
|
+
"Got argument: " ++ x println
|
54
|
+
}
|
55
|
+
|
56
|
+
foo2 = Foo new
|
57
|
+
foo2 foo_for_all: "hello, test! :)"
|
58
|
+
foo foo_for_all: "hello, test (again)! :)"
|
59
|
+
|
60
|
+
# define a class method on Foo class
|
61
|
+
# it's the same as calling 'define_singleton_method:with:' on class
|
62
|
+
foo class define_class_method: "cool_class_method:" with: |arg| {
|
63
|
+
"In class method for Foo! Argument given: " ++ arg println
|
64
|
+
}
|
65
|
+
|
66
|
+
# the following is the same as:
|
67
|
+
# foo class cool_class_method: "Some argument string"
|
68
|
+
Foo cool_class_method: "Some argument string"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# closure.fy
|
2
|
+
# Example of closures in fancy
|
3
|
+
|
4
|
+
# method that returns a closure
|
5
|
+
def create_counter: number {
|
6
|
+
closure = {
|
7
|
+
number = number + 1
|
8
|
+
}
|
9
|
+
closure
|
10
|
+
}
|
11
|
+
|
12
|
+
# create a counter from 100 upwards
|
13
|
+
closure = create_counter: 100
|
14
|
+
# this will print numbers 100 - 120
|
15
|
+
20 times: {
|
16
|
+
Console println: $ closure call
|
17
|
+
}
|
18
|
+
|
19
|
+
# create a counter from 500 upwards
|
20
|
+
closure = create_counter: 500
|
21
|
+
# this will print numbers 500 - 510
|
22
|
+
10 times: {
|
23
|
+
Console println: $ closure call
|
24
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# default_args.fy
|
2
|
+
# Example of fancy's default arguments
|
3
|
+
|
4
|
+
def arg1: arg1 arg2: arg2 ("default_arg2") arg3: arg3 ("default_arg3") {
|
5
|
+
"arguments are: " println
|
6
|
+
arg1 println
|
7
|
+
arg2 println
|
8
|
+
arg3 println
|
9
|
+
}
|
10
|
+
|
11
|
+
arg1: "hello" arg2: "world" arg3: "how are you?"
|
12
|
+
|
13
|
+
Console newline
|
14
|
+
arg1: "hello" arg2: "world"
|
15
|
+
|
16
|
+
Console newline
|
17
|
+
arg1: "hello"
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# documentation.fy
|
2
|
+
# Example about fancys built-in documentation facilities
|
3
|
+
|
4
|
+
class Foo {
|
5
|
+
|
6
|
+
"""
|
7
|
+
If first expression in a class body is an string literal
|
8
|
+
it is used as documentation.
|
9
|
+
"""
|
10
|
+
|
11
|
+
m = def foo: x bar: y (22) {
|
12
|
+
"Prints its own documentation."
|
13
|
+
"TODO: obtain methodContext and print own documentation" println
|
14
|
+
}
|
15
|
+
m documentation println
|
16
|
+
|
17
|
+
}
|
18
|
+
|
19
|
+
foo = Foo new
|
20
|
+
|
21
|
+
foo method: 'foo:bar: . documentation println
|
22
|
+
foo method: 'foo: . documentation println
|
23
|
+
|
24
|
+
def foo bar: n {
|
25
|
+
"A singleton method"
|
26
|
+
n println
|
27
|
+
}
|
28
|
+
|
29
|
+
foo method: 'bar: . documentation println
|
30
|
+
|
31
|
+
Foo instance_method: 'foo: . documentation println
|
32
|
+
|
33
|
+
Foo documentation println
|
34
|
+
|
35
|
+
block = |a, b| {
|
36
|
+
"A block can also have a documentation string, just like methods"
|
37
|
+
a + b
|
38
|
+
}
|
39
|
+
|
40
|
+
block documentation println
|
41
|
+
|
42
|
+
|
43
|
+
Math PI documentation: "An aproximation of the PI number"
|
44
|
+
Math PI documentation println
|
45
|
+
|
46
|
+
Fancy Documentation documentation println
|
47
|
+
|
48
|
+
Fancy Documentation for: Foo append: "Re-Openning Foo class to add more docs."
|
49
|
+
|
50
|
+
class Foo {
|
51
|
+
"""
|
52
|
+
Fancy provides an incremental documentation feature.
|
53
|
+
"""
|
54
|
+
self documentation println
|
55
|
+
}
|
56
|
+
|
57
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# documentation_formatters.fy
|
2
|
+
# Example of fancy's documentation formatters
|
3
|
+
|
4
|
+
foo = Object new
|
5
|
+
|
6
|
+
Fancy Documentation for: foo is: """
|
7
|
+
## Fancy documentation.
|
8
|
+
|
9
|
+
It should be possible to set documentation for any _arbitray object_.
|
10
|
+
Doing so will expose it on the API documents.
|
11
|
+
This can be useful for constants, or singleton objects.
|
12
|
+
|
13
|
+
## Fancy Documentation formatters
|
14
|
+
|
15
|
+
Fancy you to create custom documentation formatters,
|
16
|
+
thus, allowing you to display an object document in a well
|
17
|
+
formatted way for different environments, eg. when using the
|
18
|
+
interactive REPL you may want *ANSI* _colored_ output, or maybe
|
19
|
+
we create a tool to generate MAN(1) pages, and fdoc tool
|
20
|
+
to generate HTML API docs.
|
21
|
+
|
22
|
+
"""
|
23
|
+
|
24
|
+
Fancy Documentation for: foo . format: 'markdown . println
|
25
|
+
|
data/examples/echo.fy
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# echo.fy
|
2
|
+
# Outputs contents of files
|
3
|
+
|
4
|
+
ARGV[1] if_do: |filename| {
|
5
|
+
try {
|
6
|
+
File open: filename modes: ['read] with: |f| {
|
7
|
+
until: { f eof? } do: {
|
8
|
+
f readln println
|
9
|
+
}
|
10
|
+
}
|
11
|
+
} catch IOError => e {
|
12
|
+
"[ERROR] " ++ (e message) println
|
13
|
+
}
|
14
|
+
} else: {
|
15
|
+
"Usage: fancy echo.fy [filename]" println
|
16
|
+
}
|