Skip to content

Commit 961a98d

Browse files
committed
Ensure code samples in docs can be executed
1 parent a698484 commit 961a98d

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ so please check *Changed* and *Removed* notes before upgrading.
88
### Fixed
99
- Do not force adding paths with shared named parameter in an specific order (@jwoertink)
1010
- Give proper name to `Radix::VERSION` spec when running in verbose mode.
11+
- Ensure code samples in docs can be executed.
1112

1213
## [0.3.1] - 2016-07-29
1314
### Added

src/radix/node.cr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ module Radix
1414
# methods within `Tree`.
1515
#
1616
# ```
17-
# node = Node.new("/", :root)
18-
# node.children << Node.new("a", :a)
19-
# node.children << Node.new("bc", :bc)
20-
# node.children << Node.new("def", :def)
17+
# node = Radix::Node.new("/", :root)
18+
# node.children << Radix::Node.new("a", :a)
19+
# node.children << Radix::Node.new("bc", :bc)
20+
# node.children << Radix::Node.new("def", :def)
2121
# node.sort!
2222
#
2323
# node.priority
@@ -42,16 +42,16 @@ module Radix
4242
# * Any other type of key will receive priority based on its size.
4343
#
4444
# ```
45-
# Node(Nil).new("a").priority
45+
# Radix::Node(Nil).new("a").priority
4646
# # => 1
4747
#
48-
# Node(Nil).new("abc").priority
48+
# Radix::Node(Nil).new("abc").priority
4949
# # => 3
5050
#
51-
# Node(Nil).new("*filepath").priority
51+
# Radix::Node(Nil).new("*filepath").priority
5252
# # => 0
5353
#
54-
# Node(Nil).new(":query").priority
54+
# Radix::Node(Nil).new(":query").priority
5555
# # => 1
5656
# ```
5757
getter priority : Int32
@@ -66,13 +66,13 @@ module Radix
6666
#
6767
# ```
6868
# # Good, node type is inferred from payload (Symbol)
69-
# node = Node.new("/", :root)
69+
# node = Radix::Node.new("/", :root)
7070
#
7171
# # Good, node type is now Int32 but payload is optional
72-
# node = Node(Int32).new("/")
72+
# node = Radix::Node(Int32).new("/")
7373
#
7474
# # Error, node type cannot be inferred (compiler error)
75-
# node = Node.new("/")
75+
# node = Radix::Node.new("/")
7676
# ```
7777
def initialize(@key : String, @payload : T? = nil, @placeholder = false)
7878
@children = [] of Node(T)
@@ -82,7 +82,7 @@ module Radix
8282
# Changes current *key*
8383
#
8484
# ```
85-
# node = Node(Nil).new("a")
85+
# node = Radix::Node(Nil).new("a")
8686
# node.key
8787
# # => "a"
8888
#
@@ -94,7 +94,7 @@ module Radix
9494
# This will also result in a new priority for the node.
9595
#
9696
# ```
97-
# node = Node(Nil).new("a")
97+
# node = Radix::Node(Nil).new("a")
9898
# node.priority
9999
# # => 1
100100
#
@@ -129,11 +129,11 @@ module Radix
129129
# This ensures highest priority nodes are listed before others.
130130
#
131131
# ```
132-
# root = Node(Nil).new("/")
133-
# root.children << Node(Nil).new("*filepath") # node.priority => 0
134-
# root.children << Node(Nil).new(":query") # node.priority => 1
135-
# root.children << Node(Nil).new("a") # node.priority => 1
136-
# root.children << Node(Nil).new("bc") # node.priority => 2
132+
# root = Radix::Node(Nil).new("/")
133+
# root.children << Radix::Node(Nil).new("*filepath") # node.priority => 0
134+
# root.children << Radix::Node(Nil).new(":query") # node.priority => 1
135+
# root.children << Radix::Node(Nil).new("a") # node.priority => 1
136+
# root.children << Radix::Node(Nil).new("bc") # node.priority => 2
137137
# root.sort!
138138
#
139139
# root.children.map &.priority

src/radix/result.cr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ require "./node"
22

33
module Radix
44
# A Result is the comulative output of walking our [Radix tree](https://en.wikipedia.org/wiki/Radix_tree)
5-
# `Tree` implementation.
5+
# `Radix::Tree` implementation.
66
#
77
# It provides helpers to retrieve the information obtained from walking
8-
# our tree using `Tree#find`
8+
# our tree using `Radix::Tree#find`
99
#
1010
# This information can be used to perform actions in case of the *path*
1111
# that was looked on the Tree was found.
1212
#
13-
# A Result is also used recursively by `Tree#find` when collecting extra
14-
# information like *params*.
13+
# A Result is also used recursively by `Radix::Tree#find` when collecting
14+
# extra information like *params*.
1515
class Result(T)
1616
@key : String?
1717

@@ -28,11 +28,11 @@ module Radix
2828
# the result.
2929
#
3030
# ```
31-
# result = Result(Symbol).new
31+
# result = Radix::Result(Symbol).new
3232
# result.found?
3333
# # => false
3434
#
35-
# root = Node(Symbol).new("/", :root)
35+
# root = Radix::Node(Symbol).new("/", :root)
3636
# result.use(root)
3737
# result.found?
3838
# # => true
@@ -44,10 +44,10 @@ module Radix
4444
# Returns a String built based on the nodes used in the result
4545
#
4646
# ```
47-
# node1 = Node(Symbol).new("/", :root)
48-
# node2 = Node(Symbol).new("about", :about)
47+
# node1 = Radix::Node(Symbol).new("/", :root)
48+
# node2 = Radix::Node(Symbol).new("about", :about)
4949
#
50-
# result = Result(Symbol).new
50+
# result = Radix::Result(Symbol).new
5151
# result.use node1
5252
# result.use node2
5353
#
@@ -58,7 +58,7 @@ module Radix
5858
# When no node has been used, returns an empty String.
5959
#
6060
# ```
61-
# result = Result(Nil).new
61+
# result = Radix::Result(Nil).new
6262
# result.key
6363
# # => ""
6464
# ```

src/radix/tree.cr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module Radix
4545
# defined placeholder.
4646
#
4747
# ```
48-
# tree = Tree(Symbol).new
48+
# tree = Radix::Tree(Symbol).new
4949
#
5050
# # / (:root)
5151
# tree.add "/", :root
@@ -64,7 +64,7 @@ module Radix
6464
# segments of the given *path*.
6565
#
6666
# ```
67-
# tree = Tree(Symbol).new
67+
# tree = Radix::Tree(Symbol).new
6868
#
6969
# # / (:root)
7070
# tree.add "/", :root
@@ -84,7 +84,7 @@ module Radix
8484
# lower priority against other nodes.
8585
#
8686
# ```
87-
# tree = Tree(Symbol).new
87+
# tree = Radix::Tree(Symbol).new
8888
#
8989
# # / (:root)
9090
# tree.add "/", :root
@@ -208,7 +208,7 @@ module Radix
208208
# endpoint is found (or not).
209209
#
210210
# ```
211-
# tree = Tree(Symbol).new
211+
# tree = Radix::Tree(Symbol).new
212212
# tree.add "/about", :about
213213
#
214214
# result = tree.find "/products"

0 commit comments

Comments
 (0)