Skip to content

Commit 07cc74f

Browse files
committed
Format inline code
1 parent 6922863 commit 07cc74f

File tree

11 files changed

+373
-365
lines changed

11 files changed

+373
-365
lines changed

en/documentation/faq/1/index.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Ruby features:
6666

6767
### Show me some Ruby code!
6868

69-
Let's define a class called Person, with a name and an age. We'll test our
69+
Let's define a class called `Person`, with a name and an age. We'll test our
7070
code by creating a few people and examining them.
7171

7272
~~~
@@ -100,8 +100,8 @@ zoe: 7
100100
~~~
101101

102102
The code uses regular expressions to parse successive lines from the input
103-
file, creating a new Person object for each match and pushing it on to the
104-
end of the array people.
103+
file, creating a new `Person` object for each match and pushing it on to the
104+
end of the array `people`.
105105

106106
~~~
107107
people = Array.new
@@ -122,7 +122,7 @@ sorted = people.sort do |a,b| a.age <=> b.age end
122122
sorted # => [elmo (4), zoe (7), bert (8), ernie (8), cookie (11)]
123123
~~~
124124

125-
Another way would be to change the comparison method for class Person:
125+
Another way would be to change the comparison method for class `Person`:
126126

127127
~~~
128128
class Person
@@ -195,8 +195,8 @@ the last four in Japanese:
195195
~~~
196196
ruby-talk: English language discussion of Ruby.
197197
ruby-list: Japanese language discussion of Ruby.
198-
ruby-dev: List for Ruby developers.
199-
ruby-ext: List for people writing extensions for or with Ruby.
198+
ruby-dev: List for Ruby developers.
199+
ruby-ext: List for people writing extensions for or with Ruby.
200200
ruby-math: Ruby in mathematics.
201201
~~~
202202

@@ -221,9 +221,9 @@ set reply_regexp="^(\[[a-z0-9:-]+\][[:space:]]*)?(re([\[0-9\]+])*|aw):[[:space:]
221221
### Which is correct, “Ruby” or “ruby”?
222222

223223
Officially, the language is called “Ruby”. On most systems, it is invoked
224-
using the command `ruby`. It's OK to use ruby instead of Ruby.
224+
using the command `ruby`. It's OK to use ruby instead of Ruby.
225225

226-
Please don't use RUBY as the language name.
226+
Please don't use RUBY as the language name.
227227

228228
Originally, or historically, it was called “ruby”.
229229

@@ -250,17 +250,17 @@ expressions.
250250

251251
### Which editors provide support for Ruby?
252252

253-
* Emacs or XEmacs: ruby-mode.el is supplied in the Ruby distribution.
254-
With some versions of XEmacs, you may need to add (load "font-lock") to your
255-
.emacs file to allow ruby-mode.el to detect the syntax highlighting package
256-
you're using.
253+
* Emacs or XEmacs: `ruby-mode.el` is supplied in the Ruby distribution.
254+
With some versions of XEmacs, you may need to add `(load "font-lock")`
255+
to your `.emacs` file to allow `ruby-mode.el` to detect the syntax
256+
highlighting package you're using.
257257
* Vim: Vim 5.7 and later have Ruby syntax files as standard in the runtime
258258
package. For prior versions, a syntax file for Ruby is available at
259259
http://www.xs4all.nl/~hipster/lib/ruby/ruby.vim.
260260
* Jedit: A portable editor written in Java, comes with support for Ruby.
261261
* Jed: An s-lang file supporting Ruby is available at
262262
http://www.kondara.org/~g/slang/ruby.sl.
263-
* Nedit ( http://www.nedit.org): Eric Santonacci has written Ruby support for
263+
* Nedit (http://www.nedit.org): Eric Santonacci has written Ruby support for
264264
Nedit, available from ftp://ftp.talc.fr/pub/ruby/ruby.nedit-0.1.tar.gz.
265265
* Barry Shultz has written a Ruby definition file for TextPad, available at
266266
http://www.textpad.com/add-ons/ntsyn.html.
@@ -277,13 +277,13 @@ str = "Billy" + " Bob" # => "Billy Bob"
277277
str[0,1] + str[2,1] + str[-2,2] # => "Blob"
278278
~~~
279279

280-
Gotoken's xmp package, available from
280+
Gotoken's `xmp` package, available from
281281
http://www.ruby-lang.org/en/raa-list.rhtml?name=xmp is a utility that
282282
annotates Ruby source code this way.
283283

284284
Emacs and vim users can integrate this with their editing environments, which
285285
is useful if you want to send people e-mail with annotated Ruby code. Having
286-
installed xmp, Emacs users can add the following to their .emacs file:
286+
installed `xmp`, Emacs users can add the following to their `.emacs` file:
287287

288288
~~~
289289
(defun ruby-xmp-region (reg-start reg-end)
@@ -315,10 +315,12 @@ mailing list). Generally you'll get timely answers from matz himself, the
315315
author of the language, from other gurus, and from those who've solved
316316
problems similar to your own.
317317

318-
Please include the output of ruby -v along with any problematic source code.
318+
Please include the output of `ruby -v` along with any problematic
319+
source code.
319320

320-
If you have a problem using irb, be aware that it has some limitations.
321-
Try the script using `irb --single-irb`, or directly using the ruby command.
321+
If you have a problem using `irb`, be aware that it has some limitations.
322+
Try the script using `irb --single-irb`, or directly using the
323+
`ruby` command.
322324

323325
There might be similar questions in the mailing list, and it is good
324326
netiquette to read through recent mails (RFC1855:3.1.1, 3.1.2) before asking.

en/documentation/faq/10/index.md

+23-21
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ header: |
3939

4040
### How can I use Ruby interactively?
4141

42-
You can try using irb. The following is paraphrased from Goto Kentaro
42+
You can try using `irb`. The following is paraphrased from Goto Kentaro
4343
(Gotoken), and originally appeared in ruby-talk:444.
4444

4545
~~~
@@ -52,13 +52,13 @@ Possibly use rehash to tell your login shell about the new command.
5252
Type irb
5353
~~~
5454

55-
If the readline extension module works with your interpreter, it makes irb
55+
If the readline extension module works with your interpreter, it makes `irb`
5656
a lot more fun to use.
5757

58-
There is also a simple program, eval, in the samples/ directory of the Ruby
59-
distribution. It lets you enter expressions and view their values. You can
60-
copy eval into the site_ruby directory in the Ruby tree, and then invoke it
61-
using:
58+
There is also a simple program, `eval`, in the `samples/` directory of the
59+
Ruby distribution. It lets you enter expressions and view their values.
60+
You can copy `eval` into the `site_ruby` directory in the Ruby tree, and
61+
then invoke it using:
6262

6363
~~~
6464
ruby -r eval -e0
@@ -79,39 +79,41 @@ There are no problems with reference counting and variable types, and very
7979
few interfaces to learn. In fact, C code used to extend Ruby often ends up
8080
looking surprisingly like Ruby code itself.
8181

82-
First, get the Ruby source distribution and read README.EXT. This is a good
83-
document, not only if you're writing an extension library, but also if you
84-
want to understand Ruby more deeply.
82+
First, get the Ruby source distribution and read `README.EXT`. This is a
83+
good document, not only if you're writing an extension library, but also
84+
if you want to understand Ruby more deeply.
8585

8686
Next, have a look at the source of the interpreter itself, and at the various
87-
supplied extensions in the ext/ directory. You'll also find good examples
88-
under contrib/ on the Ruby ftp sites.
87+
supplied extensions in the `ext/` directory. You'll also find good examples
88+
under `contrib/` on the Ruby ftp sites.
8989

9090
### Can I use Tcl/Tk interface in Ruby?
9191

9292
There are two interfaces to Tcl/Tk included in the standard distribution.
93-
One is under ext/tcltk/ and loaded with require "tcltk". The syntax is very
94-
close to that Tcl, which is passed to Tcl interpreter. Unfortunately, the
95-
description for this library is written in Japanese.
93+
One is under `ext/tcltk/` and loaded with `require "tcltk"`. The syntax is
94+
very close to that Tcl, which is passed to Tcl interpreter.
95+
Unfortunately, the description for this library is written in Japanese.
9696

97-
The other is under ext/tk/ and loaded with require "tk". Its syntax closer to
98-
the style of the Tk interface provided by the Perl and Python interfaces.
97+
The other is under `ext/tk/` and loaded with `require "tk"`. Its syntax
98+
closer to the style of the Tk interface provided by the Perl and Python
99+
interfaces.
99100

100101
### Tk won't work.
101102

102103
Your Tk version may be old, try a newer version.
103104

104105
### Can I use gtk+ or xforms interfaces in Ruby?
105106

106-
You'll find ruby-gtk-x.xx.tar.gz and ruby-forms-x.x.tar.gz under contrib/
107+
You'll find ruby-gtk-x.xx.tar.gz and ruby-forms-x.x.tar.gz under `contrib/`
107108
in ftp sites.
108109

109110
### How can I do date arithmetic?
110111

111-
A Time object can express only the dates between Jan 1, 1970 and Jan 19, 2038.
112+
A `Time` object can express only the dates between Jan 1, 1970 and
113+
Jan 19, 2038.
112114

113115
Two standard extension library modules are provided:
114-
require "date", which is simple and uses the English calendar,
115-
and require "date2", which is more general purpose.
116+
`require "date"`, which is simple and uses the English calendar,
117+
and `require "date2"`, which is more general purpose.
116118

117-
Also see sample/cal.rb.
119+
Also see `sample/cal.rb`.

en/documentation/faq/11/index.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ header: |
3737

3838
## Other features
3939

40-
### What does a ? b : c mean?
40+
### What does `a ? b : c` mean?
4141

42-
It's the same as saying if a then b else c end.
42+
It's the same as saying `if a then b else c` end.
4343

4444
### How can I count the number of lines in a file?
4545

@@ -50,17 +50,17 @@ fastest result.
5050
open("example").read.count("\n") # => 3
5151
~~~
5252

53-
### What do begin and end of MatchingData return?
53+
### What do `begin` and `end` of `MatchingData` return?
5454

55-
They act with $ , and return the start index and the end index of the
56-
matched data ($0) in the original string. See an example in tab expansion.
55+
They act with `$ `, and return the start index and the end index of the
56+
matched data (`$0`) in the original string. See an example in tab expansion.
5757

5858
### How can I sum the elements in an array?
5959

6060
Rather than solve the specific problem, let's solve the general case. The
61-
first thing we'll do is produce a method that will iterate over an Enumerable
62-
object and collect a single result. Smalltalk calls that method inject, so we
63-
will too:
61+
first thing we'll do is produce a method that will iterate over an
62+
`Enumerable` object and collect a single result. Smalltalk calls that
63+
method inject, so we will too:
6464

6565
~~~
6666
module Enumerable
@@ -75,11 +75,11 @@ module Enumerable
7575
end
7676
~~~
7777

78-
Notice how we've added the method to Enumerable. This means that anything
79-
that includes Enumerable can now use inject. But how do we use it? It takes
80-
a single argument `n' and a block. For each element in the thing being
81-
enumerated, it calls the block, passing in `n' and the element itself.
82-
The result of the block is assigned back to `n'. So, to define sum,
78+
Notice how we've added the method to `Enumerable`. This means that anything
79+
that includes Enumerable can now use `inject`. But how do we use it? It takes
80+
a single argument `n` and a block. For each element in the thing being
81+
enumerated, it calls the block, passing in `n` and the element itself.
82+
The result of the block is assigned back to `n`. So, to define `sum`,
8383
we could write:
8484

8585
~~~
@@ -133,7 +133,6 @@ end
133133
~~~
134134

135135

136-
137136
~~~
138137
# --------------------------------------------------------------------
139138
# Filtering Out Multiples of a Given Number
@@ -160,7 +159,6 @@ end
160159
~~~
161160

162161

163-
164162
~~~
165163
# --------------------------------------------------------------------
166164
# Prime Number Generator

en/documentation/faq/2/index.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ of every method def. When a function is inserted into an object, the first
5454
argument automagically becomes a reference to the receiver.
5555

5656
Ruby is a pure OO language that can masquerade as a procedural one. It has no
57-
functions, only method calls. In a Ruby method the receiver, also called `self`,
58-
is a hidden argument like `this` in C++. A `def` statement outside of a
59-
class definition, which is a function in Python, is actually a method call in
60-
Ruby. These ersatz functions become private methods of class Object, the root
61-
of the Ruby class hierarchy. Procedural programming is neatly solved from the
62-
other direction - everything is an object. If the user doesn't grok objects
63-
yet, they can just pretend that `def` is a function definition and still
64-
get useful work done.
57+
functions, only method calls. In a Ruby method the receiver, also called
58+
`self`, is a hidden argument like `this` in C++. A `def` statement outside of
59+
a class definition, which is a function in Python, is actually a method call
60+
in Ruby. These ersatz functions become private methods of class Object, the
61+
root of the Ruby class hierarchy. Procedural programming is neatly solved from
62+
the other direction - everything is an object. If the user doesn't grok
63+
objects yet, they can just pretend that `def` is a function definition and
64+
still get useful work done.
6565

6666
Ruby's OO purity provides a number features that Python lacks or is still
6767
working toward: a unified type/class hierarchy, metaclasses, the ability to
68-
subclass everything, and uniform method invocation (none of this len() is a
69-
function but items() is a method rubbish). Ruby, like Smalltalk, only supports
70-
single inheritance, but it does have a very powerful mixin concept: a class
71-
definition may include a module, which inserts that module's methods,
68+
subclass everything, and uniform method invocation (none of this `len()` is a
69+
function but `items()` is a method rubbish). Ruby, like Smalltalk, only
70+
supports single inheritance, but it does have a very powerful mixin concept:
71+
a class definition may include a module, which inserts that module's methods,
7272
constants, etc. into the class.
7373

7474
Ruby, again like Smalltalk, provides closures and code blocks and uses them
@@ -77,14 +77,15 @@ outstanding, much more powerful and elegant than the ad hoc solutions that
7777
Python is sprouting (lambdas and list comprehensions).
7878

7979
Ruby's syntax and design philosophy are heavily influenced by Perl. It has a
80-
lot of syntactic variability. Statement modifiers (if, unless, while, until,
81-
etc.) may appear at the end of any statement. Some key words are optional
82-
(the `then` in an `if` statement for example). Parentheses may sometimes
83-
be elided in method calls. The receiver of a method may usually be elided.
80+
lot of syntactic variability. Statement modifiers (`if`, `unless`, `while`,
81+
`until`, etc.) may appear at the end of any statement. Some key words are
82+
optional (the `then` in an `if` statement for example). Parentheses may
83+
sometimes be elided in method calls. The receiver of a method may usually be
84+
elided.
8485
Many, many things are lifted directly from Perl.
85-
Built in regular expressions, $_ and friends, here documents,
86-
the single-quoted / double-quoted string distinction, $ and @ prefixes
87-
to distinguish different kinds of names and so forth.
86+
Built in regular expressions, `$_` and friends, here documents, the
87+
single-quoted / double-quoted string distinction, `$` and `@` prefixes to
88+
distinguish different kinds of names and so forth.
8889

8990
If you like Perl, you will like Ruby and be right at home with its syntax.
9091
If you like Smalltalk, you will like Ruby and be right at home with its
@@ -97,5 +98,5 @@ mined for P3K. I'm not sure how many Python programmers will be attracted to
9798
it though - it hasn't won me over (yet). But it is worthy of serious study and
9899
could be a real threat to Perl.
99100

100-
Posted by John Dell'Aquila in comp.lang.python, 11/17/2000. Reproduced with
101-
permission.
101+
Posted by John Dell'Aquila in comp.lang.python, 11/17/2000.
102+
Reproduced with permission.

0 commit comments

Comments
 (0)