Skip to content
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,39 @@ myURL.port = 1234.5678;
console.log(myURL.port);
// Prints 1234

// Out-of-range numbers are ignored
myURL.port = 1e10;
// Out-of-range numbers, which are not represented in scientific noation,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: noation -> notation

// will be ignored.
myURL.port = 1e10; // 10000000000, will be range-checked as described below
console.log(myURL.port);
// Prints 1234

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this empty line seems redundant.

```

The port value may be set as either a number or as a String containing a number
in the range `0` to `65535` (inclusive). Setting the value to the default port
of the `URL` objects given `protocol` will result in the `port` value becoming
the empty string (`''`).

If an invalid string is assigned to the `port` property, but it begins with a
number, the leading number is assigned to `port`. Otherwise, or if the number
lies outside the range denoted above, it is ignored.
Upon assigning a value to the port, the value will first be converted to a string using `.toString()`.

If that string is invalid, but it begins with a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why, but the wrapping of these two paragraphs creates hard wraps in the rendered text: https://github.com/nodeav/node/blob/e402ff4b54dd1eeb0cd0e7ce346751e97769c880/doc/api/url.md#urlport

Maybe we can rewrap them with more long lines (but within 80 characters)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand, in which line does the hard wrap occur?
And are we really limited to 80 characters? Existing lines in this doc are considerably longer

Copy link
Copy Markdown
Contributor

@vsemozhetbyt vsemozhetbyt Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, existing lines more than 80 chars is a temporal legacy, but now we have a rule in the STYLE_GUIDE.md and doc linting should throw on limit breaking.

I mean these hard wraps:
hb
breaks:

Copy link
Copy Markdown
Contributor

@vsemozhetbyt vsemozhetbyt Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see You have trailing spaces after some added lines, and markdown parses such spaces as hard breaks. It is usually useful to trim trailing spaces in the editor before saving the doc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the trailing spaces were actually intentional, but I don't mind changing that.

and good to know about the line widths

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces are not usually safe to rely upon in shared sources: some collaborator may edit any other line and have their editor set for trailing spaces auto-trimming in the whole doc, so these spaces may be deleted silently in any other PR)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an actual designated docs linter? How do I run it?
(I made the changes manually for now)

by the way, automatically removing trailing spaces for markdown documents is a bug IMO, as it's ignoring a part of the markdown language

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made sure the regex \ $ doesn't find any result in the document.

Copy link
Copy Markdown
Contributor

@vsemozhetbyt vsemozhetbyt Apr 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken. this is how to lint docs locally:

make lint-md-build
make test-doc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The first one says there's nothing to be done; the second one passes.

number, the leading number is assigned to `port`.
Otherwise, or if the number
lies outside the range denoted above, it is ignored.

Note that numbers which contain a decimal point,
such as floating-point numbers or numbers in scientific notation, are not an exception to this rule.
Leading numbers up to the decimal point will be set as the url's port, assuming they are valid.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: url's -> URL's?


For example:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Remove this line and put a colon instead of a period after valid on the line of text above this one.


```js
myURL.port = 4.567e21;
console.log(myURL.port);
// Prints 4 (because it is the leading number in the string "4.567e21")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "4.567e21" -> '4.567e21'?
We usually use single quotes in code-related things.


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this empty line seems redundant.

```


#### url.protocol

Expand Down