Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add how to access URL constructor #21928

Closed
wants to merge 1 commit into from
Closed

doc: add how to access URL constructor #21928

wants to merge 1 commit into from

Conversation

tim-phillips
Copy link

It was unclear to me how to access the constructor. This should clear things up for future users.

Checklist

@addaleax
Copy link
Member

It might be worth explicitly mentioning that this only applies up to Node 8, since Node 10 it’s also accessibly as a global?

@addaleax addaleax added doc Issues and PRs related to the documentations. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Jul 21, 2018
@Trott
Copy link
Member

Trott commented Jul 21, 2018

It might be worth explicitly mentioning that this only applies up to Node 8, since Node 10 it’s also accessibly as a global?

In that case, should this PR target v8.x-staging rather than master?

@Trott
Copy link
Member

Trott commented Jul 21, 2018

In that case, should this PR target v8.x-staging rather than master?

The v8.x docs include the const { URL } = require('url'); in the relevant example. See https://nodejs.org/dist/latest-v8.x/docs/api/url.html#url_url_strings_and_url_objects.

So I think this PR may be unnecessary? (Or maybe there's an issue where it's not sufficiently clear what version of the docs one is reading on the website?)

@tim-phillips
Copy link
Author

I didn’t realize it was global, even though it does mention it in the doc. I was looking specifically for an import statement.

Would it be against convention to add /* global: URL */ to the first example? Or is there a convention to mark things as global in the docs?

@richardlau
Copy link
Member

FWIW the const { URL } = require('url'); was removed by #20364.

@TimothyGu
Copy link
Member

BTW the v8.x docs have const { URL } = require('url'); in all of its examples.

@Trott
Copy link
Member

Trott commented Jul 22, 2018

Would it be against convention to add /* global: URL */ to the first example? Or is there a convention to mark things as global in the docs?

I don't think we do that anywhere else, but that doesn't mean we can't in this situation or start a general practice along those lines. /pinging @nodejs/documentation @nodejs/website for thoughts

@devsnek
Copy link
Member

devsnek commented Jul 22, 2018

i thought the current practice was to treat the examples as runnable code yea? so if they reference something without require/etc it should be assumed to be a global.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jul 22, 2018

i thought the current practice was to treat the examples as runnable code yea?

FWIW, we still have this point in the STYLE_GUIDE:

Code need not be complete — treat code blocks as an illustration or aid to your point, not as complete running programs. If a complete running program is necessary, include it as an asset in assets/code-examples and link to it.

And we still have many examples with assumed require().

@addaleax
Copy link
Member

addaleax commented Sep 2, 2018

Given the above comments, I’m closing this.

If you think this should be re-opened, please let us know and we’ll be happy to do so!

@addaleax addaleax closed this Sep 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants