0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
Commit Graph

33 Commits

Author SHA1 Message Date
Sam Ruby
f41dd5592e tools: produce JSON documentation using unified/remark/rehype
PR-URL: https://github.com/nodejs/node/pull/21697
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-07-25 21:33:06 +03:00
Vse Mozhet Byt
7fcb52c7b2 tools: improve heading type detection in json.js
PR-URL: https://github.com/nodejs/node/pull/20074
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-04-22 18:09:37 +03:00
Vse Mozhet Byt
9a6dd07e8d tools: overhaul tools/doc/json.js
Modernize:
* Replace `var` with `const` / `let`.
* Wrap `switch` cases with `const`/`let` in blocks.
* Replace common functions with arrow functions.
* Replace string concatenation with template literals.
* Shorthand object literals.
* Use destructuring and spread.

Optimize:
* Move RegExp declaration out of loops.
* Replace `.match()` with `.test()` in boolean context.
* Replace RegExp with string when string suffices.
* Make RegExp more strict to reject unrelated cases.
* Make RegExp do the trimming to eliminate many `.trim()` calls.
* Cache retrieved object properties.
* Remove conditions that cannot be false.
* Remove code that seems obsolete
  (it means a state that cannot happen or is not typical).

Clarify:
* Sync code examples in comments with the actual source state.
* Expand some one-letter variable names.
* Rename confusingly similar variables.
* Move variable declarations closer to their context.
* Remove non-actual commented out code.
* Unify blank lines between top-level blocks.

Fix:
* Fix conditions that cannot be true.

Guard:
* Throw on unexpected state more often.

PR-URL: https://github.com/nodejs/node/pull/19832
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2018-04-08 16:57:47 +03:00
Vse Mozhet Byt
237cbe10fb doc,tools: formalize, unify, codify default values
PR-URL: https://github.com/nodejs/node/pull/19737
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-04 12:30:36 +03:00
Vse Mozhet Byt
83d44bee01 tools: dry utility function in tools/doc/json.js
Also, move a declaration of unrelated variable
closer to its only context.

PR-URL: https://github.com/nodejs/node/pull/19692
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-30 16:34:27 +03:00
Vse Mozhet Byt
b88477ef4d tools: fix comment nits in tools/doc/*.js files
* Unify first letters case.
* Unify periods.
* Delete excess spaces.
* Add some blank lines as logical delimiters.
* Remove obvious comments.
* Combine short lines, rewrap lines more logically.
* Fix typos.
* "XXX" -> "TODO:", OSX -> macOS.

PR-URL: https://github.com/nodejs/node/pull/19696
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-03-30 16:07:48 +03:00
Giovanni Lela
cab34ba75e tools: replace string concatenation with template literals
Replace a string concatenation in the processList function
in doc/json.js.

If missing, initialize the textRow property in the same line of the
concatenation.

PR-URL: https://github.com/nodejs/node/pull/16806
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-11-06 18:02:33 +00:00
Minya Liang
9f98989484
tools: replace concat with template literals
PR-URL: https://github.com/nodejs/node/pull/16046
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Lance Ball <lball@redhat.com>
2017-10-09 02:13:21 -07:00
Sebastiaan Deckers
bb29405904
lib,src: fix consistent spacing inside braces
PR-URL: https://github.com/nodejs/node/pull/14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21 15:13:47 -04:00
Ruben Bridgewater
461049f8e9
tools: change var to const in ./doc/json
PR-URL: https://github.com/nodejs/node/pull/13732
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-07-02 19:26:50 -04:00
cjihrig
7a4d383c75 tools: enable no-useless-return eslint rule
PR-URL: https://github.com/nodejs/node/pull/12577
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-04-25 12:01:55 -04:00
James M Snell
98e54b0bd4 meta: restore original copyright header
A prior io.js era commit inappropriately removed the
original copyright statements from the source. This
restores those in any files still remaining from that
edit.

Ref: https://github.com/nodejs/TSC/issues/174
Ref: https://github.com/nodejs/node/pull/10599
PR-URL: https://github.com/nodejs/node/pull/10155

Note: This PR was required, reviewed-by and approved
by the Node.js Foundation Legal Committee and the TSC.
There is no `Approved-By:` meta data.
2017-03-10 11:23:48 -08:00
Rich Trott
79117b98b9 tools: refactor json.js
* Simplify regular expressions (see below)
* Remove unneeded `parseYAML()` wrapper
* Remove unused callback argument

Regular expression simplifications include:

* Changing trailing `*?$/` to `*$/` because non-greedy matching to the
  end of a line will not change behavior
* Change regexp beginnings like `/^(?:property:?\s*)?[^.\[]+` to the
  equivalent `/[^.\]]+`
* For regular expressions changed per the above, remove
  case-insensitivity if it no longer affects the regexp

PR-URL: https://github.com/nodejs/node/pull/10442
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
2016-12-28 22:34:42 -08:00
Prince J Wesley
0f4c7b8c37 lib,tools: remove unneeded escaping of /
The `/` character does not need to be escaped when occurring inside a
character class in a regular expression. Remove such instances of
escaping in the code base.

PR-URL: https://github.com/nodejs/node/pull/9591
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2016-11-23 22:06:24 -08:00
Rich Trott
4463d2b360 benchmark,lib,test,tools: remove unneeded . escape
The `.` character does not need to be escaped when it appears inside a
regular expression character class. This removes instances of
unnecessary escapes of the `.` character.

This also removes a few unnecessary escapes of the `(` and `)`
characters within character classes too.

PR-URL: https://github.com/nodejs/node/pull/9449
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: James Snell <jasnell@gmail.com>
2016-11-06 19:22:01 -08:00
Timothy Gu
a7fa72156a
doc/json: make sure links are correctly passed to marked
Previously, an attempt was made to make sure the links state is
inherited. Unfortunately, this support was not complete, which
results in various unresolved links in the JSON output (as an
example, [1] contains `initialized by calling
[<code>buf.fill(fill, encoding)</code>][<code>buf.fill()</code>]`).

This commit completes that attempt. After this commit, individual
instances of the parser (for descriptions) inherit the links state
from the root lexer, so that individual Markdown links in descriptions
could be resolved. That same example is now substituted with
`initialized by calling <a href=\"#buffer_buf_fill_value_offset_end_encoding\"><code>buf.fill(fill, encoding)</code></a>`.

[1]: https://nodejs.org/api/buffer.json

PR-URL: https://github.com/nodejs/node/pull/8494
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-09-16 17:29:05 +02:00
Anna Henningsen
c809b88345
doc: use blockquotes for Stability: markers
Use blockquotes instead of code blocks for stability markers in
the docs. Doing that:

- Makes the makers appear correctly when viewed e.g. on github.
- Allows remark-lint rules like `no-undefined-references` to work
  properly (https://github.com/nodejs/node/pull/7729).

PR-URL: https://github.com/nodejs/node/pull/7757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-08-04 22:43:34 +02:00
Daniel Wang
3f69ea53fd
tools: update marked dependency
Update module marked. Customize renderer to remove id from heading.

PR-URL: https://github.com/nodejs/node/pull/6396
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-05-07 09:27:05 +02:00
Tristian Flanagan
015f4fda0e
tools: parse documentation metadata
This commit introduces the Documentation YAML metadata concept to the
documentation.

- Parses added or Added for HTML
- Parses all data for JSON

Ref: https://github.com/nodejs/node/pull/3867
Ref: https://github.com/nodejs/node/issues/3713
Ref: https://github.com/nodejs/node/issues/6470
PR-URL: https://github.com/nodejs/node/pull/6495
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2016-05-05 01:15:10 +02:00
firedfox
6222e5b76d
tools,doc: fix json for grouped optional params
Current tools/doc/json.js only supports one bracket style for optional
params methodName(param0[,param1],param2). Add support to other styles
such as methodName(param0,[param1,]param2) or
methodName(param0[,param1,param2]) or
methodName(param0[,param1[,param2]]).

PR-URL: https://github.com/nodejs/node/pull/5977
Fixes: https://github.com/nodejs/node/issues/5976
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Lindstädt <robert.lindstaedt@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-04-09 18:40:26 +02:00
firedfox
05d0e9e6a3
tools,doc: fix incomplete json produced by doctool
Doc tool produces incomplete json when it meets unordered lists that
directly following a heading. Add a default case to processList function
to handle the lists.

PR-URL: https://github.com/nodejs/node/pull/5966
Fixes: https://github.com/nodejs/node/issues/1545
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Lindstädt <robert.lindstaedt@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-04-09 18:34:07 +02:00
firedfox
05b3a0b22c tools: fix json doc generation
Current processList function in tools/doc/json.js does not recognise
{"type":"loose_item_start"}. Fix it.

PR-URL: https://github.com/nodejs/node/pull/5943
Fixes: https://github.com/nodejs/node/issues/5942
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Robert Lindstädt <robert.lindstaedt@gmail.com>
2016-03-30 17:52:49 +02:00
Rich Trott
c14c12e6ba tools: fix redeclared vars in doc/json.js
PR-URL: https://github.com/nodejs/node/pull/5047
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-04 09:52:02 -08:00
Rich Trott
2d89d3d1e6 tools: apply linting to doc tools
Apply eslint rules to `tools/doc`.

PR-URL: https://github.com/nodejs/node/pull/4973
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-02-01 23:40:41 -08:00
Timothy Gu
aeb2eb7783 tools: fix detecting constructor for JSON doc
Regex previous was not detecting cases like AssertionError as
a class name.

PR-URL: https://github.com/nodejs/node/pull/4966
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chris Dickinson <chris@neversaw.us>
2016-02-01 08:30:43 -08:00
Timothy Gu
ab45390e01 tools: add property types in JSON documentation
PR-URL: https://github.com/nodejs/node/pull/4884
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-01-30 11:01:37 -08:00
Shigeki Ohtsu
05f17db8b2 tools: fix warning in doc parsing
The description of "[start[, end]]" in the doc shows warning of
"invalid param" when parsing an optional parameter in the section.
This fixes insufficient trimming of right square brackets.

PR-URL: https://github.com/nodejs/node/pull/4537
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-01-05 10:13:39 -08:00
isaacs
3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00
Trevor Norris
f2a78de6ec doc: fix optional parameter parsing
The parameter parser specifically looked for the old bracket syntax.
This generated a lot of warnings when building the docs. Those warnings
have been fixed by changing the parsing logic.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-29 16:32:34 -07:00
isaacs
33f9074a62 Mention marked, and add license to doc generator 2012-03-05 10:59:14 -08:00
isaacs
4ca3fd0a01 Handle miscs better 2012-02-29 16:04:56 -08:00
isaacs
17db291b5c 'Events' is a module, not an event named 's' 2012-02-29 16:04:55 -08:00
isaacs
217bb47b02 New documentation generation tool 2012-02-29 15:15:25 -08:00