ruby_on_rails_guides_guidelines.md 3.9 KB
Newer Older
X
Xavier Noria 已提交
1 2
**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.**

3 4
Ruby on Rails Guides Guidelines
===============================
5

6
This guide documents guidelines for writing Ruby on Rails Guides. This guide follows itself in a graceful loop, serving itself as an example.
7

8 9
After reading this guide, you will know:

V
Vijay Dev 已提交
10 11
* About the conventions to be used in Rails documentation.
* How to generate guides locally.
12

13
--------------------------------------------------------------------------------
14

15
Markdown
16
-------
17

18
Guides are written in [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown). There is comprehensive [documentation for Markdown](http://daringfireball.net/projects/markdown/syntax), as well as a [cheatsheet](http://daringfireball.net/projects/markdown/basics).
19

20 21
Prologue
--------
22

23
Each guide should start with motivational text at the top (that's the little introduction in the blue area). The prologue should tell the reader what the guide is about, and what they will learn. As an example, see the [Routing Guide](routing.html).
24

25
Headings
26
------
M
Matt Duncan 已提交
27

28
The title of every guide uses an `h1` heading; guide sections use `h2` headings; subsections use `h3` headings; etc. Note that the generated HTML output will use heading tags starting with `<h2>`.
29 30 31 32 33 34 35 36 37 38

```
Guide Title
===========

Section
-------

### Sub Section
```
39

40
When writing headings, capitalize all words except for prepositions, conjunctions, internal articles, and forms of the verb "to be":
41

42
```
43 44
#### Middleware Stack is an Array
#### When are Objects Saved?
45
```
46

47
Use the same inline formatting as regular text:
48

49
```
50
##### The `:content_type` Option
51
```
52

53 54
API Documentation Guidelines
----------------------------
55

56
The guides and the API should be coherent and consistent where appropriate. In particular, these sections of the [API Documentation Guidelines](api_documentation_guidelines.html) also apply to the guides:
57

58
* [Wording](api_documentation_guidelines.html#wording)
59
* [English](api_documentation_guidelines.html#english)
60
* [Example Code](api_documentation_guidelines.html#example-code)
61
* [Filenames](api_documentation_guidelines.html#file-names)
62
* [Fonts](api_documentation_guidelines.html#fonts)
63

64 65
HTML Guides
-----------
66

S
Sunny Ripert 已提交
67
Before generating the guides, make sure that you have the latest version of Bundler installed on your system. As of this writing, you must install Bundler 1.3.5 on your device.
68

69
To install the latest version of Bundler, run `gem install bundler`.
70

71
### Generation
72

73
To generate all the guides, just `cd` into the `guides` directory, run `bundle install`, and execute:
74

75
```
76
bundle exec rake guides:generate
77
```
78 79 80

or

81
```
82
bundle exec rake guides:generate:html
83
```
84

85
To process `my_guide.md` and nothing else use the `ONLY` environment variable:
86

87
```
88
touch my_guide.md
89
bundle exec rake guides:generate ONLY=my_guide
90
```
91

92
By default, guides that have not been modified are not processed, so `ONLY` is rarely needed in practice.
93

94
To force processing all the guides, pass `ALL=1`.
95

96
It is also recommended that you work with `WARNINGS=1`. This detects duplicate IDs and warns about broken internal links.
97

98
If you want to generate guides in a language other than English, you can keep them in a separate directory under `source` (eg. `source/es`) and use the `GUIDES_LANGUAGE` environment variable:
99

100
```
101
bundle exec rake guides:generate GUIDES_LANGUAGE=es
102
```
103 104 105

If you want to see all the environment variables you can use to configure the generation script just run:

106
```
107
rake
108
```
109

110
### Validation
111

112
Please validate the generated HTML with:
113

114
```
115
bundle exec rake guides:validate
116
```
117

118
Particularly, titles get an ID generated from their content and this often leads to duplicates. Please set `WARNINGS=1` when generating guides to detect them. The warning messages suggest a solution.
119

120 121
Kindle Guides
-------------
122

123
### Generation
124

125
To generate guides for the Kindle, use the following rake task:
126

127
```
128
bundle exec rake guides:generate:kindle
129
```