From ab55bf33e243e874e458264817b1c80cfdb81370 Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Thu, 4 Jan 2018 11:17:01 +0100 Subject: [PATCH 1/9] doc : being more explicit in the sypnosis Assuming less knowledge on the part of the reader, making it easier to get start using Node.js. --- doc/api/synopsis.md | 54 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index ada2437387b7e2..1d2c6e485e8eca 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -9,9 +9,43 @@ Please see the [Command Line Options][] document for information about different options and ways to run scripts with Node.js. ## Example - An example of a [web server][] written with Node.js which responds with -`'Hello World'`: +`'Hello World!'`: + +Firstly, Make sure you have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). +Then, Follow this [installation guide](https://nodejs.org/en/download/package-manager/). + + +Now, Create an empty project folder called `projects`, navigate into it: + +Linux and Mac: + +```txt +$ mkdir ~/projects +$ cd ~/projects +``` +Windows CMD: +```txt +> mkdir %USERPROFILE%\projects +> cd %USERPROFILE%\projects +``` + +Windows PowerShell: + +```txt +> mkdir $env:USERPROFILE\projects +> cd $env:USERPROFILE\projects +``` + +Next, create a new source file in the `projects` folder and call it `hello_world.js`. + +If you’re using more than one word in your filename, use an underscore(`_`) to separate them for simplicity and avoid using the space character in file names. + +For example, you’d use `hello_world.js` rather than `hello world.js`. +Node.js files always end with the `.js` extension. + +open `hello_world.js` in your favorite text editor and paste in the following content. + ```js const http = require('http'); @@ -22,21 +56,25 @@ const port = 3000; const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); - res.end('Hello World\n'); + res.end('Hello World!\n'); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` - -To run the server, put the code into a file called `example.js` and execute -it with Node.js: +Save the file, and go back to your terminal window enter the following command: ```txt -$ node example.js -Server running at http://127.0.0.1:3000/ +$ node hello_world.js ``` +Your should see an output like this in your terminal to indicate Node.js server is running: + ```javascript + Server running at http://127.0.0.1:3000/ + ```` + Now, Open your favorite browser and visit `http://127.0.0.1:3000`. + + You should see the string `Hello, world!`. Many of the examples in the documentation can be run similarly. From 2d75d3d48cf412222d86aa664e397ff5744b6b34 Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Thu, 4 Jan 2018 13:42:26 +0100 Subject: [PATCH 2/9] Typos and corrections --- doc/api/synopsis.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 1d2c6e485e8eca..191ff15a36f886 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -12,11 +12,11 @@ different options and ways to run scripts with Node.js. An example of a [web server][] written with Node.js which responds with `'Hello World!'`: -Firstly, Make sure you have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). -Then, Follow this [installation guide](https://nodejs.org/en/download/package-manager/). +Firstly, make sure you have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). +Then, follow this [installation guide](https://nodejs.org/en/download/package-manager/). -Now, Create an empty project folder called `projects`, navigate into it: +Now, create an empty project folder called `projects`, navigate into it: Linux and Mac: @@ -37,14 +37,14 @@ Windows PowerShell: > cd $env:USERPROFILE\projects ``` -Next, create a new source file in the `projects` folder and call it `hello_world.js`. +Next, create a new source file in the `projects` folder and call it `hello-world.js`. -If you’re using more than one word in your filename, use an underscore(`_`) to separate them for simplicity and avoid using the space character in file names. +If you’re using more than one word in your filename, use an hyphen (`-`) or an underscore(`_`) to separate them for simplicity and avoid using the space character in file names. -For example, you’d use `hello_world.js` rather than `hello world.js`. +For example, you’d use `hello-world.js` rather than `hello world.js`. Node.js files always end with the `.js` extension. -open `hello_world.js` in your favorite text editor and paste in the following content. +Open `hello-world.js` in your favorite text editor and paste in the following content. ```js @@ -63,16 +63,16 @@ server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` -Save the file, and go back to your terminal window enter the following command: +Save the file, go back to your terminal window enter the following command: ```txt -$ node hello_world.js +$ node hello-world.js ``` -Your should see an output like this in your terminal to indicate Node.js server is running: +you should see an output like this in your terminal to indicate Node.js server is running: ```javascript Server running at http://127.0.0.1:3000/ ```` - Now, Open your favorite browser and visit `http://127.0.0.1:3000`. + Now, open your favorite browser and visit `http://127.0.0.1:3000`. You should see the string `Hello, world!`. From 9e91b4143440305ad83fd2665af7517b62c59c4c Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Thu, 4 Jan 2018 15:16:08 +0100 Subject: [PATCH 3/9] corrections and wrapping lines at 80 chars. --- doc/api/synopsis.md | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 191ff15a36f886..da98eaa87c7f9b 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -12,12 +12,33 @@ different options and ways to run scripts with Node.js. An example of a [web server][] written with Node.js which responds with `'Hello World!'`: +We’ll be displaying a number of commands using a terminal, and those lines + +start with `$` or `>`. You don’t need to type in the `$` and `>` character; + +they are there to indicate the start of each command. + +You’ll see many tutorials and examples around the web that follow this + +convention: `$` or `>` for commands run as a regular user, and `#` + +for commands you should be running as an administrator. + +Lines that don’t start with `$` or `>` are typically showing the output of + +the previous command. + Firstly, make sure you have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). -Then, follow this [installation guide](https://nodejs.org/en/download/package-manager/). + +If you want to install Node using a package manager, see [this guide](https://nodejs.org/en/download/package-manager/). Now, create an empty project folder called `projects`, navigate into it: +You can name your folder as you like or base on your current project title but + +we choose to use `projects` for the purpose of this example. + Linux and Mac: ```txt @@ -37,14 +58,21 @@ Windows PowerShell: > cd $env:USERPROFILE\projects ``` -Next, create a new source file in the `projects` folder and call it `hello-world.js`. +Next, create a new source file in the `projects` folder + +and call it `hello-world.js`. + +If you’re using more than one word in your filename, use an hyphen (`-`) or + +an underscore(`_`) to separate them for simplicity and avoid using -If you’re using more than one word in your filename, use an hyphen (`-`) or an underscore(`_`) to separate them for simplicity and avoid using the space character in file names. +the space character in file names. For example, you’d use `hello-world.js` rather than `hello world.js`. Node.js files always end with the `.js` extension. -Open `hello-world.js` in your favorite text editor and paste in the following content. +Open `hello-world.js` in your favorite text editor and paste in the following +content. ```js @@ -68,8 +96,9 @@ Save the file, go back to your terminal window enter the following command: ```txt $ node hello-world.js ``` -you should see an output like this in your terminal to indicate Node.js server is running: - ```javascript +you should see an output like this in your terminal to indicate Node.js +server is running: + ``` Server running at http://127.0.0.1:3000/ ```` Now, open your favorite browser and visit `http://127.0.0.1:3000`. From 5427e5ad97dc07e64acc907e0840a5cd9216f803 Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Thu, 4 Jan 2018 21:41:30 +0100 Subject: [PATCH 4/9] eliminating personal pronouns --- doc/api/synopsis.md | 52 +++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index da98eaa87c7f9b..7010752728e7e0 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -12,32 +12,26 @@ different options and ways to run scripts with Node.js. An example of a [web server][] written with Node.js which responds with `'Hello World!'`: -We’ll be displaying a number of commands using a terminal, and those lines - -start with `$` or `>`. You don’t need to type in the `$` and `>` character; - -they are there to indicate the start of each command. - -You’ll see many tutorials and examples around the web that follow this +Commands displayed in this document are shown starting with `$` or `>` +to replicate how they would appear in a user's terminal. +Do not include the `$` and `>` character they are there to +indicate the start of each command. +There are many tutorials and examples that follow this convention: `$` or `>` for commands run as a regular user, and `#` +for commands that should be executed as an administrator. -for commands you should be running as an administrator. - -Lines that don’t start with `$` or `>` are typically showing the output of - -the previous command. +Lines that don’t start with `$` or `>` character are typically showing +the output of the previous command. -Firstly, make sure you have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). +Firstly, make sure to have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). -If you want to install Node using a package manager, see [this guide](https://nodejs.org/en/download/package-manager/). +To install Node using a package manager, see [this guide](https://nodejs.org/en/download/package-manager/). Now, create an empty project folder called `projects`, navigate into it: - -You can name your folder as you like or base on your current project title but - -we choose to use `projects` for the purpose of this example. +Project folder can be named base on user's current project title but +this example will use `projects` as the project folder. Linux and Mac: @@ -58,20 +52,17 @@ Windows PowerShell: > cd $env:USERPROFILE\projects ``` -Next, create a new source file in the `projects` folder - +Next, create a new source file in the `projects` folder and call it `hello-world.js`. -If you’re using more than one word in your filename, use an hyphen (`-`) or - +If filename has more than one word, use a hyphen(`-`) or an underscore(`_`) to separate them for simplicity and avoid using - the space character in file names. -For example, you’d use `hello-world.js` rather than `hello world.js`. +For example, use `hello-world.js` rather than `hello world.js`. Node.js files always end with the `.js` extension. -Open `hello-world.js` in your favorite text editor and paste in the following +Open `hello-world.js` in any preferred text editor and paste in the following content. @@ -91,19 +82,20 @@ server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` -Save the file, go back to your terminal window enter the following command: +Save the file, go back to the terminal window enter the following command: ```txt $ node hello-world.js ``` -you should see an output like this in your terminal to indicate Node.js +an output like this should appear in the terminal to indicate Node.js server is running: - ``` + ```txt Server running at http://127.0.0.1:3000/ ```` - Now, open your favorite browser and visit `http://127.0.0.1:3000`. +Now, open any preferred web browser and visit `http://127.0.0.1:3000`. - You should see the string `Hello, world!`. +If the browser displays the string `Hello, world!`, that indicates +the server is working. Many of the examples in the documentation can be run similarly. From f42d3c274f3887d0cb1680e4214350dbff5b3b9a Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Thu, 4 Jan 2018 22:51:17 +0100 Subject: [PATCH 5/9] update language aware fences --- doc/api/synopsis.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 7010752728e7e0..814e8db8c51089 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -35,19 +35,19 @@ this example will use `projects` as the project folder. Linux and Mac: -```txt +```console $ mkdir ~/projects $ cd ~/projects ``` Windows CMD: -```txt +```console > mkdir %USERPROFILE%\projects > cd %USERPROFILE%\projects ``` Windows PowerShell: -```txt +```console > mkdir $env:USERPROFILE\projects > cd $env:USERPROFILE\projects ``` @@ -84,12 +84,12 @@ server.listen(port, hostname, () => { ``` Save the file, go back to the terminal window enter the following command: -```txt +```console $ node hello-world.js ``` an output like this should appear in the terminal to indicate Node.js server is running: - ```txt + ```console Server running at http://127.0.0.1:3000/ ```` Now, open any preferred web browser and visit `http://127.0.0.1:3000`. From bf4e20f82aa5011ceb794a35a8f5d21fbf3af6ad Mon Sep 17 00:00:00 2001 From: "Tim O. Peters" Date: Fri, 5 Jan 2018 07:24:17 +0100 Subject: [PATCH 6/9] correcting punctuation and OS trademarks --- doc/api/synopsis.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 814e8db8c51089..35d264395724f6 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -14,8 +14,8 @@ An example of a [web server][] written with Node.js which responds with Commands displayed in this document are shown starting with `$` or `>` to replicate how they would appear in a user's terminal. -Do not include the `$` and `>` character they are there to -indicate the start of each command. +Do not include the `$` and `>` character. +They are there to indicate the start of each command. There are many tutorials and examples that follow this convention: `$` or `>` for commands run as a regular user, and `#` @@ -33,7 +33,7 @@ Now, create an empty project folder called `projects`, navigate into it: Project folder can be named base on user's current project title but this example will use `projects` as the project folder. -Linux and Mac: +UNIX : ```console $ mkdir ~/projects From 47cf571d92fcd003970f02704c2802afd7e6be3b Mon Sep 17 00:00:00 2001 From: "Timothy O. Peters" Date: Sun, 21 Jan 2018 09:26:04 +0100 Subject: [PATCH 7/9] corrections --- doc/api/synopsis.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 35d264395724f6..9f9f1144f7493b 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -14,8 +14,8 @@ An example of a [web server][] written with Node.js which responds with Commands displayed in this document are shown starting with `$` or `>` to replicate how they would appear in a user's terminal. -Do not include the `$` and `>` character. -They are there to indicate the start of each command. +Do not include the `$` and `>` character they are there to +indicate the start of each command. There are many tutorials and examples that follow this convention: `$` or `>` for commands run as a regular user, and `#` @@ -24,22 +24,22 @@ for commands that should be executed as an administrator. Lines that don’t start with `$` or `>` character are typically showing the output of the previous command. -Firstly, make sure to have downloaded Node.js from [Node.js Official website](http://nodejs.org/#download). - -To install Node using a package manager, see [this guide](https://nodejs.org/en/download/package-manager/). - +Firstly, make sure to have downloaded and installed Node.js. +See [this guide][] for further install information. Now, create an empty project folder called `projects`, navigate into it: Project folder can be named base on user's current project title but this example will use `projects` as the project folder. -UNIX : +Linux and Mac: ```console $ mkdir ~/projects $ cd ~/projects ``` + Windows CMD: + ```console > mkdir %USERPROFILE%\projects > cd %USERPROFILE%\projects @@ -55,17 +55,12 @@ Windows PowerShell: Next, create a new source file in the `projects` folder and call it `hello-world.js`. -If filename has more than one word, use a hyphen(`-`) or -an underscore(`_`) to separate them for simplicity and avoid using -the space character in file names. - -For example, use `hello-world.js` rather than `hello world.js`. -Node.js files always end with the `.js` extension. +In Node.js it is considered good style to use hyphens (`-`) or underscores (`_`) to separate +multiple words in filenames. Open `hello-world.js` in any preferred text editor and paste in the following content. - ```js const http = require('http'); @@ -82,16 +77,20 @@ server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); ``` + Save the file, go back to the terminal window enter the following command: ```console $ node hello-world.js ``` -an output like this should appear in the terminal to indicate Node.js + +An output like this should appear in the terminal to indicate Node.js server is running: + ```console Server running at http://127.0.0.1:3000/ ```` + Now, open any preferred web browser and visit `http://127.0.0.1:3000`. If the browser displays the string `Hello, world!`, that indicates @@ -101,3 +100,5 @@ Many of the examples in the documentation can be run similarly. [Command Line Options]: cli.html#cli_command_line_options [web server]: http.html +[this guide]: https://nodejs.org/en/download/package-manager/ +[Node.js Official website]: http://nodejs.org/#download From 54b63eb3ed03ac71fa32ad9393df83009ed59aa0 Mon Sep 17 00:00:00 2001 From: "Timothy O. Peters" Date: Sun, 21 Jan 2018 16:12:01 +0100 Subject: [PATCH 8/9] corrections --- doc/api/synopsis.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 9f9f1144f7493b..ad137287dae6aa 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -101,4 +101,3 @@ Many of the examples in the documentation can be run similarly. [Command Line Options]: cli.html#cli_command_line_options [web server]: http.html [this guide]: https://nodejs.org/en/download/package-manager/ -[Node.js Official website]: http://nodejs.org/#download From 3afa466602722ba53c1466ae3874cffddf4233f4 Mon Sep 17 00:00:00 2001 From: "Timothy O. Peters" Date: Thu, 1 Feb 2018 21:40:17 +0100 Subject: [PATCH 9/9] break long par to new line --- doc/api/synopsis.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index ad137287dae6aa..cd752ef4c90c04 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -52,14 +52,15 @@ Windows PowerShell: > cd $env:USERPROFILE\projects ``` -Next, create a new source file in the `projects` folder -and call it `hello-world.js`. +Next, create a new source file in the `projects` + folder and call it `hello-world.js`. -In Node.js it is considered good style to use hyphens (`-`) or underscores (`_`) to separate -multiple words in filenames. +In Node.js it is considered good style to use +hyphens (`-`) or underscores (`_`) to separate + multiple words in filenames. -Open `hello-world.js` in any preferred text editor and paste in the following -content. +Open `hello-world.js` in any preferred text editor and +paste in the following content. ```js const http = require('http');