Skip to content

Commit 3b2d2b0

Browse files
committed
Make readme code examples consistent; Update to use GH syntax fences
1 parent 84da169 commit 3b2d2b0

File tree

1 file changed

+135
-59
lines changed

1 file changed

+135
-59
lines changed

README.md

Lines changed: 135 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,30 @@ How to build your own jQuery
4141

4242
First, clone a copy of the main jQuery git repo by running:
4343

44-
`git clone git://github.com/jquery/jquery.git`
44+
```bash
45+
git clone git://github.com/jquery/jquery.git
46+
```
4547

4648
Enter the directory and install the node dependencies:
4749

48-
`cd jquery && npm install`
50+
```bash
51+
cd jquery && npm install
52+
```
4953

5054

5155
Make sure you have `grunt` installed by testing:
5256

53-
`grunt -version`
57+
```bash
58+
grunt -version
59+
```
5460

5561

5662

5763
Then, to get a complete, minified (w/ Uglify.js), linted (w/ JSHint) version of jQuery, type the following:
5864

59-
`grunt`
65+
```bash
66+
grunt
67+
```
6068

6169

6270
The built version of jQuery will be put in the `dist/` subdirectory.
@@ -75,21 +83,27 @@ To create a custom build, use the following special `grunt` commands:
7583

7684
Exclude `dimensions`:
7785

78-
`grunt build:*:*:-dimensions`
86+
```bash
87+
grunt build:*:*:-dimensions
88+
```
7989

8090
Exclude `effects`:
8191

82-
`grunt build:*:*:-effects`
92+
```bash
93+
grunt build:*:*:-effects
94+
```
8395

8496
Exclude `offset`:
8597

86-
`grunt build:*:*:-offset`
87-
98+
```bash
99+
grunt build:*:*:-offset
100+
```
88101

89102
Exclude **all** optional modules:
90103

91-
`grunt build:*:*:-dimensions:-effects:-offset`
92-
104+
```bash
105+
grunt build:*:*:-dimensions:-effects:-offset
106+
```
93107

94108

95109

@@ -99,8 +113,9 @@ Running the Unit Tests
99113

100114
Start grunt to auto-build jQuery as you work:
101115

102-
`cd jquery && grunt watch`
103-
116+
```bash
117+
cd jquery && grunt watch
118+
```
104119

105120

106121
Run the unit tests with a local server that supports PHP. No database is required. Pre-configured php local servers are available for Windows and Mac. Here are some options:
@@ -118,14 +133,14 @@ Building to a different directory
118133

119134
If you want to build jQuery to a directory that is different from the default location:
120135

121-
`grunt && grunt dist:/path/to/special/location/`
122-
136+
```bash
137+
grunt && grunt dist:/path/to/special/location/
138+
```
123139
With this example, the output files would be:
124140

125141
```bash
126142
/path/to/special/location/jquery.js
127143
/path/to/special/location/jquery.min.js
128-
129144
```
130145

131146
If you want to add a permanent copy destination, create a file in `dist/` called ".destination.json". Inside the file, paste and customize the following:
@@ -135,7 +150,6 @@ If you want to add a permanent copy destination, create a file in `dist/` called
135150
{
136151
"/Absolute/path/to/other/destination": true
137152
}
138-
139153
```
140154

141155

@@ -148,8 +162,9 @@ Updating Submodules
148162

149163
Update the submodules to what is probably the latest upstream code.
150164

151-
`grunt submodules`
152-
165+
```bash
166+
grunt submodules
167+
```
153168

154169
Note: This task will also be run any time the default `grunt` command is used.
155170

@@ -167,46 +182,61 @@ be able to work with them manually.
167182

168183
Following are the steps to manually get the submodules:
169184

170-
1. `git clone https://github.com/jquery/jquery.git`
171-
2. `git submodule init`
172-
3. `git submodule update`
185+
```bash
186+
git clone https://github.com/jquery/jquery.git
187+
git submodule init
188+
git submodule update
189+
```
173190

174191
Or:
175192

176-
1. `git clone https://github.com/jquery/jquery.git`
177-
2. `git submodule update --init`
193+
```bash
194+
git clone https://github.com/jquery/jquery.git
195+
git submodule update --init
196+
```
178197

179198
Or:
180199

181-
1. `git clone --recursive https://github.com/jquery/jquery.git`
200+
```bash
201+
git clone --recursive https://github.com/jquery/jquery.git
202+
```
182203

183204
If you want to work inside a submodule, it is possible, but first you need to checkout a branch:
184205

185-
1. `cd src/sizzle`
186-
2. `git checkout master`
206+
```bash
207+
cd src/sizzle
208+
git checkout master
209+
```
187210

188211
After you've committed your changes to the submodule, you'll update the jquery project to point to the new commit,
189212
but remember to push the submodule changes before pushing the new jquery commit:
190213

191-
1. `cd src/sizzle`
192-
2. `git push origin master`
193-
3. `cd ..`
194-
4. `git add src/sizzle`
195-
5. `git commit`
214+
```bash
215+
cd src/sizzle
216+
git push origin master
217+
cd ..
218+
git add src/sizzle
219+
git commit
220+
```
196221

197222

198223
### cleaning ###
199224

200225
If you want to purge your working directory back to the status of upstream, following commands can be used (remember everything you've worked on is gone after these):
201226

202-
1. `git reset --hard upstream/master`
203-
2. `git clean -fdx`
227+
```bash
228+
git reset --hard upstream/master
229+
git clean -fdx
230+
```
204231

205232
### rebasing ###
206233

207234
For feature/topic branches, you should always used the `--rebase` flag to `git pull`, or if you are usually handling many temporary "to be in a github pull request" branches, run following to automate this:
208235

209-
* `git config branch.autosetuprebase local` (see `man git-config` for more information)
236+
```bash
237+
git config branch.autosetuprebase local
238+
```
239+
(see `man git-config` for more information)
210240

211241
### handling merge conflicts ###
212242

@@ -229,51 +259,91 @@ Following are some commands that can be used there:
229259

230260
### Test methods ###
231261

232-
expect( numAssertions );
233-
stop();
234-
start();
235-
note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite
236-
so that start and stop can be passed as callbacks without worrying about their parameters
262+
```js
263+
expect( numAssertions );
264+
stop();
265+
start();
266+
```
267+
268+
269+
note: QUnit's eventual addition of an argument to stop/start is ignored in this test suite so that start and stop can be passed as callbacks without worrying about their parameters
237270

238271
### Test assertions ###
239272

240-
ok( value, [message] );
241-
equal( actual, expected, [message] );
242-
notEqual( actual, expected, [message] );
243-
deepEqual( actual, expected, [message] );
244-
notDeepEqual( actual, expected, [message] );
245-
strictEqual( actual, expected, [message] );
246-
notStrictEqual( actual, expected, [message] );
247-
raises( block, [expected], [message] );
273+
274+
```js
275+
ok( value, [message] );
276+
equal( actual, expected, [message] );
277+
notEqual( actual, expected, [message] );
278+
deepEqual( actual, expected, [message] );
279+
notDeepEqual( actual, expected, [message] );
280+
strictEqual( actual, expected, [message] );
281+
notStrictEqual( actual, expected, [message] );
282+
raises( block, [expected], [message] );
283+
```
284+
248285

249286
Test Suite Convenience Methods Reference (See [test/data/testinit.js](https://github.com/jquery/jquery/blob/master/test/data/testinit.js))
250287
------------------------------
251288

252289
### Returns an array of elements with the given IDs ###
253290

254-
q( ... );
291+
```js
292+
q( ... );
293+
```
294+
295+
Example:
255296

256-
@example `q("main", "foo", "bar")` => [`<div id="main">`, `<span id="foo">`, `input id="bar">`]
297+
```js
298+
q("main", "foo", "bar");
299+
300+
=> [ div#main, span#foo, input#bar ]
301+
```
257302

258303
### Asserts that a selection matches the given IDs ###
259304

260-
t( testName, selector, [ "array", "of", "ids" ] );
305+
```js
306+
t( testName, selector, [ "array", "of", "ids" ] );
307+
```
308+
309+
Example:
310+
311+
```js
312+
t("Check for something", "//[a]", ["foo", "baar"]);
313+
```
314+
261315

262-
@example `t("Check for something", "//[a]", ["foo", "baar"]);`
263316

264317
### Fires a native DOM event without going through jQuery ###
265318

266-
fireNative( node, eventType );
319+
```js
320+
fireNative( node, eventType )
321+
```
322+
323+
Example:
267324

268-
@example `fireNative( jQuery("#elem")[0], "click" );`
325+
```js
326+
fireNative( jQuery("#elem")[0], "click" );
327+
```
269328

270329
### Add random number to url to stop caching ###
271330

272-
url( "some/url.php" );
331+
```js
332+
url( "some/url.php" );
333+
```
273334

274-
@example `url("data/test.html")` => `"data/test.html?10538358428943"`
335+
Example:
275336

276-
@example `url("data/test.php?foo=bar")` => `"data/test.php?foo=bar&10538358345554"`
337+
```js
338+
url("data/test.html");
339+
340+
=> "data/test.html?10538358428943"
341+
342+
343+
url("data/test.php?foo=bar");
344+
345+
=> "data/test.php?foo=bar&10538358345554"
346+
```
277347

278348

279349
### Load tests in an iframe ###
@@ -282,11 +352,15 @@ Loads a given page constructing a url with fileName: `"./data/" + fileName + ".h
282352
and fires the given callback on jQuery ready (using the jQuery loading from that page)
283353
and passes the iFrame's jQuery to the callback.
284354

285-
testIframe( fileName, testName, callback );
355+
```js
356+
testIframe( fileName, testName, callback );
357+
```
286358

287359
Callback arguments:
288360

289-
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument )
361+
```js
362+
callback( jQueryFromIFrame, iFrameWindow, iFrameDocument );
363+
```
290364

291365
### Load tests in an iframe (window.iframeCallback) ###
292366

@@ -295,7 +369,9 @@ The given callback is fired when window.iframeCallback is called by the page
295369
The arguments passed to the callback are the same as the
296370
arguments passed to window.iframeCallback, whatever that may be
297371

298-
testIframeWithCallback( testName, fileName, callback )
372+
```js
373+
testIframeWithCallback( testName, fileName, callback );
374+
```
299375

300376
Questions?
301377
----------

0 commit comments

Comments
 (0)