From 2595a7ccf95a28c9b3396525406aa175aba4ac6c Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 12 Apr 2016 13:25:03 -0400 Subject: [PATCH 1/3] doc: better example & synopsis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/nodejs/node/pull/6167 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Robert Jefe Lindstädt --- doc/api/_toc.md | 2 +- doc/api/synopsis.md | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/doc/api/_toc.md b/doc/api/_toc.md index 5c8fbdd7901e20..52d8b94fe43518 100644 --- a/doc/api/_toc.md +++ b/doc/api/_toc.md @@ -1,7 +1,7 @@ @// NB(chrisdickinson): if you move this file, be sure to update tools/doc/html.js to @// point at the new location. * [About these Docs](documentation.html) -* [Synopsis](synopsis.html) +* [Usage & Example](synopsis.html) * [Assertion Testing](assert.html) * [Buffer](buffer.html) * [C/C++ Addons](addons.html) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 7dd3b8fe99d7fd..134c0dbed7286e 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -1,29 +1,43 @@ -# Synopsis +# Usage +`node [options] [v8 options] [script.js | -e "script"] [arguments]` + +Please see the [Command Line Options][] document for information about +different options and ways to run scripts with Node. + +## Example + An example of a [web server][] written with Node.js which responds with `'Hello World'`: ```js const http = require('http'); -http.createServer( (request, response) => { - response.writeHead(200, {'Content-Type': 'text/plain'}); - response.end('Hello World\n'); -}).listen(8124); +const hostname = '127.0.0.1'; +const port = 3000; + +const server = http.createServer((req, res) => { + res.statusCode = 200; + res.setHeader('Content-Type', 'text/plain'); + res.end('Hello World\n'); +}); -console.log('Server running at http://127.0.0.1:8124/'); +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 the node program +it with Node.js: ``` $ node example.js -Server running at http://127.0.0.1:8124/ +Server running at http://127.0.0.1:3000/ ``` All of the examples in the documentation can be run similarly. +[Command Line Options]: cli.html#cli_command_line_options [web server]: http.html From 3a4224d4a5e8cf0525098bcbde9786da8bcaf7ea Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 12 Apr 2016 13:25:44 -0400 Subject: [PATCH 2/3] doc: no Node.js(1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node.js(1) does not make sense. Node(1) would, but this isn’t a `man` page. https://github.com/nodejs/node/pull/6167 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Robert Jefe Lindstädt --- doc/template.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/template.html b/doc/template.html index dec3f50670226e..71e3a21e1d4d5c 100644 --- a/doc/template.html +++ b/doc/template.html @@ -13,7 +13,7 @@
__GTOC__ From c8d1db8efee7eca9fdc555d92eb2dc0731c12eb0 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 12 Apr 2016 13:26:21 -0400 Subject: [PATCH 3/3] doc: subdivide TOC, add auxiliary links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/nodejs/node/pull/6167 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Robert Jefe Lindstädt --- doc/api/_toc.md | 8 ++++++++ doc/api_assets/style.css | 31 ++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/doc/api/_toc.md b/doc/api/_toc.md index 52d8b94fe43518..2527ad84e2e360 100644 --- a/doc/api/_toc.md +++ b/doc/api/_toc.md @@ -2,6 +2,9 @@ @// point at the new location. * [About these Docs](documentation.html) * [Usage & Example](synopsis.html) + +
+ * [Assertion Testing](assert.html) * [Buffer](buffer.html) * [C/C++ Addons](addons.html) @@ -39,3 +42,8 @@ * [V8](v8.html) * [VM](vm.html) * [ZLIB](zlib.html) + +
+ +* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) +* [Mailing List](http://groups.google.com/group/nodejs) diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index b093b2c3fe11fd..bb25c4d0a1f6d2 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -92,6 +92,12 @@ em code { font-size: .8em; } +.line { + width: calc(100% - 1em); + display: block; + padding-bottom: 1px; +} + .api_stability { color: white !important; margin: 0 0 1em 0; @@ -207,6 +213,12 @@ header h1 { padding-top: 1em; } +#apicontent .line { + width: calc(50% - 1em); + margin: 1em 1em .95em; + background-color: #ccc; +} + #toc + h1 { margin-top: 1em; padding-top: 0; @@ -388,10 +400,22 @@ a code { #column2 ul { list-style: none; - margin: 1.25em 0; + margin: .9em 0 .5em; background: #333; } +#column2 > :first-child { + margin: 1.25em 1em; +} + +#column2 > ul:nth-child(2) { + margin: 1.25em 0 .5em; +} + +#column2 > ul:last-child { + margin: .9em 0 1.25em; +} + #column2 ul li { padding-left: 1.4em; margin-bottom: .5em; @@ -399,6 +423,11 @@ a code { font-size: .8em; } +#column2 .line { + margin: 0 .5em; + background-color: #707070; +} + #column2 ul li:last-child { margin-bottom: 0; }